});
if(sig) {
+ sig->set = false;
sig->cb(loop, sig->data);
}
}
}
void signal_trigger(event_loop_t *loop, signal_t *sig) {
+ if(sig->set) {
+ return;
+ }
+
uint8_t signum = sig->signum;
+ sig->set = true;
write(loop->pipefd[1], &signum, 1);
return;
}
sig->cb = cb;
sig->data = data;
sig->signum = signum;
+ sig->set = false;
sig->node.data = sig;
if(loop->pipefd[0] == -1) {
return false;
}
+ logger(mesh, MESHLINK_DEBUG, "Adding packet of %zu bytes to packet queue", len);
+
// Notify event loop
signal_trigger(&mesh->loop, &mesh->datafromapp);
void meshlink_send_from_queue(event_loop_t *loop, void *data) {
(void)loop;
meshlink_handle_t *mesh = data;
- vpn_packet_t *packet = meshlink_queue_pop(&mesh->outpacketqueue);
-
- if(!packet) {
- return;
- }
- mesh->self->in_packets++;
- mesh->self->in_bytes += packet->len;
- route(mesh, mesh->self, packet);
+ logger(mesh, MESHLINK_DEBUG, "Flushing the packet queue");
- free(packet);
+ for(vpn_packet_t *packet; (packet = meshlink_queue_pop(&mesh->outpacketqueue));) {
+ logger(mesh, MESHLINK_DEBUG, "Removing packet of %d bytes from packet queue", packet->len);
+ mesh->self->in_packets++;
+ mesh->self->in_bytes += packet->len;
+ route(mesh, mesh->self, packet);
+ free(packet);
+ }
}
ssize_t meshlink_get_pmtu(meshlink_handle_t *mesh, meshlink_node_t *destination) {