Allow MSG framework to pass 0 byte messages.

This commit is contained in:
Joris Vink 2017-02-27 21:27:50 -08:00
parent 0fe570ef41
commit 60a3f60a92
1 changed files with 13 additions and 4 deletions

View File

@ -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) {