0

从 solaris 中 fcntl 的 Mannul 开始,成功完成后,为 F_SETLKW 返回的值将是“-1 以外的值”。但是 Apache httpd 1.3.41 源代码(http_main.c)检查返回值是否为正,如:

int ret;

while ((ret = fcntl(lock_fd, F_SETLKW, &unlock_it)) < 0 && errno == EINTR) {
    /* nop */
}

if (ret < 0) {
    ap_log_error(APLOG_MARK, APLOG_EMERG, server_conf,
                "fcntl: F_SETLKW: Error getting accept lock, exiting!  "
                "Perhaps you need to use the LockFile directive to place "
                "your lock file on a local disk!");
    clean_child_exit(APEXIT_CHILDFATAL);
}

在极少数情况下,我们的系统之一中的 apache 会因为测试失败而退出。我怀疑这是由 fcntl 返回的小于 -1 的负值引起的。

那么solaris中的fcntl什么时候会返回小于-1的值呢?

4

1 回答 1

0
  1. 在您的代码示例中,fcntl 返回 <0(例如,您知道的 -1)意味着如果 errno 不是 EINTR,则可能有错误,如果 errno == EINTR(中断),这不是错误,只是建议重试。
  2. “从solaris中fcntl的Mannul,成功完成后,F_SETLKW返回的值将是-1以外的值”,表示成功时返回0或>0,“>=0”是-1以外的值,不是< -1 如您所料。
于 2009-10-13T05:51:21.107 回答