mirror of https://git.kore.io/kore.git
Allow MSG framework to pass 0 byte messages.
This commit is contained in:
parent
0fe570ef41
commit
60a3f60a92
17
src/msg.c
17
src/msg.c
|
@ -142,7 +142,9 @@ kore_msg_send(u_int16_t dst, u_int8_t id, const void *data, u_int32_t len)
|
|||
m.src = worker->id;
|
||||
|
||||
net_send_queue(worker->msg[1], &m, sizeof(m));
|
||||
net_send_queue(worker->msg[1], data, len);
|
||||
if (data != NULL && len > 0)
|
||||
net_send_queue(worker->msg[1], data, len);
|
||||
|
||||
net_send_flush(worker->msg[1]);
|
||||
}
|
||||
|
||||
|
@ -151,8 +153,12 @@ msg_recv_packet(struct netbuf *nb)
|
|||
{
|
||||
struct kore_msg *msg = (struct kore_msg *)nb->buf;
|
||||
|
||||
net_recv_expand(nb->owner, msg->length, msg_recv_data);
|
||||
return (KORE_RESULT_OK);
|
||||
if (msg->length > 0) {
|
||||
net_recv_expand(nb->owner, msg->length, msg_recv_data);
|
||||
return (KORE_RESULT_OK);
|
||||
}
|
||||
|
||||
return (msg_recv_data(nb));
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -169,7 +175,10 @@ msg_recv_data(struct netbuf *nb)
|
|||
if (worker != NULL && msg->dst != worker->id)
|
||||
fatal("received message for incorrect worker");
|
||||
|
||||
type->cb(msg, nb->buf + sizeof(*msg));
|
||||
if (msg->length > 0)
|
||||
type->cb(msg, nb->buf + sizeof(*msg));
|
||||
else
|
||||
type->cb(msg, NULL);
|
||||
}
|
||||
|
||||
if (worker == NULL && type == NULL) {
|
||||
|
|
Loading…
Reference in New Issue