From: Alan T. DeKok Date: Wed, 7 Jun 2017 12:34:18 +0000 (-0400) Subject: return fr_network_t when adding a socket to a scheduler X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d77e3baec5fada8b30aa4ca34d845d27ca80fe70;p=thirdparty%2Ffreeradius-server.git return fr_network_t when adding a socket to a scheduler so that the caller can push other things for that socket to the network thread. --- diff --git a/src/lib/io/schedule.c b/src/lib/io/schedule.c index 76fafdaa4cd..6ba5a763169 100644 --- a/src/lib/io/schedule.c +++ b/src/lib/io/schedule.c @@ -29,8 +29,6 @@ RCSID("$Id$") #include #include -#include - #ifdef HAVE_PTHREAD_H #include #define PTHREAD_MUTEX_LOCK pthread_mutex_lock @@ -634,10 +632,17 @@ int fr_schedule_destroy(fr_schedule_t *sc) * @param fd the file descriptor for the socket * @param ctx the context for the transport * @param transport the transport + * @return + * - NULL on error + * - the fr_network_t that the socket was added to. */ -int fr_schedule_socket_add(fr_schedule_t *sc, int fd, void *ctx, fr_io_op_t *transport) +fr_network_t *fr_schedule_socket_add(fr_schedule_t *sc, int fd, void *ctx, fr_io_op_t *transport) { - return fr_network_socket_add(sc->sn->rc, fd, ctx, transport); + if (fr_network_socket_add(sc->sn->rc, fd, ctx, transport) < 0) { + return NULL; + } + + return sc->sn->rc; } diff --git a/src/lib/io/schedule.h b/src/lib/io/schedule.h index d33fe9091ee..ace2d1dd46a 100644 --- a/src/lib/io/schedule.h +++ b/src/lib/io/schedule.h @@ -26,6 +26,7 @@ RCSIDH(schedule_h, "$Id$") #include +#include #include #ifdef __cplusplus @@ -42,7 +43,7 @@ fr_schedule_t *fr_schedule_create(TALLOC_CTX *ctx, fr_log_t *log, int max_inputs int fr_schedule_destroy(fr_schedule_t *sc); int fr_schedule_get_worker_kq(fr_schedule_t *sc); -int fr_schedule_socket_add(fr_schedule_t *sc, int fd, void *ctx, fr_io_op_t *transport) CC_HINT(nonnull); +fr_network_t *fr_schedule_socket_add(fr_schedule_t *sc, int fd, void *ctx, fr_io_op_t *transport) CC_HINT(nonnull); #ifdef __cplusplus } diff --git a/src/modules/proto_radius/proto_radius.c b/src/modules/proto_radius/proto_radius.c index cb6895eee41..ad4663c0226 100644 --- a/src/modules/proto_radius/proto_radius.c +++ b/src/modules/proto_radius/proto_radius.c @@ -251,7 +251,7 @@ static int open_transport(proto_radius_ctx_t *ctx, UNUSED fr_schedule_t *handle, * * @todo - more cleanup on error. */ - if (fr_schedule_socket_add(handle, ctx->sockfd, ctx, &ctx->transport) < 0) { + if (!fr_schedule_socket_add(handle, ctx->sockfd, ctx, &ctx->transport)) { talloc_free(ctx); return -1; }