mirror of https://github.com/yandex/odyssey.git
odissey: implicitly reset stream before read
This commit is contained in:
parent
4b88900203
commit
8207824ef4
|
@ -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",
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
12
core/od_io.c
12
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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue