Compact input buffer before trying to read instead of after.
Also log an error when the input buffer contains more than MAXBUFSIZE bytes already, instead of silently claiming the other side closed the connection.
This commit is contained in:
parent
8de8f1d9e2
commit
90c7fafe59
1 changed files with 7 additions and 2 deletions
|
@ -85,6 +85,13 @@ bool receive_meta(connection_t *c) {
|
|||
- If not, keep stuff in buffer and exit.
|
||||
*/
|
||||
|
||||
buffer_compact(&c->inbuf);
|
||||
|
||||
if(sizeof inbuf <= c->inbuf.len) {
|
||||
logger(LOG_ERR, "Input buffer full for %s (%s)\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
inlen = recv(c->socket, inbuf, sizeof inbuf - c->inbuf.len, 0);
|
||||
|
||||
if(inlen <= 0) {
|
||||
|
@ -151,7 +158,5 @@ bool receive_meta(connection_t *c) {
|
|||
}
|
||||
} while(inlen);
|
||||
|
||||
buffer_compact(&c->inbuf);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue