Richard Valk wrote:

Recently tried to upgrade to the latest version of the courier-auth
daemon on my Mac OS X 10.4 and noticed a (I hope) small problem with the
latest 2 releases.

I compiled using:

./configure --with-authmysql --without-authpam
--with-mysql-libs=/usr/local/mysql/lib/mysql
--with-mysql-includes=/usr/local/mysql/include

As I did always with previous version succesfully, but when trying to
run I got the following error.

richard$ sudo /usr/local/sbin/authdaemond start
/usr/local/var/spool/authdaemon/pid.lock: Bad file descriptor
ll_daemon_start: Resource temporarily unavailable

I reverted to 0.59.3, compiled that with the same settings and
everything works again.

I'm unable to determine what has changed to cause this issue.

Does someone have any ideas ?

OPEN_MAX is the value used in ll_daemon_start() to figure out an available file descriptor. I've heard that Mac OS X may have some absurdly high value which may actually be larger than the actual file descriptor table size. Can you try the attached patch?

        Cheers,

        -- Johnny C. Lam
$NetBSD$

--- liblock/lockdaemon.c.orig   Wed Sep 26 02:44:34 2007
+++ liblock/lockdaemon.c
@@ -31,10 +31,21 @@
 #include       <sys/ioctl.h>
 #endif
 
-#ifndef OPEN_MAX
-#ifdef HAVE_SYSCONF
-#ifdef _SC_OPEN_MAX
-#define OPEN_MAX       (my_open_max())
+/*
+** XXX This should be replaced by an autoconf test, e.g.
+** XXX AC_FUNCS([getdtablesize]).
+*/
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
+    defined(__APPLE__)
+#define HAVE_GETDTABLESIZE 1
+#endif
+
+#if HAVE_GETDTABLESIZE
+#define MAX_FD         (getdtablesize()-1)
+#elif defined(OPEN_MAX)
+#define MAX_FD         (OPEN_MAX-1)
+#elif HAVE_SYSCONF && defined(_SC_OPEN_MAX)
+#define MAX_FD         (my_open_max()-1)
 
 static int my_open_max()
 {
@@ -45,12 +56,8 @@ static int my_open_max()
        return n;
 }
 
-#endif
-#endif
-#endif
-
-#ifndef OPEN_MAX
-#define OPEN_MAX       64
+#else
+#define MAX_FD         63
 #endif
 
 #define exit(_a_) _exit(_a_)
@@ -168,14 +175,14 @@ int       lockfd;
                lockfd=open(lockfile, O_RDWR|O_CREAT, 0600);
        }
 
-       if (lockfd < 0 || dup2(lockfd, OPEN_MAX-1) != OPEN_MAX-1)
+       if (lockfd < 0 || dup2(lockfd, MAX_FD) != MAX_FD)
        {
                perror(lockfile);
                exit(1);
        }
 
        close(lockfd);
-       lockfd=OPEN_MAX-1;
+       lockfd=MAX_FD;
 
 #ifdef FD_CLOEXEC
        if (fcntl(lockfd, F_SETFD, FD_CLOEXEC) < 0)
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
courier-users mailing list
[email protected]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users

Reply via email to