mirror of https://github.com/yandex/odyssey.git
odissey: implement first vital C-P-S-P-C interaction
This commit is contained in:
parent
eb19ed9f76
commit
9079d68ba7
|
@ -57,7 +57,9 @@ int od_feerror(odclient_t *client, char *fmt, ...)
|
|||
return -1;
|
||||
rc = ft_write(client->io, (char*)stream->s,
|
||||
so_stream_used(stream), 0);
|
||||
return rc;
|
||||
if (rc < 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -121,5 +123,7 @@ int od_feauth(odclient_t *client)
|
|||
return -1;
|
||||
rc = ft_write(client->io, (char*)stream->s,
|
||||
so_stream_used(stream), 0);
|
||||
return rc;
|
||||
if (rc < 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -126,20 +126,46 @@ void od_router(void *arg)
|
|||
/* link server with client */
|
||||
client->server = server;
|
||||
|
||||
sostream_t *stream = &client->stream;
|
||||
char type;
|
||||
while (1) {
|
||||
rc = od_read(client->io, &client->stream);
|
||||
/* read client request */
|
||||
rc = od_read(client->io, stream);
|
||||
if (rc == -1) {
|
||||
od_feclose(client);
|
||||
return;
|
||||
}
|
||||
char type = *client->stream.s;
|
||||
type = *client->stream.s;
|
||||
od_log(&pooler->od->log, "C: %c", type);
|
||||
|
||||
/* write(server, packet) */
|
||||
if (type == 'X') {
|
||||
/* client graceful shutdown */
|
||||
od_feclose(client);
|
||||
break;
|
||||
}
|
||||
/* write request to server */
|
||||
rc = ft_write(server->io, (char*)stream->s,
|
||||
so_stream_used(stream), 0);
|
||||
if (rc < 0) {
|
||||
}
|
||||
|
||||
while (1) {
|
||||
/* packet = read(server) */
|
||||
/* write(client, packet) */
|
||||
/* if Z break */
|
||||
/* read responce from server */
|
||||
rc = od_read(server->io, stream);
|
||||
if (rc == -1) {
|
||||
}
|
||||
|
||||
type = *stream->s;
|
||||
od_log(&pooler->od->log, "S: %c", type);
|
||||
|
||||
/* write responce to client */
|
||||
rc = ft_write(client->io, (char*)stream->s,
|
||||
so_stream_used(stream), 0);
|
||||
if (rc < 0) {
|
||||
}
|
||||
|
||||
if (type == 'Z')
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue