kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 60a3f60a92f53113d58d6509fc442df2c089a894
parent 0fe570ef4125755526135625ffd4f8f58aa70d64
Author: Joris Vink <joris@coders.se>
Date:   Mon, 27 Feb 2017 21:27:50 -0800

Allow MSG framework to pass 0 byte messages.

Diffstat:
src/msg.c | 17+++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/msg.c b/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) {