|
|
@ -150,6 +150,7 @@ int read_socket_line(connsock_t *cs, int timeout) |
|
|
|
|
|
|
|
|
|
|
|
while (42) { |
|
|
|
while (42) { |
|
|
|
char readbuf[PAGESIZE] = {}; |
|
|
|
char readbuf[PAGESIZE] = {}; |
|
|
|
|
|
|
|
char *ptr; |
|
|
|
|
|
|
|
|
|
|
|
FD_ZERO(&rd); |
|
|
|
FD_ZERO(&rd); |
|
|
|
FD_SET(cs->fd, &rd); |
|
|
|
FD_SET(cs->fd, &rd); |
|
|
@ -173,9 +174,10 @@ int read_socket_line(connsock_t *cs, int timeout) |
|
|
|
} |
|
|
|
} |
|
|
|
buflen = cs->bufofs + ret + 1; |
|
|
|
buflen = cs->bufofs + ret + 1; |
|
|
|
align_len(&buflen); |
|
|
|
align_len(&buflen); |
|
|
|
cs->buf = realloc(cs->buf, buflen); |
|
|
|
ptr = realloc(cs->buf, buflen); |
|
|
|
if (unlikely(!cs->buf)) |
|
|
|
if (unlikely(!ptr)) |
|
|
|
quit(1, "Failed to alloc buf of %d bytes in read_socket_line", (int)buflen); |
|
|
|
quit(1, "Failed to alloc buf of %d bytes in read_socket_line", (int)buflen); |
|
|
|
|
|
|
|
cs->buf = ptr; |
|
|
|
memcpy(cs->buf + cs->bufofs, readbuf, ret); |
|
|
|
memcpy(cs->buf + cs->bufofs, readbuf, ret); |
|
|
|
eom = strchr(cs->buf, '\n'); |
|
|
|
eom = strchr(cs->buf, '\n'); |
|
|
|
cs->bufofs += ret; |
|
|
|
cs->bufofs += ret; |
|
|
|