]> arthur.barton.de Git - netatalk.git/commitdiff
cnid dbd remove on time() syscall in the loop
authordidg <didg>
Mon, 19 Oct 2009 08:09:07 +0000 (08:09 +0000)
committerdidg <didg>
Mon, 19 Oct 2009 08:09:07 +0000 (08:09 +0000)
etc/cnid_dbd/comm.c
etc/cnid_dbd/comm.h
etc/cnid_dbd/main.c

index bdc696f146f41db4ddd756d979fb8c00dec7f85e..04e43420707684dcc3f5c974bcac4605094ddf32 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: comm.c,v 1.5 2009-10-18 17:50:13 didg Exp $
+ * $Id: comm.c,v 1.6 2009-10-19 08:09:07 didg Exp $
  *
  * Copyright (C) Joerg Lenneis 2003
  * All Rights Reserved.  See COPYING.
@@ -142,7 +142,7 @@ static int recv_cred(int fd)
  *  things and clean up fd_table. The same happens for any read/write errors.
  */
 
-static int check_fd(time_t timeout, const sigset_t *sigmask)
+static int check_fd(time_t timeout, const sigset_t *sigmask, time_t *now)
 {
     int fd;
     fd_set readfds;
@@ -170,10 +170,13 @@ static int check_fd(time_t timeout, const sigset_t *sigmask)
         return -1;
     }
 
+    time(&t);
+    if (now)
+        *now = t;
+
     if (!ret)
         return 0;
 
-    time(&t);
 
     if (FD_ISSET(control_fd, &readfds)) {
         int    l = 0;
@@ -251,12 +254,12 @@ int comm_nbe(void)
 }
 
 /* ------------ */
-int comm_rcv(struct cnid_dbd_rqst *rqst, time_t timeout, const sigset_t *sigmask)
+int comm_rcv(struct cnid_dbd_rqst *rqst, time_t timeout, const sigset_t *sigmask, time_t *now)
 {
     char *nametmp;
     int b;
 
-    if ((cur_fd = check_fd(timeout, sigmask)) < 0)
+    if ((cur_fd = check_fd(timeout, sigmask, now)) < 0)
         return -1;
 
     if (!cur_fd)
index a570a22716cac52210f820d7d2324097c661f509..614bd27da6adbeedbe166768f08fe811f6c49d7a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: comm.h,v 1.4 2009-10-18 17:50:13 didg Exp $
+ * $Id: comm.h,v 1.5 2009-10-19 08:09:07 didg Exp $
  *
  * Copyright (C) Joerg Lenneis 2003
  * All Rights Reserved.  See COPYING.
@@ -13,7 +13,7 @@
 
 
 extern int      comm_init  (struct db_param *, int, int);
-extern int      comm_rcv  (struct cnid_dbd_rqst *,  time_t, const sigset_t *);
+extern int      comm_rcv  (struct cnid_dbd_rqst *,  time_t, const sigset_t *, time_t *);
 extern int      comm_snd  (struct cnid_dbd_rply *);
 extern int      comm_nbe  (void);
 
index dcb46511651fa4148fc5231e004c07ad442f9e78..febadc1a7cae04d7c1daeae7299e7f300616ffe5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: main.c,v 1.14 2009-10-19 07:46:35 didg Exp $
+ * $Id: main.c,v 1.15 2009-10-19 08:09:07 didg Exp $
  *
  * Copyright (C) Joerg Lenneis 2003
  * Copyright (c) Frank Lahm 2009
@@ -124,11 +124,9 @@ static int loop(struct db_param *dbp)
         else
             timeout = 1;
 
-        if ((cret = comm_rcv(&rqst, timeout, &set)) < 0)
+        if ((cret = comm_rcv(&rqst, timeout, &set, &now)) < 0)
             return -1;
 
-        now = time(NULL);
-
         if (cret == 0) {
             /* comm_rcv returned from select without receiving anything. */
             if (exit_sig) {