diff options
Diffstat (limited to 'src/irmd')
-rw-r--r-- | src/irmd/CMakeLists.txt | 22 | ||||
-rw-r--r-- | src/irmd/api_table.c | 5 | ||||
-rw-r--r-- | src/irmd/config.h.in | 46 | ||||
-rw-r--r-- | src/irmd/ipcp.c | 31 | ||||
-rw-r--r-- | src/irmd/irm_flow.c | 5 | ||||
-rw-r--r-- | src/irmd/main.c | 8 | ||||
-rw-r--r-- | src/irmd/registry.c | 5 | ||||
-rw-r--r-- | src/irmd/registry.h | 1 | ||||
-rw-r--r-- | src/irmd/utils.c | 3 |
9 files changed, 101 insertions, 25 deletions
diff --git a/src/irmd/CMakeLists.txt b/src/irmd/CMakeLists.txt index 930c7b05..3339991a 100644 --- a/src/irmd/CMakeLists.txt +++ b/src/irmd/CMakeLists.txt @@ -4,6 +4,28 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_SOURCE_DIR}/include) include_directories(${CMAKE_BINARY_DIR}/include) +set(IRMD_ACCEPT_TIMEOUT 100 CACHE STRING + "Timeout for accept in IRMD mainloop threads (ms)") +set(IRMD_REQ_ARR_TIMEOUT 500 CACHE STRING + "Timeout for an application to respond to a new flow (ms)") +set(IRMD_FLOW_TIMEOUT 5000 CACHE STRING + "Timeout for a flow allocation response (ms)") +set(BOOTSTRAP_TIMEOUT 5000 CACHE STRING + "Timeout for an IPCP to bootstrap (ms)") +set(ENROLL_TIMEOUT 60000 CACHE STRING + "Timeout for an IPCP to enroll (ms)") +set(REG_TIMEOUT 10000 CACHE STRING + "Timeout for registering a name (ms)") +set(QUERY_TIMEOUT 3000 CACHE STRING + "Timeout to query a name with an IPCP (ms)") +set(IRMD_MIN_THREADS 8 CACHE STRING + "Minimum number of worker threads in the IRMd.") +set(IRMD_ADD_THREADS 8 CACHE STRING + "Number of extra threads to start when the IRMD faces thread starvation") + +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.h.in" + "${CMAKE_CURRENT_BINARY_DIR}/config.h" @ONLY) + set(SOURCE_FILES # Add source files here api_table.c diff --git a/src/irmd/api_table.c b/src/irmd/api_table.c index 5765916e..df56dd02 100644 --- a/src/irmd/api_table.c +++ b/src/irmd/api_table.c @@ -20,7 +20,10 @@ * Foundation, Inc., http://www.fsf.org/about/contact/. */ -#include <ouroboros/config.h> +#define _POSIX_C_SOURCE 200112L + +#include "config.h" + #include <ouroboros/list.h> #include <ouroboros/errno.h> #include <ouroboros/time_utils.h> diff --git a/src/irmd/config.h.in b/src/irmd/config.h.in new file mode 100644 index 00000000..eb396bbc --- /dev/null +++ b/src/irmd/config.h.in @@ -0,0 +1,46 @@ +/* + * Ouroboros - Copyright (C) 2016 - 2017 + * + * Configuration for the IPC Resource Manager + * + * Dimitri Staessens <[email protected]> + * Sander Vrijders <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., http://www.fsf.org/about/contact/. + */ + +#define IPCP_SHIM_UDP_EXEC "@IPCP_SHIM_UDP_TARGET@" +#define IPCP_SHIM_ETH_LLC_EXEC "@IPCP_SHIM_ETH_LLC_TARGET@" +#define IPCP_NORMAL_EXEC "@IPCP_NORMAL_TARGET@" +#define IPCP_LOCAL_EXEC "@IPCP_LOCAL_TARGET@" + +#define INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@" + +#define PTHREAD_COND_CLOCK @PTHREAD_COND_CLOCK@ + +#define SOCKET_TIMEOUT @SOCKET_TIMEOUT@ + +#define IRMD_ACCEPT_TIMEOUT @IRMD_ACCEPT_TIMEOUT@ +#define IRMD_REQ_ARR_TIMEOUT @IRMD_REQ_ARR_TIMEOUT@ +#define IRMD_FLOW_TIMEOUT @IRMD_FLOW_TIMEOUT@ + +#define BOOTSTRAP_TIMEOUT @BOOTSTRAP_TIMEOUT@ +#define ENROLL_TIMEOUT @ENROLL_TIMEOUT@ +#define REG_TIMEOUT @REG_TIMEOUT@ +#define QUERY_TIMEOUT @QUERY_TIMEOUT@ + +#define SYS_MAX_FLOWS @SYS_MAX_FLOWS@ + +#define IRMD_MIN_THREADS @IRMD_MIN_THREADS@ +#define IRMD_ADD_THREADS @IRMD_ADD_THREADS@ diff --git a/src/irmd/ipcp.c b/src/irmd/ipcp.c index f3f97811..e1689b91 100644 --- a/src/irmd/ipcp.c +++ b/src/irmd/ipcp.c @@ -20,9 +20,12 @@ * Foundation, Inc., http://www.fsf.org/about/contact/. */ +#define _POSIX_C_SOURCE 199309L + +#include "config.h" + #define OUROBOROS_PREFIX "irmd/ipcp" -#include <ouroboros/config.h> #include <ouroboros/logs.h> #include <ouroboros/errno.h> #include <ouroboros/utils.h> @@ -49,9 +52,9 @@ ipcp_msg_t * send_recv_ipcp_msg(pid_t api, ipcp_msg_t * msg) { int sockfd = 0; - buffer_t buf; + uint8_t buf[IPCP_MSG_BUF_SIZE]; char * sock_path = NULL; - ssize_t count = 0; + ssize_t len; ipcp_msg_t * recv_msg = NULL; struct timeval tv; @@ -70,14 +73,8 @@ ipcp_msg_t * send_recv_ipcp_msg(pid_t api, free(sock_path); - buf.len = ipcp_msg__get_packed_size(msg); - if (buf.len == 0) { - close(sockfd); - return NULL; - } - - buf.data = malloc(IPCP_MSG_BUF_SIZE); - if (buf.data == NULL) { + len = ipcp_msg__get_packed_size(msg); + if (len == 0) { close(sockfd); return NULL; } @@ -110,18 +107,16 @@ ipcp_msg_t * send_recv_ipcp_msg(pid_t api, log_warn("Failed to set timeout on socket."); pthread_cleanup_push(close_ptr, (void *) &sockfd); - pthread_cleanup_push((void (*)(void *)) free, (void *) buf.data); - ipcp_msg__pack(msg, buf.data); + ipcp_msg__pack(msg, buf); - if (write(sockfd, buf.data, buf.len) != -1) - count = read(sockfd, buf.data, IPCP_MSG_BUF_SIZE); + if (write(sockfd, buf, len) != -1) + len = read(sockfd, buf, IPCP_MSG_BUF_SIZE); - if (count > 0) - recv_msg = ipcp_msg__unpack(NULL, count, buf.data); + if (len > 0) + recv_msg = ipcp_msg__unpack(NULL, len, buf); pthread_cleanup_pop(true); - pthread_cleanup_pop(true); return recv_msg; } diff --git a/src/irmd/irm_flow.c b/src/irmd/irm_flow.c index ae5585a2..e335ef48 100644 --- a/src/irmd/irm_flow.c +++ b/src/irmd/irm_flow.c @@ -20,9 +20,12 @@ * Foundation, Inc., http://www.fsf.org/about/contact/. */ +#define _POSIX_C_SOURCE 199309L + +#include "config.h" + #define OUROBOROS_PREFIX "irm_flow" -#include <ouroboros/config.h> #include <ouroboros/errno.h> #include <ouroboros/logs.h> #include <ouroboros/time_utils.h> diff --git a/src/irmd/main.c b/src/irmd/main.c index a7c2bd4c..66c230c8 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -20,9 +20,13 @@ * Foundation, Inc., http://www.fsf.org/about/contact/. */ +#define _POSIX_C_SOURCE 200812L +#define __XSI_VISIBLE 500 + +#include "config.h" + #define OUROBOROS_PREFIX "irmd" -#include <ouroboros/config.h> #include <ouroboros/hash.h> #include <ouroboros/errno.h> #include <ouroboros/sockets.h> @@ -2070,7 +2074,7 @@ static int irm_init(void) list_head_init(&irmd.registry); list_head_init(&irmd.irm_flows); - irmd.port_ids = bmp_create(IRMD_MAX_FLOWS, 0); + irmd.port_ids = bmp_create(SYS_MAX_FLOWS, 0); if (irmd.port_ids == NULL) { log_err("Failed to create port_ids bitmap."); goto fail_port_ids; diff --git a/src/irmd/registry.c b/src/irmd/registry.c index ad6a10d4..3cc9b5f5 100644 --- a/src/irmd/registry.c +++ b/src/irmd/registry.c @@ -20,9 +20,12 @@ * Foundation, Inc., http://www.fsf.org/about/contact/. */ +#define _POSIX_C_SOURCE 200809L + +#include "config.h" + #define OUROBOROS_PREFIX "registry" -#include <ouroboros/config.h> #include <ouroboros/errno.h> #include <ouroboros/logs.h> #include <ouroboros/irm.h> diff --git a/src/irmd/registry.h b/src/irmd/registry.h index d1733f6c..486843a2 100644 --- a/src/irmd/registry.h +++ b/src/irmd/registry.h @@ -23,7 +23,6 @@ #ifndef OUROBOROS_IRMD_REGISTRY_H #define OUROBOROS_IRMD_REGISTRY_H -#include <ouroboros/config.h> #include <ouroboros/hash.h> #include <ouroboros/ipcp.h> #include <ouroboros/list.h> diff --git a/src/irmd/utils.c b/src/irmd/utils.c index 5a3da732..08699a05 100644 --- a/src/irmd/utils.c +++ b/src/irmd/utils.c @@ -20,7 +20,8 @@ * Foundation, Inc., http://www.fsf.org/about/contact/. */ -#include <ouroboros/config.h> +#define _POSIX_C_SOURCE 200809L + #include <stdlib.h> #include <string.h> |