]> arthur.barton.de Git - netatalk.git/blobdiff - etc/cnid_dbd/cnid_metad.c
Reapply ugly hack for sys/socket.h include
[netatalk.git] / etc / cnid_dbd / cnid_metad.c
index b84a3ea0916537cd65da7711317928a6befe3956..7c5210745e47fee8d06bea6adda1c46285097945 100644 (file)
@@ -1,9 +1,8 @@
 /*
- * $Id: cnid_metad.c,v 1.22 2009-11-16 02:04:47 didg Exp $
- *
  * Copyright (C) Joerg Lenneis 2003
- * All Rights Reserved.  See COPYING.
+ * Copyright (C) Frank Lahm 2009, 2010
  *
+ * All Rights Reserved.  See COPYING.
  */
 
 /* 
@@ -22,6 +21,8 @@
    Result:
                        via TCP socket
    4.       afpd          ------->         cnid_dbd
+
+   cnid_metad and cnid_dbd have been converted to non-blocking IO in 2010.
  */
 
 
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
-#ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
-#endif
-#ifdef HAVE_SYS_WAIT_H
 #include <sys/wait.h>
-#endif
-#ifdef HAVE_SYS_UIO_H
 #include <sys/uio.h>
-#endif
 #include <sys/un.h>
 #define _XPG4_2 1
 #include <sys/socket.h>
@@ -319,10 +312,9 @@ static int maybe_start_dbd(char *dbdpn, char *dbdir, char *usockfn)
         else {
             ret = execlp(dbdpn, dbdpn, dbdir, buf1, buf2, logconfig, NULL);
         }
-        if (ret < 0) {
-            LOG(log_error, logtype_cnid, "Fatal error in exec: %s", strerror(errno));
-            daemon_exit(0);
-        }
+        /* Yikes! We're still here, so exec failed... */
+        LOG(log_error, logtype_cnid, "Fatal error in exec: %s", strerror(errno));
+        daemon_exit(0);
     }
     /*
      *  Parent.
@@ -605,8 +597,13 @@ int main(int argc, char *argv[])
         if (rqstfd <= 0)
             continue;
 
-        /* TODO: Check out read errors, broken pipe etc. in libatalk. Is
-           SIGIPE ignored there? Answer: Ignored for dsi, but not for asp ... */
+        /*
+         * Note:
+         * although we're in non-blocking mode, I didn't bother adding EAGAIN/select
+         * loops around read, because we're really reading only very small amounts here,
+         * and as we've just got the connection assuming the sent bytes are
+         * available for reading seems reasonable.
+         */
         ret = read(rqstfd, &len, sizeof(int));
         if (!ret) {
             /* already close */