]> arthur.barton.de Git - netatalk.git/commitdiff
Merge master
authorFrank Lahm <franklahm@googlemail.com>
Sat, 17 Mar 2012 21:18:14 +0000 (22:18 +0100)
committerFrank Lahm <franklahm@googlemail.com>
Sat, 17 Mar 2012 21:18:14 +0000 (22:18 +0100)
etc/cnid_dbd/cnid_metad.c
etc/cnid_dbd/main.c
libatalk/acl/uuid.c

index a264bd8874eb2127193f620b8df1813a3e216f66..5230b741b02b1aa7b76876d25ad2f7531eee3eab 100644 (file)
@@ -106,7 +106,7 @@ static volatile sig_atomic_t sigchild = 0;
 static uint maxvol;
 
 #define MAXSPAWN   3                   /* Max times respawned in.. */
-#define TESTTIME   42                  /* this much seconds apfd client tries to  *
+#define TESTTIME   10                  /* this much seconds apfd client tries to  *
                                         * to reconnect every 5 secondes, catch it */
 #define MAXVOLS    4096
 #define DEFAULTHOST  "localhost"
@@ -116,7 +116,7 @@ struct server {
     char *v_path;
     pid_t pid;
     time_t tm;                    /* When respawned last */
-    int count;                    /* Times respawned in the last TESTTIME secondes */
+    unsigned int count;           /* Times respawned in the last TESTTIME secondes */
     int control_fd;               /* file descriptor to child cnid_dbd process */
 };
 
@@ -199,25 +199,30 @@ static int maybe_start_dbd(const AFPObj *obj, char *dbdpn, const char *volpath)
             return -1;
         }
     } else {
-        /* we have a slot but no process, check for respawn too fast */
-        if ( (t < (up->tm + TESTTIME)) /* We're in the respawn time window */
-             &&
-             (up->count > MAXSPAWN) ) { /* ...and already tried to fork too often */
-            LOG(log_maxdebug, logtype_cnid, "maybe_start_dbd: respawn too fast just exiting");
-            return -1; /* just exit, dont sleep, because we might have work to do for another client  */
-        }
-        if ( t >= (up->tm + TESTTIME) ) { /* out of respawn too fast windows reset the count */
-            LOG(log_maxdebug, logtype_cnid, "maybe_start_dbd: respawn window ended");
-            up->tm = t;
-            up->count = 0;
+        /* we have a slot but no process */
+        if (up->count > 0) {
+            /* check for respawn too fast */
+            if (t < (up->tm + TESTTIME)) {
+                /* We're in the respawn time window */
+                if (up->count > MAXSPAWN) {
+                    /* ...and already tried to fork too often */
+                    LOG(log_maxdebug, logtype_cnid, "maybe_start_dbd: respawning too fast");
+                    return -1; /* just exit, dont sleep, because we might have work to do for another client  */
+                }
+            } else {
+                /* out of respawn too fast windows reset the count */
+                LOG(log_info, logtype_cnid, "maybe_start_dbd: respawn window ended");
+                up->count = 0;
+            }
         }
         up->count++;
-        LOG(log_maxdebug, logtype_cnid, "maybe_start_dbd: respawn count now is: %u", up->count);
+        up->tm = t;
+        LOG(log_maxdebug, logtype_cnid, "maybe_start_dbd: respawn count: %u", up->count);
         if (up->count > MAXSPAWN) {
             /* We spawned too fast. From now until the first time we tried + TESTTIME seconds
                we will just return -1 above */
-            LOG(log_maxdebug, logtype_cnid, "maybe_start_dbd: reached MAXSPAWN threshhold");
-        }
+            LOG(log_info, logtype_cnid, "maybe_start_dbd: reached MAXSPAWN threshhold");
+       }
     }
 
     /* 
@@ -550,6 +555,10 @@ int main(int argc, char *argv[])
             if (WIFEXITED(status)) {
                 LOG(log_info, logtype_cnid, "cnid_dbd[%i] exited with exit code %i",
                     pid, WEXITSTATUS(status));
+            } else {
+                /* cnid_dbd did a clean exit probably on idle timeout, reset bookkeeping */
+                srv[i].tm = 0;
+                srv[i].count = 0;
             }
             else if (WIFSIGNALED(status)) {
                 LOG(log_info, logtype_cnid, "cnid_dbd[%i] got signal %i",
index 1079fb5839051da06b03f6fd14515708cfd7e9d1..a5fbb2a23985438ccc878a0044816cc46013c421 100644 (file)
@@ -239,7 +239,7 @@ static void switch_to_user(char *dir)
         exit(1);
     }
     if (!getuid()) {
-        LOG(log_info, logtype_cnid, "Setting uid/gid to %i/%i", st.st_uid, st.st_gid);
+        LOG(log_debug, logtype_cnid, "Setting uid/gid to %i/%i", st.st_uid, st.st_gid);
         if (setgid(st.st_gid) < 0 || setuid(st.st_uid) < 0) {
             LOG(log_error, logtype_cnid, "uid/gid: %s", strerror(errno));
             exit(1);
index 83dd54581c481d3ed2ce03f983e55c2b8ffddbd8..7d6e7d620cf6ad0aaf554c814c9b0774e0ccc3d4 100644 (file)
@@ -113,9 +113,11 @@ const char *uuid_bin2string(const unsigned char *uuid) {
     int i = 0;
     unsigned char c;
 
+#ifdef HAVE_LDAP
     if (ldap_uuid_string)
         uuidmask = ldap_uuid_string;
     else
+#endif
         uuidmask = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
 
     LOG(log_debug, logtype_afpd, "uuid_bin2string{uuid}: mask: %s", uuidmask);