odissey: add od_write(); switch to it

This commit is contained in:
Dmitry Simonenko 2016-11-14 13:24:37 +03:00
parent a8f6aa4dc5
commit 19e98f757c
5 changed files with 22 additions and 23 deletions

View File

@ -58,8 +58,7 @@ od_bestartup(odserver_t *server)
rc = so_fewrite_startup_message(stream, 4, argv);
if (rc == -1)
return -1;
rc = ft_write(server->io, (char*)stream->s,
so_stream_used(stream), 0);
rc = od_write(server->io, stream);
return rc;
}

View File

@ -28,6 +28,7 @@
#include "od_client.h"
#include "od_client_pool.h"
#include "od.h"
#include "od_io.h"
#include "od_pooler.h"
#include "od_fe.h"
@ -60,11 +61,8 @@ int od_feerror(odclient_t *client, char *fmt, ...)
rc = so_bewrite_error(stream, message, len);
if (rc == -1)
return -1;
rc = ft_write(client->io, (char*)stream->s,
so_stream_used(stream), 0);
if (rc < 0)
return -1;
return 0;
rc = od_write(client->io, stream);
return rc;
}
static int
@ -123,11 +121,8 @@ int od_feauth(odclient_t *client)
rc = so_bewrite_parameter_status(stream, "", 1, "", 1);
if (rc == -1)
return -1;
rc = ft_write(client->io, (char*)stream->s,
so_stream_used(stream), 0);
if (rc < 0)
return -1;
return 0;
rc = od_write(client->io, stream);
return rc;
}
int od_feready(odclient_t *client)
@ -138,9 +133,6 @@ int od_feready(odclient_t *client)
rc = so_bewrite_ready(stream, 'I');
if (rc == -1)
return -1;
rc = ft_write(client->io, (char*)stream->s,
so_stream_used(stream), 0);
if (rc < 0)
return -1;
return 0;
rc = od_write(client->io, stream);
return rc;
}

View File

@ -42,3 +42,12 @@ int od_read(ftio_t *io, sostream_t *stream)
}
return 0;
}
int od_write(ftio_t *io, sostream_t *stream)
{
int rc;
rc = ft_write(io, (char*)stream->s, so_stream_used(stream), 0);
if (rc < 0)
return -1;
return 0;
}

View File

@ -8,5 +8,6 @@
*/
int od_read(ftio_t*, sostream_t*);
int od_write(ftio_t*, sostream_t*);
#endif

View File

@ -149,9 +149,8 @@ void od_router(void *arg)
break;
}
/* write request to server */
rc = ft_write(server->io, (char*)stream->s,
so_stream_used(stream), 0);
if (rc < 0) {
rc = od_write(server->io, stream);
if (rc == -1) {
}
while (1) {
@ -164,9 +163,8 @@ void od_router(void *arg)
od_log(&pooler->od->log, "S: %c", type);
/* write response to client */
rc = ft_write(client->io, (char*)stream->s,
so_stream_used(stream), 0);
if (rc < 0) {
rc = od_write(client->io, stream);
if (rc == -1) {
}
if (type == 'Z')