/*
- * $Id: main.c,v 1.12 2009-10-18 17:50:13 didg Exp $
+ * $Id: main.c,v 1.16 2009-11-25 14:59:15 franklahm Exp $
*
* Copyright (C) Joerg Lenneis 2003
* Copyright (c) Frank Lahm 2009
1: Success, if transactions are used commit.
0: Failure, but we continue to serve requests. If transactions are used abort/rollback.
- -1: Fatal error, either from the database or from the socket. Abort the transaction if applicable
+ -1: Fatal error, either from t
+ he database or from the socket. Abort the transaction if applicable
(which might fail as well) and then exit.
We always try to notify the client process about the outcome, the result field
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)
+ if (exit_sig) {
/* Received signal (TERM|INT) */
return 0;
- if (dbp->idle_timeout && comm_nbe() <= 0 && (now - time_last_rqst) > dbp->idle_timeout)
+ }
+ if (now - time_last_rqst >= dbp->idle_timeout && comm_nbe() <= 0) {
/* Idle timeout */
return 0;
+ }
+ /* still active connections, reset time_last_rqst */
+ time_last_rqst = now;
} else {
/* We got a request */
time_last_rqst = now;
ret = 1;
break;
case CNID_DBD_OP_ADD:
- ret = dbd_add(dbd, &rqst, &rply);
+ ret = dbd_add(dbd, &rqst, &rply, 0);
break;
case CNID_DBD_OP_GET:
ret = dbd_get(dbd, &rqst, &rply);
ret = dbd_resolve(dbd, &rqst, &rply);
break;
case CNID_DBD_OP_LOOKUP:
- ret = dbd_lookup(dbd, &rqst, &rply);
+ ret = dbd_lookup(dbd, &rqst, &rply, 0);
break;
case CNID_DBD_OP_UPDATE:
ret = dbd_update(dbd, &rqst, &rply);
Shall we checkpoint bdb ?
"flush_interval" seconds passed ?
*/
- if (now > time_next_flush) {
+ if (now >= time_next_flush) {
LOG(log_info, logtype_cnid, "Checkpointing BerkeleyDB for volume '%s'", dbp->dir);
if (dbif_txn_checkpoint(dbd, 0, 0, 0) < 0)
return -1;