diff options
author | 2019-11-24 23:51:45 +0100 | |
---|---|---|
committer | 2019-11-24 23:51:45 +0100 | |
commit | 93b0b7a95922defa19951dde01b1dce4047bb0e7 (patch) | |
tree | 4eb6b79102522e7b58461e00436cac9e1e823657 /ctrl/facemgr/src/interfaces/priority_controller | |
parent | 02fef955058d47f869f18f9c675f7cdca2be0695 (diff) |
[HICN-408] Add a face manager interface for face priority control
Change-Id: I768112c920154380a614d0c5858f50efa135903d
Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'ctrl/facemgr/src/interfaces/priority_controller')
-rw-r--r-- | ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c b/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c index 5c5afdb6c..b8e7271bb 100644 --- a/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c +++ b/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c @@ -22,7 +22,7 @@ int priority_controller_initialize(interface_t * interface, void * cfg) pc_data_t * data = malloc(sizeof(pc_data_t)); if (!data) { INFO("Priority controller data memory allocation error"); - return -1; + goto ERR_MALLOC; } interface->data = data; @@ -32,7 +32,7 @@ int priority_controller_initialize(interface_t * interface, void * cfg) if (data->fd < 0) { INFO("Priority controller socket error"); perror("socket error"); - return -1; + goto ERR_SOCKET; } memset(&addr, 0, sizeof(addr)); @@ -43,12 +43,23 @@ int priority_controller_initialize(interface_t * interface, void * cfg) if (bind(data->fd, (struct sockaddr*)&addr, sizeof(addr)) < 0) { INFO("Priority controller socket bind error"); perror("bind error"); - return -1; + goto ERR_BIND; + } + if (interface_register_fd(interface, data->fd, NULL) < 0) { + ERROR("[priority_controller_initialize] Error registering fd"); + goto ERR_FD; } - interface_register_fd(interface, data->fd, NULL); INFO("Priority controller successfully initialized"); - return data->fd; + return 0; + +ERR_FD: +ERR_BIND: + close(data->fd); +ERR_SOCKET: + free(data); +ERR_MALLOC: + return -1; } int priority_controller_finalize(interface_t * interface) @@ -67,12 +78,6 @@ int priority_controller_callback(interface_t * interface, int fd, void * unused) char buf[100]; int rc; - struct sockaddr_in addr; - memset(&addr, 0, sizeof(addr)); - addr.sin_family = AF_INET; - addr.sin_addr.s_addr = inet_addr("127.0.0.1"); - addr.sin_port = htons(9533); - INFO("Priority controller receiving command"); rc = recv(data->fd, buf, 100, 0); @@ -119,8 +124,6 @@ int priority_controller_callback(interface_t * interface, int fd, void * unused) interface_raise_event(interface, facelet_w); interface_raise_event(interface, facelet_c); - facelet_free(facelet_w); - facelet_free(facelet_c); return 0; } |