client: handle partial lines correctly
Commit 6eb62e47 didn't obey partial lines correctly: when a line wasn't finished in one read, the first part was ignored when the rest arrived.
This commit is contained in:
parent
ae6ca0b8af
commit
79459d08d9
@ -445,12 +445,12 @@ static int client_process_line(struct client *client, char *line)
|
|||||||
|
|
||||||
static int client_input_received(struct client *client, int bytesRead)
|
static int client_input_received(struct client *client, int bytesRead)
|
||||||
{
|
{
|
||||||
char *start = client->buffer + client->bufferLength;
|
char *start = client->buffer + client->bufferPos, *end;
|
||||||
char *end = start + bytesRead;
|
|
||||||
char *newline, *next;
|
char *newline, *next;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
client->bufferLength += bytesRead;
|
client->bufferLength += bytesRead;
|
||||||
|
end = client->buffer + client->bufferLength;
|
||||||
|
|
||||||
/* process all lines */
|
/* process all lines */
|
||||||
while ((newline = memchr(start, '\n', end - start)) != NULL) {
|
while ((newline = memchr(start, '\n', end - start)) != NULL) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user