Browse Source

Set default unix read timeout back to 5 seconds except for ckpmsg and ckdb which need the 30s defaults, and double the write timeout

master
Con Kolivas 10 years ago
parent
commit
aa8460c0ba
  1. 2
      src/ckdb.c
  2. 8
      src/libckpool.c
  3. 10
      src/libckpool.h

2
src/ckdb.c

@ -3743,7 +3743,7 @@ static void *socketer(__maybe_unused void *arg)
cmdnum = CMD_UNSET; cmdnum = CMD_UNSET;
buf = recv_unix_msg(sockd); buf = recv_unix_msg_tmo2(sockd, RECV_UNIX_TIMEOUT1, RECV_UNIX_TIMEOUT2);
// Once we've read the message // Once we've read the message
setnow(&now); setnow(&now);
if (buf) { if (buf) {

8
src/libckpool.c

@ -1050,7 +1050,7 @@ bool _send_unix_msg(int sockd, const char *buf, const char *file, const char *fu
goto out; goto out;
} }
msglen = htole32(len); msglen = htole32(len);
ret = wait_write_select(sockd, 5); ret = wait_write_select(sockd, UNIX_WRITE_TIMEOUT);
if (unlikely(ret < 1)) { if (unlikely(ret < 1)) {
ern = errno; ern = errno;
LOGERR("Select1 failed in send_unix_msg (%d)", ern); LOGERR("Select1 failed in send_unix_msg (%d)", ern);
@ -1061,7 +1061,7 @@ bool _send_unix_msg(int sockd, const char *buf, const char *file, const char *fu
LOGERR("Failed to write 4 byte length in send_unix_msg"); LOGERR("Failed to write 4 byte length in send_unix_msg");
goto out; goto out;
} }
ret = wait_write_select(sockd, 5); ret = wait_write_select(sockd, UNIX_WRITE_TIMEOUT);
if (unlikely(ret < 1)) { if (unlikely(ret < 1)) {
ern = errno; ern = errno;
LOGERR("Select2 failed in send_unix_msg (%d)", ern); LOGERR("Select2 failed in send_unix_msg (%d)", ern);
@ -1089,7 +1089,7 @@ bool _send_unix_data(int sockd, const struct msghdr *msg, const char *file, cons
LOGWARNING("Null message sent to send_unix_data"); LOGWARNING("Null message sent to send_unix_data");
goto out; goto out;
} }
ret = wait_write_select(sockd, 5); ret = wait_write_select(sockd, UNIX_WRITE_TIMEOUT);
if (unlikely(ret < 1)) { if (unlikely(ret < 1)) {
LOGERR("Select1 failed in send_unix_data"); LOGERR("Select1 failed in send_unix_data");
goto out; goto out;
@ -1112,7 +1112,7 @@ bool _recv_unix_data(int sockd, struct msghdr *msg, const char *file, const char
bool retval = false; bool retval = false;
int ret; int ret;
ret = wait_read_select(sockd, 5); ret = wait_read_select(sockd, UNIX_READ_TIMEOUT);
if (unlikely(ret < 1)) { if (unlikely(ret < 1)) {
LOGERR("Select1 failed in recv_unix_data"); LOGERR("Select1 failed in recv_unix_data");
goto out; goto out;

10
src/libckpool.h

@ -236,6 +236,12 @@ void logmsg(int loglevel, const char *fmt, ...);
#define PAGESIZE (4096) #define PAGESIZE (4096)
/* Default timeouts for unix socket reads and writes in seconds. Set write
* timeout to double the read timeout in case of one read blocking the next
* writer. */
#define UNIX_READ_TIMEOUT 5
#define UNIX_WRITE_TIMEOUT 10
/* Share error values */ /* Share error values */
enum share_err { enum share_err {
@ -495,8 +501,8 @@ int read_length(int sockd, void *buf, int len);
char *_recv_unix_msg(int sockd, int timeout1, int timeout2, const char *file, const char *func, const int line); char *_recv_unix_msg(int sockd, int timeout1, int timeout2, const char *file, const char *func, const int line);
#define RECV_UNIX_TIMEOUT1 30 #define RECV_UNIX_TIMEOUT1 30
#define RECV_UNIX_TIMEOUT2 5 #define RECV_UNIX_TIMEOUT2 5
#define recv_unix_msg(sockd) _recv_unix_msg(sockd, RECV_UNIX_TIMEOUT1, RECV_UNIX_TIMEOUT2, __FILE__, __func__, __LINE__) #define recv_unix_msg(sockd) _recv_unix_msg(sockd, UNIX_READ_TIMEOUT, UNIX_READ_TIMEOUT, __FILE__, __func__, __LINE__)
#define recv_unix_msg_tmo(sockd, tmo) _recv_unix_msg(sockd, tmo, RECV_UNIX_TIMEOUT2, __FILE__, __func__, __LINE__) #define recv_unix_msg_tmo(sockd, tmo) _recv_unix_msg(sockd, tmo, UNIX_READ_TIMEOUT, __FILE__, __func__, __LINE__)
#define recv_unix_msg_tmo2(sockd, tmo1, tmo2) _recv_unix_msg(sockd, tmo1, tmo2, __FILE__, __func__, __LINE__) #define recv_unix_msg_tmo2(sockd, tmo1, tmo2) _recv_unix_msg(sockd, tmo1, tmo2, __FILE__, __func__, __LINE__)
int wait_write_select(int sockd, float timeout); int wait_write_select(int sockd, float timeout);
#define write_length(sockd, buf, len) _write_length(sockd, buf, len, __FILE__, __func__, __LINE__) #define write_length(sockd, buf, len) _write_length(sockd, buf, len, __FILE__, __func__, __LINE__)

Loading…
Cancel
Save