From 46ef967244d11a2e1dc9c0c61f5d1e2caf08b51a Mon Sep 17 00:00:00 2001 From: Saverio Proto Date: Sun, 1 Jun 2014 17:04:26 +0200 Subject: [PATCH] Register the signal passing proper data --- src/meshlink.c | 8 +++++++- src/meshlink.h | 2 +- src/net.c | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/meshlink.c b/src/meshlink.c index 122afa58..37901179 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -862,9 +862,15 @@ bool meshlink_send(meshlink_handle_t *mesh, meshlink_node_t *destination, const signal_trigger(&(mesh->loop),&(mesh->datafromapp)); } -bool meshlink_send_from_queue (meshlink_handle_t *mesh,outpacketqueue_t* p) { +bool meshlink_send_from_queue(meshlink_handle_t *mesh) { vpn_packet_t packet; meshlink_packethdr_t *hdr = (meshlink_packethdr_t *)packet.data; + + outpacketqueue_t* p = list_get_tail(mesh->outpacketqueue); + if (p) + list_delete_tail(mesh->outpacketqueue); + else return false; + if (sizeof(meshlink_packethdr_t) + p->len > MAXSIZE) { //log something return false; diff --git a/src/meshlink.h b/src/meshlink.h index 342657db..076c7ac7 100644 --- a/src/meshlink.h +++ b/src/meshlink.h @@ -196,7 +196,7 @@ extern void meshlink_set_log_cb(meshlink_handle_t *mesh, meshlink_log_level_t le */ extern bool meshlink_send(meshlink_handle_t *mesh, meshlink_node_t *destination, const void *data, unsigned int len); -extern bool meshlink_send_from_queue (meshlink_handle_t *mesh,outpacketqueue_t* p); +extern bool meshlink_send_from_queue (meshlink_handle_t *mesh); /// Get a handle for a specific node. /** This function returns a handle for the node with the given name. diff --git a/src/net.c b/src/net.c index 2c24f10c..39bd2dc4 100644 --- a/src/net.c +++ b/src/net.c @@ -271,7 +271,7 @@ int main_loop(meshlink_handle_t *mesh) { //Add signal handler mesh->datafromapp.signum = 0; - signal_add(&(mesh->loop),&(mesh->datafromapp), meshlink_send_from_queue,NULL, mesh->datafromapp.signum); + signal_add(&(mesh->loop),&(mesh->datafromapp), meshlink_send_from_queue,mesh, mesh->datafromapp.signum); if(!event_loop_run(&mesh->loop)) { logger(DEBUG_ALWAYS, LOG_ERR, "Error while waiting for input: %s", strerror(errno)); -- 2.39.5