X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fmeta.c;h=a3f7ef3cfa1f38c7fae38badbfcc11f28eb641a9;hb=a22041922f160667573e9a5ae3f4195e1668906a;hp=787ccbd0ff17426b709dc8683e08e3a358d6cf12;hpb=7ea85043ac1fb2096baea44f6b0af27ac0d0b2cf;p=tinc diff --git a/src/meta.c b/src/meta.c index 787ccbd0..a3f7ef3c 100644 --- a/src/meta.c +++ b/src/meta.c @@ -76,7 +76,7 @@ void broadcast_meta(connection_t *from, const char *buffer, int length) { } bool receive_meta(connection_t *c) { - size_t inlen; + int inlen; char inbuf[MAXBUFSIZE]; char *bufp = inbuf, *endp; @@ -92,7 +92,14 @@ bool receive_meta(connection_t *c) { inlen = recv(c->socket, inbuf, sizeof inbuf, 0); if(inlen <= 0) { - logger(LOG_ERR, "Receive callback called for %s (%s) but no data to receive: %s", c->name, c->hostname, strerror(errno)); + if(!inlen || !errno) { + ifdebug(CONNECTIONS) logger(LOG_NOTICE, "Connection closed by %s (%s)", + c->name, c->hostname); + } else if(sockwouldblock(sockerrno)) + return true; + else + logger(LOG_ERR, "Metadata socket read error for %s (%s): %s", + c->name, c->hostname, sockstrerror(sockerrno)); return false; } @@ -110,7 +117,7 @@ bool receive_meta(connection_t *c) { bufp = endp; } else { size_t outlen = inlen; - ifdebug(META) logger(LOG_DEBUG, "Received encrypted %zu bytes", inlen); + ifdebug(META) logger(LOG_DEBUG, "Received encrypted %d bytes", inlen); evbuffer_expand(c->buffer->input, c->buffer->input->off + inlen); if(!cipher_decrypt(&c->incipher, bufp, inlen, c->buffer->input->buffer + c->buffer->input->off, &outlen, false) || inlen != outlen) { @@ -152,7 +159,5 @@ bool receive_meta(connection_t *c) { } } while(inlen); - c->last_ping_time = time(NULL); - return true; }