]> arthur.barton.de Git - netatalk.git/blobdiff - etc/cnid_dbd/cnid_metad.c
cnid_metad don't drop the slot if it's outside the respawn window, reuse it
[netatalk.git] / etc / cnid_dbd / cnid_metad.c
index 3aaf4f150b5a082ece792377e5575c19f9cc891e..51eed6c27d208ccb3ca9b21db7cbf4513a87f6dd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: cnid_metad.c,v 1.12 2009-06-09 11:58:49 franklahm Exp $
+ * $Id: cnid_metad.c,v 1.17 2009-10-18 18:25:13 didg Exp $
  *
  * Copyright (C) Joerg Lenneis 2003
  * All Rights Reserved.  See COPYING.
 #define WTERMSIG(status)      ((status) & 0x7f)
 #endif
 
-#ifdef ATACC
-#define fork aTaC_fork
-#endif
-
 /* functions for username and group */
 #include <pwd.h>
 #include <grp.h>
 
 static int srvfd;
 static int rqstfd;
-volatile sig_atomic_t alarmed = 0;
+static volatile sig_atomic_t alarmed = 0;
 
 #define MAXSPAWN   3                   /* Max times respawned in.. */
 #define TESTTIME   42                  /* this much seconds apfd client tries to  *
@@ -248,11 +244,10 @@ static int maybe_start_dbd(char *dbdpn, char *dbdir, char *usockfn)
             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) ) { /* drop slot */
-            LOG(log_maxdebug, logtype_cnid, "maybe_start_dbd: respawn window ended, dropping slot");
-            free(up->name);
-            up->name = NULL;
-            return -1; /* next time we'll try again with a new slot */
+        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;
         }
         up->count++;
         LOG(log_maxdebug, logtype_cnid, "maybe_start_dbd: respawn count now is: %u", up->count);
@@ -347,8 +342,7 @@ static int set_dbdir(char *dbdir, int len)
 }
 
 /* ------------------ */
-uid_t user_to_uid ( username )
-    char    *username;
+static uid_t user_to_uid (char *username)
 {
     struct passwd *this_passwd;
 
@@ -367,8 +361,7 @@ uid_t user_to_uid ( username )
 }
 
 /* ------------------ */
-gid_t group_to_gid ( group )
-    char    *group;
+static gid_t group_to_gid ( char *group)
 {
     struct group *this_group;
 
@@ -387,7 +380,7 @@ gid_t group_to_gid ( group )
 }
 
 /* ------------------ */
-void catch_alarm(int sig) {
+static void catch_alarm(int sig _U_) {
     alarmed = 1;
 }