summaryrefslogtreecommitdiff
path: root/src/lib/dev.c
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-04-05 20:02:28 +0200
committerdimitri staessens <dimitri.staessens@ugent.be>2017-04-06 10:36:24 +0200
commite1c0714d5827cd927961f3a687d9720e6e9aa802 (patch)
treed8e793cffbe829d64855eaa5a429b90ebe3dc3a4 /src/lib/dev.c
parentc6ad4f96f8bb2f1ee749e92308e7173523ddd0b8 (diff)
downloadouroboros-e1c0714d5827cd927961f3a687d9720e6e9aa802.tar.gz
ouroboros-e1c0714d5827cd927961f3a687d9720e6e9aa802.zip
lib, irmd: Implement flow allocation timeout
Setting the timeouts on flow_alloc and flow_accept will now work. This makes some changes to the UNIX sockets used for management communication between the APs, IRMd and IPCPs.
Diffstat (limited to 'src/lib/dev.c')
-rw-r--r--src/lib/dev.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c
index c063fd47..389ff278 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -276,7 +276,7 @@ int ap_init(const char * ap_name)
shm_flow_set_destroy(ai.fqset);
bmp_destroy(ai.fqueues);
bmp_destroy(ai.fds);
- return -1;
+ return -EIRMD;
}
ai.flows = malloc(sizeof(*ai.flows) * AP_MAX_FLOWS);
@@ -393,9 +393,9 @@ int flow_accept(qosspec_t * qs,
if (timeo != NULL) {
msg.has_timeo_sec = true;
- msg.has_timeo_usec = true;
+ msg.has_timeo_nsec = true;
msg.timeo_sec = timeo->tv_sec;
- msg.timeo_usec = timeo->tv_nsec / 1000;
+ msg.timeo_nsec = timeo->tv_nsec;
}
pthread_rwlock_rdlock(&ai.data_lock);
@@ -404,15 +404,21 @@ int flow_accept(qosspec_t * qs,
pthread_rwlock_unlock(&ai.data_lock);
- recv_msg = send_recv_irm_msg_b(&msg);
+ recv_msg = send_recv_irm_msg(&msg);
if (recv_msg == NULL)
return -EIRMD;
- if (recv_msg->has_result) {
+ if (!recv_msg->has_result) {
irm_msg__free_unpacked(recv_msg, NULL);
return -EIRMD;
}
+ if (recv_msg->result != 0) {
+ int res = recv_msg->result;
+ irm_msg__free_unpacked(recv_msg, NULL);
+ return res;
+ }
+
if (!recv_msg->has_api || !recv_msg->has_port_id) {
irm_msg__free_unpacked(recv_msg, NULL);
return -1;
@@ -496,9 +502,9 @@ int flow_alloc(const char * dst_name,
if (timeo != NULL) {
msg.has_timeo_sec = true;
- msg.has_timeo_usec = true;
+ msg.has_timeo_nsec = true;
msg.timeo_sec = timeo->tv_sec;
- msg.timeo_usec = timeo->tv_nsec / 1000;
+ msg.timeo_nsec = timeo->tv_nsec;
}
pthread_rwlock_rdlock(&ai.data_lock);
@@ -511,6 +517,17 @@ int flow_alloc(const char * dst_name,
if (recv_msg == NULL)
return -EIRMD;
+ if (!recv_msg->has_result) {
+ irm_msg__free_unpacked(recv_msg, NULL);
+ return -EIRMD;
+ }
+
+ if (recv_msg->result != 0) {
+ int res = recv_msg->result;
+ irm_msg__free_unpacked(recv_msg, NULL);
+ return res;
+ }
+
if (!recv_msg->has_api || !recv_msg->has_port_id) {
irm_msg__free_unpacked(recv_msg, NULL);
return -1;