Browse Source

ckdb - add a simple socketer timeout for quiet pools :)

master
kanoi 8 years ago
parent
commit
649461ff01
  1. 25
      src/ckdb.c
  2. 2
      src/ckdb.h

25
src/ckdb.c

@ -5940,8 +5940,9 @@ static void *socketer(void *arg)
char *end, *buf = NULL; char *end, *buf = NULL;
K_ITEM *bq_item = NULL; K_ITEM *bq_item = NULL;
BREAKQUEUE *bq = NULL; BREAKQUEUE *bq = NULL;
int sockd; int ret, sockd;
tv_t now, nowacc, now1, now2; fd_set rfds;
tv_t now, nowacc, now1, now2, tmo;
pthread_detach(pthread_self()); pthread_detach(pthread_self());
@ -5972,9 +5973,29 @@ static void *socketer(void *arg)
create_pthread(&proc_pt, process_socket, arg); create_pthread(&proc_pt, process_socket, arg);
} }
ret = 0;
setnow(&sock_stt); setnow(&sock_stt);
while (!everyone_die) { while (!everyone_die) {
setnow(&now1); setnow(&now1);
while (!everyone_die) {
FD_ZERO(&rfds);
FD_SET(us->sockd, &rfds);
tmo.tv_sec = 1;
tmo.tv_usec = 0;
ret = select(us->sockd + 1, &rfds, NULL, NULL, &tmo);
if (ret > 0)
break;
if (ret < 0) {
int e = errno;
LOGERR("%s() Failed to select on socket (%d:%s)",
__func__, e, strerror(e));
break;
}
}
// Timeout exit on no input (or error)
if (everyone_die || ret < 0)
break;
sockd = accept(us->sockd, NULL, NULL); sockd = accept(us->sockd, NULL, NULL);
if (sockd < 0) { if (sockd < 0) {
int e = errno; int e = errno;

2
src/ckdb.h

@ -58,7 +58,7 @@
#define DB_VLOCK "1" #define DB_VLOCK "1"
#define DB_VERSION "1.0.7" #define DB_VERSION "1.0.7"
#define CKDB_VERSION DB_VERSION"-2.405" #define CKDB_VERSION DB_VERSION"-2.406"
#define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__ #define WHERE_FFL_HERE __FILE__, __func__, __LINE__

Loading…
Cancel
Save