From: Arran Cudbard-Bell Date: Thu, 15 Jun 2017 15:43:05 +0000 (-0400) Subject: Connection API fixes X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7bcbe6be6737b97dbb7c2eadd0f6af68fc63d883;p=thirdparty%2Ffreeradius-server.git Connection API fixes --- diff --git a/src/include/connection.h b/src/include/connection.h index aeebe256d0c..a85cddbbcfa 100644 --- a/src/include/connection.h +++ b/src/include/connection.h @@ -77,11 +77,12 @@ typedef fr_connection_state_t (*fr_connection_open_t)(int fd, fr_event_list_t *e typedef void (*fr_connection_close_t)(int fd, void *uctx); -fr_connection_t const *fr_connection_alloc(TALLOC_CTX *ctx, fr_event_list_t *el, +fr_connection_t *fr_connection_alloc(TALLOC_CTX *ctx, fr_event_list_t *el, struct timeval *open_time, struct timeval *wait_time, fr_connection_init_t init, fr_connection_open_t open, fr_connection_close_t close, char const *log_prefix, void *uctx); +void fr_connection_start(fr_connection_t *conn); int fr_connection_get_fd(fr_connection_t const *conn); void fr_connection_reconnect(fr_connection_t *conn); diff --git a/src/main/connection.c b/src/main/connection.c index faa44ffbf73..5d44894f8ea 100644 --- a/src/main/connection.c +++ b/src/main/connection.c @@ -322,13 +322,13 @@ static int _connection_free(fr_connection_t *conn) * - A new #fr_connection_t on success. * - NULL on failure. */ -fr_connection_t const *fr_connection_alloc(TALLOC_CTX *ctx, fr_event_list_t *el, - struct timeval *connection_timeout, struct timeval *reconnection_delay, - fr_connection_init_t init, fr_connection_open_t open, fr_connection_close_t close, - char const *log_prefix, - void *uctx) +fr_connection_t *fr_connection_alloc(TALLOC_CTX *ctx, fr_event_list_t *el, + struct timeval *connection_timeout, struct timeval *reconnection_delay, + fr_connection_init_t init, fr_connection_open_t open, fr_connection_close_t close, + char const *log_prefix, + void *uctx) { - struct timeval now; + fr_connection_t *conn; rad_assert(el); @@ -349,11 +349,16 @@ fr_connection_t const *fr_connection_alloc(TALLOC_CTX *ctx, fr_event_list_t *el, conn->log_prefix = talloc_typed_strdup(conn, log_prefix); conn->uctx = uctx; + return conn; +} + +void fr_connection_start(fr_connection_t *conn) +{ + struct timeval now; + gettimeofday(&now, NULL); connection_state_init(conn, &now); - - return conn; } /** Asynchronously signal the connection should be reconnected