summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@ugent.be>2017-08-03 19:33:00 +0200
committerSander Vrijders <sander.vrijders@ugent.be>2017-08-03 19:33:00 +0200
commite77db148ce7adbaefb2ec7fb66a1fe0a36cff72f (patch)
tree8f69e8ca7817cefcdece2f749a83de32fea9be18
parent3b06d69d61cd677394fa7adf1ffcfa13ab8bac70 (diff)
parent9017e3006c1e1246de5291f13319a763fd440e2f (diff)
downloadouroboros-e77db148ce7adbaefb2ec7fb66a1fe0a36cff72f.tar.gz
ouroboros-e77db148ce7adbaefb2ec7fb66a1fe0a36cff72f.zip
Merge branch 'testing' into be
-rw-r--r--src/ipcpd/local/main.c18
-rw-r--r--src/ipcpd/normal/fa.c16
-rw-r--r--src/ipcpd/shim-eth-llc/main.c18
-rw-r--r--src/ipcpd/shim-udp/main.c18
4 files changed, 54 insertions, 16 deletions
diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c
index ddb5e4ec..78224fbd 100644
--- a/src/ipcpd/local/main.c
+++ b/src/ipcpd/local/main.c
@@ -177,18 +177,23 @@ static int ipcp_local_flow_alloc(int fd,
qoscube_t cube)
{
struct timespec ts = {0, EVENT_WAIT_TIMEOUT * 1000};
+ struct timespec abstime;
int out_fd = -1;
log_dbg("Allocating flow to " HASH_FMT " on fd %d.", HASH_VAL(dst), fd);
assert(dst);
+ clock_gettime(PTHREAD_COND_CLOCK, &abstime);
+
pthread_mutex_lock(&ipcpi.alloc_lock);
- while (ipcpi.alloc_id != -1 && ipcp_get_state() == IPCP_OPERATIONAL)
+ while (ipcpi.alloc_id != -1 && ipcp_get_state() == IPCP_OPERATIONAL) {
+ ts_add(&abstime, &ts, &abstime);
pthread_cond_timedwait(&ipcpi.alloc_cond,
&ipcpi.alloc_lock,
- &ts);
+ &abstime);
+ }
if (ipcp_get_state() != IPCP_OPERATIONAL) {
log_dbg("Won't allocate over non-operational IPCP.");
@@ -228,15 +233,20 @@ static int ipcp_local_flow_alloc_resp(int fd,
int response)
{
struct timespec ts = {0, EVENT_WAIT_TIMEOUT * 1000};
+ struct timespec abstime;
int out_fd = -1;
int ret = -1;
+ clock_gettime(PTHREAD_COND_CLOCK, &abstime);
+
pthread_mutex_lock(&ipcpi.alloc_lock);
- while (ipcpi.alloc_id != fd && ipcp_get_state() == IPCP_OPERATIONAL)
+ while (ipcpi.alloc_id != fd && ipcp_get_state() == IPCP_OPERATIONAL) {
+ ts_add(&abstime, &ts, &abstime);
pthread_cond_timedwait(&ipcpi.alloc_cond,
&ipcpi.alloc_lock,
- &ts);
+ &abstime);
+ }
if (ipcp_get_state() != IPCP_OPERATIONAL) {
pthread_mutex_unlock(&ipcpi.alloc_lock);
diff --git a/src/ipcpd/normal/fa.c b/src/ipcpd/normal/fa.c
index d346f67c..704f4f16 100644
--- a/src/ipcpd/normal/fa.c
+++ b/src/ipcpd/normal/fa.c
@@ -84,6 +84,7 @@ static void fa_post_sdu(void * ae,
struct shm_du_buff * sdb)
{
struct timespec ts = {0, TIMEOUT * 1000};
+ struct timespec abstime;
int fd;
flow_alloc_msg_t * msg;
@@ -108,6 +109,8 @@ static void fa_post_sdu(void * ae,
switch (msg->code) {
case FLOW_ALLOC_CODE__FLOW_REQ:
+ clock_gettime(PTHREAD_COND_CLOCK, &abstime);
+
pthread_mutex_lock(&ipcpi.alloc_lock);
if (!msg->has_hash || !msg->has_s_fd || !msg->has_s_addr) {
@@ -118,10 +121,12 @@ static void fa_post_sdu(void * ae,
}
while (ipcpi.alloc_id != -1 &&
- ipcp_get_state() == IPCP_OPERATIONAL)
+ ipcp_get_state() == IPCP_OPERATIONAL) {
+ ts_add(&abstime, &ts, &abstime);
pthread_cond_timedwait(&ipcpi.alloc_cond,
&ipcpi.alloc_lock,
- &ts);
+ &abstime);
+ }
if (ipcp_get_state() != IPCP_OPERATIONAL) {
log_dbg("Won't allocate over non-operational IPCP.");
@@ -275,16 +280,19 @@ int fa_alloc_resp(int fd,
int response)
{
struct timespec ts = {0, TIMEOUT * 1000};
+ struct timespec abstime;
flow_alloc_msg_t msg = FLOW_ALLOC_MSG__INIT;
struct shm_du_buff * sdb;
qoscube_t qc;
pthread_mutex_lock(&ipcpi.alloc_lock);
- while (ipcpi.alloc_id != fd && ipcp_get_state() == IPCP_OPERATIONAL)
+ while (ipcpi.alloc_id != fd && ipcp_get_state() == IPCP_OPERATIONAL) {
+ ts_add(&abstime, &ts, &abstime);
pthread_cond_timedwait(&ipcpi.alloc_cond,
&ipcpi.alloc_lock,
- &ts);
+ &abstime);
+ }
if (ipcp_get_state() != IPCP_OPERATIONAL) {
pthread_mutex_unlock(&ipcpi.alloc_lock);
diff --git a/src/ipcpd/shim-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c
index 28ab897b..4899cd83 100644
--- a/src/ipcpd/shim-eth-llc/main.c
+++ b/src/ipcpd/shim-eth-llc/main.c
@@ -382,14 +382,19 @@ static int eth_llc_ipcp_sap_req(uint8_t r_sap,
qoscube_t cube)
{
struct timespec ts = {0, EVENT_WAIT_TIMEOUT * 1000};
+ struct timespec abstime;
int fd;
+ clock_gettime(PTHREAD_COND_CLOCK, &abstime);
+
pthread_mutex_lock(&ipcpi.alloc_lock);
- while (ipcpi.alloc_id != -1 && ipcp_get_state() == IPCP_OPERATIONAL)
+ while (ipcpi.alloc_id != -1 && ipcp_get_state() == IPCP_OPERATIONAL) {
+ ts_add(&abstime, &ts, &abstime);
pthread_cond_timedwait(&ipcpi.alloc_cond,
&ipcpi.alloc_lock,
- &ts);
+ &abstime);
+ }
if (ipcp_get_state() != IPCP_OPERATIONAL) {
log_dbg("Won't allocate over non-operational IPCP.");
@@ -1023,16 +1028,21 @@ static int eth_llc_ipcp_flow_alloc_resp(int fd,
int response)
{
struct timespec ts = {0, EVENT_WAIT_TIMEOUT * 1000};
+ struct timespec abstime;
uint8_t ssap = 0;
uint8_t r_sap = 0;
uint8_t r_addr[MAC_SIZE];
+ clock_gettime(PTHREAD_COND_CLOCK, &abstime);
+
pthread_mutex_lock(&ipcpi.alloc_lock);
- while (ipcpi.alloc_id != fd && ipcp_get_state() == IPCP_OPERATIONAL)
+ while (ipcpi.alloc_id != fd && ipcp_get_state() == IPCP_OPERATIONAL){
+ ts_add(&abstime, &ts, &abstime);
pthread_cond_timedwait(&ipcpi.alloc_cond,
&ipcpi.alloc_lock,
- &ts);
+ &abstime);
+ }
if (ipcp_get_state() != IPCP_OPERATIONAL) {
pthread_mutex_unlock(&ipcpi.alloc_lock);
diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c
index ab199ffd..fa77f843 100644
--- a/src/ipcpd/shim-udp/main.c
+++ b/src/ipcpd/shim-udp/main.c
@@ -236,6 +236,7 @@ static int ipcp_udp_port_req(struct sockaddr_in * c_saddr,
qoscube_t cube)
{
struct timespec ts = {0, FD_UPDATE_TIMEOUT * 1000};
+ struct timespec abstime;
struct sockaddr_in f_saddr;
socklen_t f_saddr_len = sizeof(f_saddr);
int skfd;
@@ -272,12 +273,16 @@ static int ipcp_udp_port_req(struct sockaddr_in * c_saddr,
return -1;
}
+ clock_gettime(PTHREAD_COND_CLOCK, &abstime);
+
pthread_mutex_lock(&ipcpi.alloc_lock);
- while (ipcpi.alloc_id != -1 && ipcp_get_state() == IPCP_OPERATIONAL)
+ while (ipcpi.alloc_id != -1 && ipcp_get_state() == IPCP_OPERATIONAL) {
+ ts_add(&abstime, &ts, &abstime);
pthread_cond_timedwait(&ipcpi.alloc_cond,
&ipcpi.alloc_lock,
- &ts);
+ &abstime);
+ }
if (ipcp_get_state() != IPCP_OPERATIONAL) {
log_dbg("Won't allocate over non-operational IPCP.");
@@ -971,6 +976,7 @@ static int ipcp_udp_flow_alloc_resp(int fd,
int response)
{
struct timespec ts = {0, FD_UPDATE_TIMEOUT * 1000};
+ struct timespec abstime;
int skfd = -1;
struct sockaddr_in f_saddr;
struct sockaddr_in r_saddr;
@@ -979,12 +985,16 @@ static int ipcp_udp_flow_alloc_resp(int fd,
if (response)
return 0;
+ clock_gettime(PTHREAD_COND_CLOCK, &abstime);
+
pthread_mutex_lock(&ipcpi.alloc_lock);
- while (ipcpi.alloc_id != fd && ipcp_get_state() == IPCP_OPERATIONAL)
+ while (ipcpi.alloc_id != fd && ipcp_get_state() == IPCP_OPERATIONAL) {
+ ts_add(&abstime, &ts, &abstime);
pthread_cond_timedwait(&ipcpi.alloc_cond,
&ipcpi.alloc_lock,
- &ts);
+ &abstime);
+ }
if (ipcp_get_state() != IPCP_OPERATIONAL) {
pthread_mutex_unlock(&ipcpi.alloc_lock);