From b495a407f934e80f8848ee7d827055886243e849 Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Thu, 10 May 2018 08:33:19 +0000 Subject: [PATCH] Feature: Added listensocket_container_configure_and_setup() that combines configure and setup into one call --- src/listensocket.c | 23 +++++++++++++++++++++++ src/listensocket.h | 1 + 2 files changed, 24 insertions(+) diff --git a/src/listensocket.c b/src/listensocket.c index 8a93675d..90670ca0 100644 --- a/src/listensocket.c +++ b/src/listensocket.c @@ -186,6 +186,29 @@ int listensocket_container_configure(listensocket_contai return 0; } +int listensocket_container_configure_and_setup(listensocket_container_t *self, const ice_config_t *config) +{ + void (*cb)(size_t count, void *userdata); + int ret; + + if (!self) + return -1; + + cb = self->sockcount_cb; + self->sockcount_cb = NULL; + + if (listensocket_container_configure(self, config) == 0) { + ret = listensocket_container_setup(self); + } else { + ret = -1; + } + + self->sockcount_cb = cb; + __call_sockcount_cb(self); + + return ret; +} + int listensocket_container_setup(listensocket_container_t *self) { size_t i; int ret = 0; diff --git a/src/listensocket.h b/src/listensocket.h index 6c4576c0..b3a03e6a 100644 --- a/src/listensocket.h +++ b/src/listensocket.h @@ -14,6 +14,7 @@ listensocket_container_t * listensocket_container_new(void); int listensocket_container_configure(listensocket_container_t *self, const ice_config_t *config); +int listensocket_container_configure_and_setup(listensocket_container_t *self, const ice_config_t *config); int listensocket_container_setup(listensocket_container_t *self); connection_t * listensocket_container_accept(listensocket_container_t *self, int timeout); int listensocket_container_set_sockcount_cb(listensocket_container_t *self, void (*cb)(size_t count, void *userdata), void *userdata);