Browse Source

Add a function for sending binary data to another process

master
Con Kolivas 9 years ago
parent
commit
a743d307cf
  1. 17
      src/ckpool.c
  2. 2
      src/ckpool.h

17
src/ckpool.c

@ -718,17 +718,12 @@ out:
/* Send a single message to a process instance when there will be no response,
* closing the socket immediately. */
void _send_proc(proc_instance_t *pi, const char *msg, const char *file, const char *func, const int line)
void _send_proc_data(proc_instance_t *pi, const char *msg, const char *file, const char *func, const int line)
{
char *path = pi->us.path;
bool ret = false;
int sockd;
if (unlikely(!msg || !strlen(msg))) {
LOGERR("Attempted to send null message to %s in send_proc", pi->processname);
return;
}
if (unlikely(!path || !strlen(path))) {
LOGERR("Attempted to send message %s to null path in send_proc", msg ? msg : "");
goto out;
@ -763,6 +758,16 @@ out:
LOGERR("Failure in send_proc from %s %s:%d", file, func, line);
}
/* As per send_proc_data but must be a string */
void _send_proc(proc_instance_t *pi, const char *msg, const char *file, const char *func, const int line)
{
if (unlikely(!msg || !strlen(msg))) {
LOGERR("Attempted to send null message to %s in send_proc", pi->processname);
return;
}
return _send_proc_data(pi, msg, file, func, line);
}
/* Send a single message to a process instance and retrieve the response, then
* close the socket. */
char *_send_recv_proc(proc_instance_t *pi, const char *msg, int writetimeout, int readtimedout,

2
src/ckpool.h

@ -326,6 +326,8 @@ void empty_buffer(connsock_t *cs);
int set_sendbufsize(ckpool_t *ckp, const int fd, const int len);
int set_recvbufsize(ckpool_t *ckp, const int fd, const int len);
int read_socket_line(connsock_t *cs, float *timeout);
void _send_proc_data(proc_instance_t *pi, const char *msg, const char *file, const char *func, const int line);
#define send_proc_data(pi, msg) _send_proc_data(pi, msg, __FILE__, __func__, __LINE__)
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, const char *msg, int writetimeout, int readtimedout,

Loading…
Cancel
Save