diff options
Diffstat (limited to 'ctrl')
-rw-r--r-- | ctrl/facemgr/examples/updownsrv/updownsrv.c | 11 | ||||
-rw-r--r-- | ctrl/facemgr/src/api.c | 13 | ||||
-rw-r--r-- | ctrl/facemgr/src/interface.c | 20 | ||||
-rw-r--r-- | ctrl/facemgr/src/interface.h | 2 | ||||
-rw-r--r-- | ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c | 1 | ||||
-rw-r--r-- | ctrl/facemgr/src/interfaces/updown/updown.c | 12 | ||||
-rw-r--r-- | ctrl/facemgr/src/main.c | 1 | ||||
-rw-r--r-- | ctrl/facemgr/src/util/map.h | 4 |
8 files changed, 38 insertions, 26 deletions
diff --git a/ctrl/facemgr/examples/updownsrv/updownsrv.c b/ctrl/facemgr/examples/updownsrv/updownsrv.c index 5d624583b..3aba3cfd0 100644 --- a/ctrl/facemgr/examples/updownsrv/updownsrv.c +++ b/ctrl/facemgr/examples/updownsrv/updownsrv.c @@ -27,7 +27,8 @@ /** * \brief Default interval (in seconds) between timer events */ -#define DEFAULT_INTERVAL 100000 +#define DEFAULT_INTERVAL_SEC 5 +#define DEFAULT_INTERVAL_NSEC 0 /** * \brief Maximum allowed number of connected clients @@ -136,12 +137,12 @@ int main() { struct itimerspec ts = { .it_interval = { - .tv_sec = DEFAULT_INTERVAL, - .tv_nsec = 0, + .tv_sec = DEFAULT_INTERVAL_SEC, + .tv_nsec = DEFAULT_INTERVAL_NSEC, }, .it_value = { - .tv_sec = DEFAULT_INTERVAL, - .tv_nsec = 0, + .tv_sec = DEFAULT_INTERVAL_SEC, + .tv_nsec = DEFAULT_INTERVAL_NSEC, } }; rc = timerfd_settime(tfd, 0, &ts, NULL); diff --git a/ctrl/facemgr/src/api.c b/ctrl/facemgr/src/api.c index 19f211dbf..f0ae15b62 100644 --- a/ctrl/facemgr/src/api.c +++ b/ctrl/facemgr/src/api.c @@ -1622,28 +1622,29 @@ facemgr_bootstrap(facemgr_t * facemgr) /* FIXME facemgr_delete_interface */ #ifdef WITH_EXAMPLE_UPDOWN - interface_free(facemgr->updown); + facemgr_delete_interface(facemgr, facemgr->updown); ERR_UPDOWN_CREATE: #endif #ifdef WITH_EXAMPLE_DUMMY - interface_free(facemgr->dummy); + facemgr_delete_interface(facemgr, facemgr->dummy); ERR_DUMMY_CREATE: #endif #ifdef __ANDROID__ - interface_free(facemgr->au); + facemgr_delete_interface(facemgr, facemgr->au); ERR_AU_CREATE: #endif /* __ANDROID__ */ #ifdef __linux__ - interface_free(facemgr->nl); + facemgr_delete_interface(facemgr, facemgr->nl); ERR_NL_CREATE: #endif /* __linux__ */ #ifdef __APPLE__ - interface_free(facemgr->nf); + facemgr_delete_interface(facemgr, facemgr->nf); ERR_NF_CREATE: #endif /* __APPLE__ */ - interface_free(facemgr->hl); + facemgr_delete_interface(facemgr, facemgr->hl); ERR_HL_CREATE: ERR_REGISTER: + interface_unregister_all(); return -1; } diff --git a/ctrl/facemgr/src/interface.c b/ctrl/facemgr/src/interface.c index 72a78ef56..d592bf04c 100644 --- a/ctrl/facemgr/src/interface.c +++ b/ctrl/facemgr/src/interface.c @@ -53,19 +53,21 @@ interface_unregister_all() int n = interface_ops_map_get_key_array(interface_ops_map, &ops_name_array); if (n < 0) { ERROR("[interface_unregister_all] Could not get interface ops array"); - ret = -1; - } else { - for (unsigned i = 0; i < n; i++) { - const char * ops_name = ops_name_array[i]; - if (interface_ops_map_remove(interface_ops_map, ops_name, NULL) < 0) { - ERROR("[interface_unregister_all] Could not remove %s from interface ops map", ops_name); - ret = -1; - } + return -1; + } + + for (unsigned i = 0; i < n; i++) { + const char * ops_name = ops_name_array[i]; + if (interface_ops_map_remove(interface_ops_map, ops_name, NULL) < 0) { + ERROR("[interface_unregister_all] Could not remove %s from interface ops map", ops_name); + ret = -1; } - free(ops_name_array); } + free(ops_name_array); + interface_ops_map_free(interface_ops_map); interface_ops_map = NULL; + return ret; } diff --git a/ctrl/facemgr/src/interface.h b/ctrl/facemgr/src/interface.h index 0ebe8c7c8..627a3645e 100644 --- a/ctrl/facemgr/src/interface.h +++ b/ctrl/facemgr/src/interface.h @@ -77,6 +77,8 @@ typedef struct interface_s { */ int interface_register(const interface_ops_t * ops); +int interface_unregister_all(); + /** * \brief Unregister all interface types */ diff --git a/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c b/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c index e8f168706..82d4a7e6e 100644 --- a/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c +++ b/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c @@ -242,7 +242,6 @@ int hl_on_event(interface_t * interface, const facelet_t * facelet) if (!data->s) { /* We are not connected to the forwarder */ goto ERR; - } switch(facelet_get_event(facelet)) { diff --git a/ctrl/facemgr/src/interfaces/updown/updown.c b/ctrl/facemgr/src/interfaces/updown/updown.c index 6a7ab83f4..b804cdac1 100644 --- a/ctrl/facemgr/src/interfaces/updown/updown.c +++ b/ctrl/facemgr/src/interfaces/updown/updown.c @@ -53,7 +53,7 @@ int updown_initialize(interface_t * interface, void * cfg) data->fd = socket(AF_UNIX, SOCK_STREAM, 0); if (data->fd == -1) { perror("socket error"); - return -1; + goto ERR_SOCKET; } memset(&addr, 0, sizeof(addr)); @@ -67,7 +67,7 @@ int updown_initialize(interface_t * interface, void * cfg) if (connect(data->fd, (struct sockaddr*)&addr, sizeof(addr)) == -1) { perror("connect error"); - return -1; + goto ERR_CONNECT; } if (interface_register_fd(interface, data->fd, NULL) < 0) { @@ -77,6 +77,11 @@ int updown_initialize(interface_t * interface, void * cfg) return 0; +ERR_FD: +ERR_CONNECT: + close(data->fd); +ERR_SOCKET: + free(data); ERR_MALLOC: return -1; } @@ -87,11 +92,12 @@ int updown_finalize(interface_t * interface) if (data->fd > 0) close(data->fd); + free(data); return 0; } -int updown_callback(interface_t * interface) +int updown_callback(interface_t * interface, int fd, void * unused) { updown_data_t * data = (updown_data_t*)interface->data; char buf[100]; diff --git a/ctrl/facemgr/src/main.c b/ctrl/facemgr/src/main.c index 9eba2aa0c..b7bd6c6cd 100644 --- a/ctrl/facemgr/src/main.c +++ b/ctrl/facemgr/src/main.c @@ -246,6 +246,7 @@ MAIN_LOOP: ERR_BOOTSTRAP: facemgr_free(facemgr); + loop_free(loop); ERR_FACEMGR_CONFIG: ERR_FACEMGR: ERR_PARSE: diff --git a/ctrl/facemgr/src/util/map.h b/ctrl/facemgr/src/util/map.h index 19a308d86..adab8d758 100644 --- a/ctrl/facemgr/src/util/map.h +++ b/ctrl/facemgr/src/util/map.h @@ -219,7 +219,7 @@ NAME ## _get_key_array(NAME ## _t * map, KEY_T **array) { for (int i = 0; i < n; i++) \ (*array)[i] = pair_array[i]->key; \ free(pair_array); \ - return 0; \ + return n; \ } \ \ int \ @@ -238,7 +238,7 @@ NAME ## _get_value_array(NAME ## _t * map, VAL_T **array) { for (int i = 0; i < n; i++) \ (*array)[i] = pair_array[i]->value; \ free(pair_array); \ - return 0; \ + return n; \ } #endif /* UTIL_MAP_H */ |