mirror of https://github.com/yandex/odyssey.git
odissey: limit stream fill by readahead size
This commit is contained in:
parent
15761a1186
commit
c810d77591
|
@ -427,8 +427,15 @@ od_frontend_setup(od_client_t *client)
|
||||||
return OD_FE_OK;
|
return OD_FE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
od_frontend_stream_hit_limit(od_client_t *client)
|
||||||
|
{
|
||||||
|
od_instance_t *instance = client->system->instance;
|
||||||
|
return shapito_stream_used(&client->stream) >= instance->scheme.readahead;
|
||||||
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
od_frontend_reset_stream(od_client_t *client)
|
od_frontend_stream_reset(od_client_t *client)
|
||||||
{
|
{
|
||||||
od_instance_t *instance = client->system->instance;
|
od_instance_t *instance = client->system->instance;
|
||||||
shapito_stream_t *stream = &client->stream;
|
shapito_stream_t *stream = &client->stream;
|
||||||
|
@ -506,7 +513,7 @@ od_frontend_remote_client(od_client_t *client)
|
||||||
int request_count = 0;
|
int request_count = 0;
|
||||||
int terminate = 0;
|
int terminate = 0;
|
||||||
|
|
||||||
od_frontend_reset_stream(client);
|
od_frontend_stream_reset(client);
|
||||||
int rc;
|
int rc;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
@ -571,6 +578,10 @@ od_frontend_remote_client(od_client_t *client)
|
||||||
request_count++;
|
request_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rc = od_frontend_stream_hit_limit(client);
|
||||||
|
if (rc)
|
||||||
|
break;
|
||||||
|
|
||||||
rc = machine_read_pending(client->io);
|
rc = machine_read_pending(client->io);
|
||||||
if (rc < 0 || rc > 0)
|
if (rc < 0 || rc > 0)
|
||||||
continue;
|
continue;
|
||||||
|
@ -605,7 +616,7 @@ od_frontend_remote_server(od_client_t *client)
|
||||||
shapito_stream_t *stream = &client->stream;
|
shapito_stream_t *stream = &client->stream;
|
||||||
od_server_t *server = client->server;
|
od_server_t *server = client->server;
|
||||||
|
|
||||||
od_frontend_reset_stream(client);
|
od_frontend_stream_reset(client);
|
||||||
int rc;
|
int rc;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
@ -692,6 +703,10 @@ od_frontend_remote_server(od_client_t *client)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rc = od_frontend_stream_hit_limit(client);
|
||||||
|
if (rc)
|
||||||
|
break;
|
||||||
|
|
||||||
rc = machine_read_pending(server->io);
|
rc = machine_read_pending(server->io);
|
||||||
if (rc < 0 || rc > 0)
|
if (rc < 0 || rc > 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue