From f468664b18b26f84ef7c9229105cc051270dddf2 Mon Sep 17 00:00:00 2001 From: didg Date: Mon, 19 Oct 2009 08:09:07 +0000 Subject: [PATCH] cnid dbd remove on time() syscall in the loop --- etc/cnid_dbd/comm.c | 13 ++++++++----- etc/cnid_dbd/comm.h | 4 ++-- etc/cnid_dbd/main.c | 6 ++---- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/etc/cnid_dbd/comm.c b/etc/cnid_dbd/comm.c index bdc696f1..04e43420 100644 --- a/etc/cnid_dbd/comm.c +++ b/etc/cnid_dbd/comm.c @@ -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) diff --git a/etc/cnid_dbd/comm.h b/etc/cnid_dbd/comm.h index a570a227..614bd27d 100644 --- a/etc/cnid_dbd/comm.h +++ b/etc/cnid_dbd/comm.h @@ -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); diff --git a/etc/cnid_dbd/main.c b/etc/cnid_dbd/main.c index dcb46511..febadc1a 100644 --- a/etc/cnid_dbd/main.c +++ b/etc/cnid_dbd/main.c @@ -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) { -- 2.39.2