diff --git a/core/od_auth.c b/core/od_auth.c index 9634c2a1..89f86277 100644 --- a/core/od_auth.c +++ b/core/od_auth.c @@ -58,6 +58,7 @@ od_authfe_cleartext(od_client_t *client) /* wait for password response */ while (1) { + so_stream_reset(stream); rc = od_read(client->io, stream, INT_MAX); if (rc == -1) { od_error(&pooler->od->log, client->io, "C (auth): read error: %s", @@ -126,6 +127,7 @@ od_authfe_md5(od_client_t *client) /* wait for password response */ while (1) { int rc; + so_stream_reset(stream); rc = od_read(client->io, stream, INT_MAX); if (rc == -1) { od_error(&pooler->od->log, client->io, "C (auth): read error: %s", @@ -380,6 +382,7 @@ int od_authbe(od_server_t *server) /* wait for authentication response */ while (1) { int rc; + so_stream_reset(stream); rc = od_read(server->io, &server->stream, INT_MAX); if (rc == -1) { od_error(&pooler->od->log, server->io, "S (auth): read error: %s", diff --git a/core/od_be.c b/core/od_be.c index cf6f3bf3..251a4277 100644 --- a/core/od_be.c +++ b/core/od_be.c @@ -106,10 +106,11 @@ od_besetup(od_server_t *server) od_pooler_t *pooler = server->pooler; so_stream_t *stream = &server->stream; while (1) { + so_stream_reset(stream); int rc; rc = od_read(server->io, &server->stream, INT_MAX); if (rc == -1) { - od_error(&pooler->od->log, server->io, "S (setup): write error: %s", + od_error(&pooler->od->log, server->io, "S (setup): read error: %s", machine_error(server->io)); return -1; } @@ -366,13 +367,13 @@ od_beready_wait(od_server_t *server, char *procedure, int time_ms) { od_pooler_t *pooler = server->pooler; so_stream_t *stream = &server->stream; - so_stream_reset(stream); /* wait for response */ while (1) { + so_stream_reset(stream); int rc; rc = od_read(server->io, stream, time_ms); if (rc == -1) { - od_error(&pooler->od->log, server->io, "S (%s): write error: %s", + od_error(&pooler->od->log, server->io, "S (%s): read error: %s", procedure, machine_error(server->io)); return -1; } diff --git a/core/od_io.c b/core/od_io.c index 2794d157..9a0d0eef 100644 --- a/core/od_io.c +++ b/core/od_io.c @@ -25,13 +25,14 @@ int od_read(machine_io_t io, so_stream_t *stream, int time_ms) { - so_stream_reset(stream); - for (;;) { - uint32_t pos_size = so_stream_used(stream); - uint8_t *pos_data = stream->s; + uint32_t request_start = so_stream_used(stream); + uint32_t request_size = 0; + for (;;) + { + uint8_t *request_data = stream->s + request_start; uint32_t len; int to_read; - to_read = so_read(&len, &pos_data, &pos_size); + to_read = so_read(&len, &request_data, &request_size); if (to_read == 0) break; if (to_read == -1) @@ -43,6 +44,7 @@ int od_read(machine_io_t io, so_stream_t *stream, int time_ms) if (rc < 0) return -1; so_stream_advance(stream, to_read); + request_size += to_read; } return 0; } diff --git a/core/od_router_copy.c b/core/od_router_copy.c index 25e598dd..97a52f4e 100644 --- a/core/od_router_copy.c +++ b/core/od_router_copy.c @@ -54,6 +54,7 @@ od_router_copy_in(od_client_t *client) int rc, type; so_stream_t *stream = &client->stream; for (;;) { + so_stream_reset(stream); rc = od_read(client->io, stream, INT_MAX); if (rc == -1) return OD_RS_ECLIENT_READ; diff --git a/core/od_router_session.c b/core/od_router_session.c index 0bd1ebfd..f70530c5 100644 --- a/core/od_router_session.c +++ b/core/od_router_session.c @@ -90,6 +90,7 @@ od_router_session(od_client_t *client) for (;;) { /* client to server */ + so_stream_reset(stream); rc = od_read(client->io, stream, INT_MAX); if (rc == -1) return OD_RS_ECLIENT_READ; @@ -109,6 +110,7 @@ od_router_session(od_client_t *client) for (;;) { /* read server reply */ for (;;) { + so_stream_reset(stream); rc = od_read(server->io, stream, 1000); if (rc == 0) break; diff --git a/core/od_router_transaction.c b/core/od_router_transaction.c index e2719563..63ed7663 100644 --- a/core/od_router_transaction.c +++ b/core/od_router_transaction.c @@ -78,6 +78,7 @@ od_router_transaction(od_client_t *client) for (;;) { /* client to server */ + so_stream_reset(stream); rc = od_read(client->io, stream, INT_MAX); if (rc == -1) return OD_RS_ECLIENT_READ; @@ -113,6 +114,7 @@ od_router_transaction(od_client_t *client) for (;;) { /* read server reply */ for (;;) { + so_stream_reset(stream); rc = od_read(server->io, stream, 1000); if (rc == 0) break;