feat: dissociate timeouts and empty pastes
feuille was handling those two errors the same way, by sending `Timeout'd.' even if the client just sent an EOF.
This commit is contained in:
parent
6a20fa7e61
commit
24da772e56
2 changed files with 10 additions and 2 deletions
7
server.c
7
server.c
|
|
@ -188,6 +188,7 @@ char *read_paste(int connection)
|
|||
|
||||
/* read all data until EOF is received, or max file size is reached, or the socket timeouts... */
|
||||
/* each time, the data is appended to the buffer, once it's been reallocated a larger size */
|
||||
errno = 0;
|
||||
long size;
|
||||
while ((size = recv(connection, buffer + total_size, buffer_size - total_size, 0)) > 0) {
|
||||
total_size += size;
|
||||
|
|
@ -216,11 +217,15 @@ char *read_paste(int connection)
|
|||
}
|
||||
}
|
||||
|
||||
printf("%d\n", errno);
|
||||
|
||||
/* is the buffer empty? */
|
||||
if (total_size == 0) {
|
||||
/* yup, free the buffer and return an error */
|
||||
if (errno != EAGAIN)
|
||||
errno = ENOENT;
|
||||
|
||||
free(buffer);
|
||||
errno = ENOENT;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in a new issue