diff --git a/core/od_be.c b/core/od_be.c index 18cf7b07..613f911a 100644 --- a/core/od_be.c +++ b/core/od_be.c @@ -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; } diff --git a/core/od_fe.c b/core/od_fe.c index bb1f54e3..474c89f9 100644 --- a/core/od_fe.c +++ b/core/od_fe.c @@ -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; } diff --git a/core/od_io.c b/core/od_io.c index 9d36c63f..1808a987 100644 --- a/core/od_io.c +++ b/core/od_io.c @@ -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; +} diff --git a/core/od_io.h b/core/od_io.h index e9f49cee..4b5fdbaf 100644 --- a/core/od_io.h +++ b/core/od_io.h @@ -8,5 +8,6 @@ */ int od_read(ftio_t*, sostream_t*); +int od_write(ftio_t*, sostream_t*); #endif diff --git a/core/od_router.c b/core/od_router.c index 09106d3d..6815a8b2 100644 --- a/core/od_router.c +++ b/core/od_router.c @@ -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')