Skip to content

Commit fb06db6

Browse files
committed
improve http read logging
1 parent 267d429 commit fb06db6

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

src/core/http.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,23 @@ state_action http_read_handle(scache_connection* connection) {
5252
//Read from socket
5353
num = rbuf_write_to_end(&connection->input);
5454
if (num > 0) {
55-
DEBUG("[#%d] reading %d bytes from socket (write pos: %d, read pos: %d)\n", fd, num, connection->input.write_position, connection->input.read_position);
5655
num = read(fd, RBUF_WRITE(connection->input), num);
57-
5856
if (num == 0) {
5957
return close_connection;
6058
}
6159
if (num < 0) {
62-
if (errno != EAGAIN && errno != EWOULDBLOCK) {
63-
DEBUG("A socket error occured while reading: %d", num);
60+
num = errno;
61+
if (num != EAGAIN && num != EWOULDBLOCK) {
62+
DEBUG("[#%d] A socket error occured while reading: %d\n", fd, num);
6463
return close_connection;
6564
}
66-
else{
67-
return needs_more;
68-
}
65+
66+
DEBUG("[#%d] Needs more bytes, got errno %d\n", fd, num);
67+
return needs_more;
6968
}
69+
70+
DEBUG("[#%d] Reading %d bytes from socket (write pos: %d, read pos: %d)\n", fd, num, connection->input.write_position, connection->input.read_position);
71+
7072

7173
RBUF_WRITEMOVE(connection->input, (uint16_t)num);
7274
}

0 commit comments

Comments
 (0)