diff options
Diffstat (limited to 'src/ipcpd')
-rw-r--r-- | src/ipcpd/eth/eth.c | 2 | ||||
-rw-r--r-- | src/ipcpd/ipcp.c | 55 | ||||
-rw-r--r-- | src/ipcpd/ipcp.h | 3 | ||||
-rw-r--r-- | src/ipcpd/unicast/dir/dht.c | 8 | ||||
-rw-r--r-- | src/ipcpd/unicast/dir/tests/CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/ipcpd/unicast/pff/tests/CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/ipcpd/unicast/routing/tests/CMakeLists.txt | 6 |
7 files changed, 50 insertions, 36 deletions
diff --git a/src/ipcpd/eth/eth.c b/src/ipcpd/eth/eth.c index ea6e0f1c..c0e6d0ce 100644 --- a/src/ipcpd/eth/eth.c +++ b/src/ipcpd/eth/eth.c @@ -1512,8 +1512,8 @@ static int eth_ipcp_bootstrap(const struct ipcp_config * conf) close(eth_data.bpf); #elif defined(HAVE_RAW_SOCKETS) close(eth_data.s_fd); -#endif fail_socket: +#endif return -1; } diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c index 966c4920..39b053d6 100644 --- a/src/ipcpd/ipcp.c +++ b/src/ipcpd/ipcp.c @@ -64,6 +64,10 @@ #endif #endif +#ifndef CLOCK_REALTIME_COARSE +#define CLOCK_REALTIME_COARSE CLOCK_REALTIME +#endif + char * info[LAYER_NAME_SIZE + 1] = { "_state", "_type", @@ -639,17 +643,17 @@ static void do_flow_dealloc(int flow_id, static void * mainloop(void * o) { - int sfd; - buffer_t buffer; - ipcp_msg_t * msg; + int sfd; + buffer_t buffer; + ipcp_msg_t * msg; (void) o; while (true) { - ipcp_msg_t ret_msg = IPCP_MSG__INIT; - qosspec_t qs; - struct cmd * cmd; - buffer_t data; + ipcp_msg_t ret_msg = IPCP_MSG__INIT; + qosspec_t qs; + struct cmd * cmd; + buffer_t data; ret_msg.code = IPCP_MSG_CODE__IPCP_REPLY; @@ -675,7 +679,7 @@ static void * mainloop(void * o) continue; } - tpm_dec(ipcpi.tpm); + tpm_begin_work(ipcpi.tpm); pthread_cleanup_push(__cleanup_close_ptr, &sfd); pthread_cleanup_push(free_msg, msg); @@ -749,7 +753,7 @@ static void * mainloop(void * o) if (buffer.len == 0) { log_err("Failed to pack reply message"); close(sfd); - tpm_inc(ipcpi.tpm); + tpm_end_work(ipcpi.tpm); continue; } @@ -757,7 +761,7 @@ static void * mainloop(void * o) if (buffer.data == NULL) { log_err("Failed to create reply buffer."); close(sfd); - tpm_inc(ipcpi.tpm); + tpm_end_work(ipcpi.tpm); continue; } @@ -766,16 +770,16 @@ static void * mainloop(void * o) if (ret_msg.layer_info != NULL) layer_info_msg__free_unpacked(ret_msg.layer_info, NULL); - pthread_cleanup_push(__cleanup_close_ptr, &sfd); pthread_cleanup_push(free, buffer.data) + pthread_cleanup_push(__cleanup_close_ptr, &sfd); if (write(sfd, buffer.data, buffer.len) == -1) log_warn("Failed to send reply message"); - pthread_cleanup_pop(true); - pthread_cleanup_pop(true); + pthread_cleanup_pop(true); /* close sfd */ + pthread_cleanup_pop(true); /* free buffer.data */ - tpm_inc(ipcpi.tpm); + tpm_end_work(ipcpi.tpm); } return (void *) 0; @@ -813,39 +817,38 @@ int ipcp_init(int argc, { bool log; pthread_condattr_t cattr; - int ret = -1; if (parse_args(argc, argv, &log)) return -1; log_init(log); - ipcpi.irmd_fd = -1; ipcpi.state = IPCP_NULL; ipcpi.type = type; #if defined (__linux__) prctl(PR_SET_TIMERSLACK, IPCP_LINUX_SLACK_NS, 0, 0, 0); #endif - ipcpi.sock_path = ipcp_sock_path(getpid()); + ipcpi.sock_path = sock_path(getpid(), IPCP_SOCK_PATH_PREFIX); if (ipcpi.sock_path == NULL) goto fail_sock_path; ipcpi.sockfd = server_socket_open(ipcpi.sock_path); if (ipcpi.sockfd < 0) { - log_err("Could not open server socket."); + log_err("Failed to open server socket at %s.", + ipcpi.sock_path); goto fail_serv_sock; } ipcpi.ops = ops; if (pthread_mutex_init(&ipcpi.state_mtx, NULL)) { - log_err("Could not create mutex."); + log_err("Failed to create mutex."); goto fail_state_mtx; } if (pthread_condattr_init(&cattr)) { - log_err("Could not create condattr."); + log_err("Failed to create condattr."); goto fail_cond_attr; } @@ -853,7 +856,7 @@ int ipcp_init(int argc, pthread_condattr_setclock(&cattr, PTHREAD_COND_CLOCK); #endif if (pthread_cond_init(&ipcpi.state_cond, &cattr)) { - log_err("Could not init condvar."); + log_err("Failed to init condvar."); goto fail_state_cond; } @@ -887,6 +890,8 @@ int ipcp_init(int argc, goto fail_rib_reg; } + list_head_init(&ipcpi.cmds); + ipcpi.tpm = tpm_create(IPCP_MIN_THREADS, IPCP_ADD_THREADS, mainloop, NULL); if (ipcpi.tpm == NULL) { @@ -894,8 +899,6 @@ int ipcp_init(int argc, goto fail_tpm_create; } - list_head_init(&ipcpi.cmds); - ipcpi.alloc_id = -1; pthread_condattr_destroy(&cattr); @@ -927,7 +930,7 @@ int ipcp_init(int argc, fail_serv_sock: free(ipcpi.sock_path); fail_sock_path: - return ret; + return -1; } int ipcp_start(void) @@ -948,8 +951,10 @@ int ipcp_start(void) strcpy(info.name, ipcpi.name); info.state = IPCP_OPERATIONAL; - if (tpm_start(ipcpi.tpm)) + if (tpm_start(ipcpi.tpm)) { + log_err("Failed to start threadpool manager."); goto fail_tpm_start; + } if (pthread_create(&ipcpi.acceptor, NULL, acceptloop, NULL)) { log_err("Failed to create acceptor thread."); diff --git a/src/ipcpd/ipcp.h b/src/ipcpd/ipcp.h index aab490c7..b29f0bf4 100644 --- a/src/ipcpd/ipcp.h +++ b/src/ipcpd/ipcp.h @@ -123,9 +123,6 @@ void ipcp_set_state(enum ipcp_state state); enum ipcp_state ipcp_get_state(void); -int ipcp_parse_arg(int argc, - char * argv[]); - /* Helper functions to handle races during flow allocation */ int ipcp_wait_flow_req_arr(const uint8_t * dst, qosspec_t qs, diff --git a/src/ipcpd/unicast/dir/dht.c b/src/ipcpd/unicast/dir/dht.c index 08a5a5a9..95c5f19a 100644 --- a/src/ipcpd/unicast/dir/dht.c +++ b/src/ipcpd/unicast/dir/dht.c @@ -884,12 +884,12 @@ static void lookup_update(struct dht * dht, contact_destroy(c); } else { struct contact * d; - list_add_tail(&c->next, p); d = list_last_entry(&lu->contacts, struct contact, next); list_del(&d->next); assert(lu->contacts.prv != &d->next); contact_destroy(d); + list_add_tail(&c->next, p); mod = true; } } @@ -2503,7 +2503,7 @@ static void * dht_handle_packet(void * o) continue; } - tpm_dec(dht->tpm); + tpm_begin_work(dht->tpm); addr = msg->s_addr; @@ -2604,7 +2604,7 @@ static void * dht_handle_packet(void * o) free(resp_msg.addrs); if (resp_msg.n_contacts == 0) { - tpm_inc(dht->tpm); + tpm_end_work(dht->tpm); continue; } @@ -2613,7 +2613,7 @@ static void * dht_handle_packet(void * o) NULL); free(resp_msg.contacts); - tpm_inc(dht->tpm); + tpm_end_work(dht->tpm); } return (void *) 0; diff --git a/src/ipcpd/unicast/dir/tests/CMakeLists.txt b/src/ipcpd/unicast/dir/tests/CMakeLists.txt index c850e41d..f62ed993 100644 --- a/src/ipcpd/unicast/dir/tests/CMakeLists.txt +++ b/src/ipcpd/unicast/dir/tests/CMakeLists.txt @@ -28,7 +28,11 @@ target_link_libraries(${PARENT_DIR}_test ouroboros-common) add_dependencies(check ${PARENT_DIR}_test) set(tests_to_run ${${PARENT_DIR}_tests}) -remove(tests_to_run test_suite.c) +if(CMAKE_VERSION VERSION_LESS "3.29.0") + remove(tests_to_run test_suite.c) +else () + list(POP_FRONT tests_to_run) +endif() foreach (test ${tests_to_run}) get_filename_component(test_name ${test} NAME_WE) diff --git a/src/ipcpd/unicast/pff/tests/CMakeLists.txt b/src/ipcpd/unicast/pff/tests/CMakeLists.txt index e7082372..65705714 100644 --- a/src/ipcpd/unicast/pff/tests/CMakeLists.txt +++ b/src/ipcpd/unicast/pff/tests/CMakeLists.txt @@ -26,7 +26,11 @@ target_link_libraries(${PARENT_DIR}_test ouroboros-common) add_dependencies(check ${PARENT_DIR}_test) set(tests_to_run ${${PARENT_DIR}_tests}) -remove(tests_to_run test_suite.c) +if(CMAKE_VERSION VERSION_LESS "3.29.0") + remove(tests_to_run test_suite.c) +else () + list(POP_FRONT tests_to_run) +endif() foreach (test ${tests_to_run}) get_filename_component(test_name ${test} NAME_WE) diff --git a/src/ipcpd/unicast/routing/tests/CMakeLists.txt b/src/ipcpd/unicast/routing/tests/CMakeLists.txt index d0652533..9d24bf03 100644 --- a/src/ipcpd/unicast/routing/tests/CMakeLists.txt +++ b/src/ipcpd/unicast/routing/tests/CMakeLists.txt @@ -26,7 +26,11 @@ target_link_libraries(${PARENT_DIR}_test ouroboros-common) add_dependencies(check ${PARENT_DIR}_test) set(tests_to_run ${${PARENT_DIR}_tests}) -remove(tests_to_run test_suite.c) +if(CMAKE_VERSION VERSION_LESS "3.29.0") + remove(tests_to_run test_suite.c) +else () + list(POP_FRONT tests_to_run) +endif() foreach (test ${tests_to_run}) get_filename_component(test_name ${test} NAME_WE) |