Browse Source

Json RPC calls can take a while to return so use a custom timeout when talking to the generator from the stratifier

master
Con Kolivas 10 years ago
parent
commit
53656e1284
  1. 8
      src/ckpool.c
  2. 8
      src/ckpool.h
  3. 2
      src/stratifier.c

8
src/ckpool.c

@ -359,7 +359,7 @@ static int send_procmsg(proc_instance_t *pi, const char *buf)
}
sockd = open_unix_client(path);
if (unlikely(sockd < 0)) {
LOGWARNING("Failed to open socket %s in send_recv_proc", path);
LOGWARNING("Failed to open socket %s in send_procmsg", path);
goto out;
}
if (unlikely(!send_unix_msg(sockd, buf)))
@ -640,8 +640,8 @@ out:
/* Send a single message to a process instance and retrieve the response, then
* close the socket. */
char *_send_recv_proc(proc_instance_t *pi, int writetimeout, int readtimedout,
const char *msg, const char *file, const char *func, const int line)
char *_send_recv_proc(proc_instance_t *pi, const char *msg, int writetimeout, int readtimedout,
const char *file, const char *func, const int line)
{
char *path = pi->us.path, *buf = NULL;
int sockd;
@ -727,10 +727,10 @@ char *_ckdb_msg_call(const ckpool_t *ckp, const char *msg, const char *file, co
json_t *json_rpc_call(connsock_t *cs, const char *rpc_req)
{
float timeout = RPC_TIMEOUT;
char *http_req = NULL;
json_error_t err_val;
json_t *val = NULL;
float timeout = 60;
int len, ret;
if (unlikely(cs->fd < 0)) {

8
src/ckpool.h

@ -19,6 +19,8 @@
#include "libckpool.h"
#include "uthash.h"
#define RPC_TIMEOUT 60
struct ckpool_instance;
typedef struct ckpool_instance ckpool_t;
@ -245,9 +247,9 @@ void empty_buffer(connsock_t *cs);
int read_socket_line(connsock_t *cs, float *timeout);
void _send_proc(proc_instance_t *pi, const char *msg, const char *file, const char *func, const int line);
#define send_proc(pi, msg) _send_proc(pi, msg, __FILE__, __func__, __LINE__)
char *_send_recv_proc(proc_instance_t *pi, int writetimeout, int readtimedout,
const char *msg, const char *file, const char *func, const int line);
#define send_recv_proc(pi, msg) _send_recv_proc(pi, UNIX_WRITE_TIMEOUT, UNIX_READ_TIMEOUT, msg, __FILE__, __func__, __LINE__)
char *_send_recv_proc(proc_instance_t *pi, const char *msg, int writetimeout, int readtimedout,
const char *file, const char *func, const int line);
#define send_recv_proc(pi, msg) _send_recv_proc(pi, msg, UNIX_WRITE_TIMEOUT, UNIX_READ_TIMEOUT, __FILE__, __func__, __LINE__)
char *_send_recv_ckdb(const ckpool_t *ckp, const char *msg, const char *file, const char *func, const int line);
#define send_recv_ckdb(ckp, msg) _send_recv_ckdb(ckp, msg, __FILE__, __func__, __LINE__)
char *_ckdb_msg_call(const ckpool_t *ckp, const char *msg, const char *file, const char *func,

2
src/stratifier.c

@ -832,7 +832,7 @@ static char *__send_recv_generator(ckpool_t *ckp, const char *msg, const int pri
set = true;
} else
set = false;
buf = send_recv_proc(ckp->generator, msg);
buf = _send_recv_proc(ckp->generator, msg, UNIX_WRITE_TIMEOUT, RPC_TIMEOUT, __FILE__, __func__, __LINE__);
if (unlikely(!buf))
buf = strdup("failed");
if (set)

Loading…
Cancel
Save