+static void handle_meta_write(meshlink_handle_t *mesh, connection_t *c) {
+ if(c->outbuf.len <= c->outbuf.offset) {
+ return;
+ }
+
+ ssize_t outlen = send(c->socket, c->outbuf.data + c->outbuf.offset, c->outbuf.len - c->outbuf.offset, MSG_NOSIGNAL);
+
+ if(outlen <= 0) {
+ if(!errno || errno == EPIPE) {
+ logger(mesh, MESHLINK_INFO, "Connection closed by %s", c->name);
+ } else if(sockwouldblock(sockerrno)) {
+ logger(mesh, MESHLINK_DEBUG, "Sending %lu bytes to %s would block", (unsigned long)(c->outbuf.len - c->outbuf.offset), c->name);
+ return;
+ } else {
+ logger(mesh, MESHLINK_ERROR, "Could not send %lu bytes of data to %s: %s", (unsigned long)(c->outbuf.len - c->outbuf.offset), c->name, strerror(errno));
+ }
+
+ terminate_connection(mesh, c, c->status.active);
+ return;
+ }
+
+ buffer_read(&c->outbuf, outlen);
+
+ if(!c->outbuf.len) {
+ io_set(&mesh->loop, &c->io, IO_READ);
+ }