- if(listen(nfd, 3)) {
- closesocket(nfd);
- logger(LOG_ERR, _("System call `%s' failed: %s"), "listen",
- strerror(errno));
- return -1;
+ 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;