summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordimitri staessens <[email protected]>2017-07-12 10:13:50 +0000
committerSander Vrijders <[email protected]>2017-07-12 10:13:50 +0000
commit9bbc7b4ba57a13e425fcfdfd6bd7ba5248255721 (patch)
treebccd240c8a6fd59c283dcb2a325e1815bf478310
parent35b8b38606721b16a2fff52046096b603d7718f7 (diff)
parent9f553e440bd540ac46c98fa13ddf93e81daff221 (diff)
downloadouroboros-9bbc7b4ba57a13e425fcfdfd6bd7ba5248255721.tar.gz
ouroboros-9bbc7b4ba57a13e425fcfdfd6bd7ba5248255721.zip
Merged in dstaesse/ouroboros/be-fixes (pull request #526)
Be fixes
-rw-r--r--src/ipcpd/normal/connmgr.c3
-rw-r--r--src/ipcpd/shim-udp/main.c31
-rw-r--r--src/lib/cacep.c4
-rw-r--r--src/lib/irm.c3
4 files changed, 19 insertions, 22 deletions
diff --git a/src/ipcpd/normal/connmgr.c b/src/ipcpd/normal/connmgr.c
index 00af3db4..6259969a 100644
--- a/src/ipcpd/normal/connmgr.c
+++ b/src/ipcpd/normal/connmgr.c
@@ -169,7 +169,8 @@ int connmgr_init(void)
int connmgr_start(void)
{
- pthread_create(&connmgr.acceptor, NULL, flow_acceptor, NULL);
+ if (pthread_create(&connmgr.acceptor, NULL, flow_acceptor, NULL))
+ return -1;
return 0;
}
diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c
index b793c414..4ef3015a 100644
--- a/src/ipcpd/shim-udp/main.c
+++ b/src/ipcpd/shim-udp/main.c
@@ -376,14 +376,20 @@ static int ipcp_udp_port_alloc_reply(uint16_t src_udp_port,
static void * ipcp_udp_listener(void * o)
{
- uint8_t buf[SHIM_UDP_MSG_SIZE];
- ssize_t n = 0;
+ uint8_t buf[SHIM_UDP_MSG_SIZE];
+ ssize_t n = 0;
struct sockaddr_in c_saddr;
- int sfd = udp_data.s_fd;
+ int sfd = udp_data.s_fd;
+ struct timeval ltv = {(SOCKET_TIMEOUT / 1000),
+ (SOCKET_TIMEOUT % 1000) * 1000};
(void) o;
- while (true) {
+ if (setsockopt(sfd, SOL_SOCKET, SO_RCVTIMEO,
+ (void *) &ltv, sizeof(ltv)))
+ log_warn("Failed to set timeout on socket.");
+
+ while (ipcp_get_state() == IPCP_OPERATIONAL) {
shim_udp_msg_t * msg = NULL;
memset(&buf, 0, SHIM_UDP_MSG_SIZE);
@@ -443,7 +449,7 @@ static void * ipcp_udp_sdu_reader(void * o)
(void) o;
- while (true) {
+ while (ipcp_get_state() == IPCP_OPERATIONAL) {
pthread_rwlock_rdlock(&udp_data.flows_lock);
pthread_mutex_lock(&udp_data.fd_set_lock);
@@ -492,19 +498,14 @@ static void * ipcp_udp_sdu_loop(void * o)
(void) o;
- while (flow_event_wait(udp_data.np1_flows, udp_data.fq, &timeout)) {
+ while (ipcp_get_state() == IPCP_OPERATIONAL) {
+ flow_event_wait(udp_data.np1_flows, udp_data.fq, &timeout);
while ((fd = fqueue_next(udp_data.fq)) >= 0) {
if (ipcp_flow_read(fd, &sdb)) {
log_err("Bad read from fd %d.", fd);
continue;
}
-
- if (ipcp_get_state() != IPCP_OPERATIONAL) {
- ipcp_sdb_release(sdb);
- return (void *) 0; /* -ENOTENROLLED */
- }
-
pthread_rwlock_rdlock(&udp_data.flows_lock);
fd = udp_data.fd_to_uf[fd].skfd;
@@ -744,8 +745,7 @@ static int ipcp_udp_reg(const uint8_t * hash)
#ifdef CONFIG_OUROBOROS_ENABLE_DNS
char ipstr[INET_ADDRSTRLEN];
char dnsstr[INET_ADDRSTRLEN];
- /* max DNS name length + max IP length + command length */
- char cmd[100];
+ char cmd[1000];
uint32_t dns_addr;
uint32_t ip_addr;
#endif
@@ -1114,9 +1114,6 @@ int main(int argc,
ipcp_shutdown();
if (ipcp_get_state() == IPCP_SHUTDOWN) {
- pthread_cancel(udp_data.handler);
- pthread_cancel(udp_data.sdu_reader);
- pthread_cancel(udp_data.sduloop);
pthread_join(udp_data.sduloop, NULL);
pthread_join(udp_data.handler, NULL);
pthread_join(udp_data.sdu_reader, NULL);
diff --git a/src/lib/cacep.c b/src/lib/cacep.c
index a2c5c3d2..19585126 100644
--- a/src/lib/cacep.c
+++ b/src/lib/cacep.c
@@ -34,8 +34,8 @@ typedef CacepMsg cacep_msg_t;
#define BUF_SIZE 64
-int read_msg(int fd,
- struct conn_info * info)
+static int read_msg(int fd,
+ struct conn_info * info)
{
uint8_t buf[BUF_SIZE];
cacep_msg_t * msg;
diff --git a/src/lib/irm.c b/src/lib/irm.c
index 68202ad9..9ee9e9e0 100644
--- a/src/lib/irm.c
+++ b/src/lib/irm.c
@@ -189,9 +189,8 @@ ssize_t irm_list_ipcps(const char * name,
return -ENOMEM;
}
- for (i = 0; i < nr; i++) {
+ for (i = 0; i < nr; i++)
(*apis)[i] = recv_msg->apis[i];
- }
irm_msg__free_unpacked(recv_msg, NULL);