summaryrefslogtreecommitdiff
path: root/src/lib/dev.c
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2016-12-28 00:36:36 +0100
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2016-12-28 01:05:20 +0100
commit314c5323d3a038394f43e84d72594b78d17b1a46 (patch)
tree5c82135181d99879725f59cc4c263e9ec4e95049 /src/lib/dev.c
parent6166259f74855fe9e6976175eeb7b16912bc477a (diff)
downloadouroboros-314c5323d3a038394f43e84d72594b78d17b1a46.tar.gz
ouroboros-314c5323d3a038394f43e84d72594b78d17b1a46.zip
include, lib: Report communication failure with the IRMd
An errno EIRMD has been added to errno.h to indicate failure to send a message tot the IRMd. The IRM tool will report such errors, which makes it easier for users to detect that the IRM was not started or has failed.
Diffstat (limited to 'src/lib/dev.c')
-rw-r--r--src/lib/dev.c42
1 files changed, 11 insertions, 31 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c
index 8eb98506..3a1df16d 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -176,7 +176,7 @@ static int api_announce(char * ap_name)
recv_msg = send_recv_irm_msg(&msg);
if (recv_msg == NULL) {
- return -1;
+ return -EIRMD;
}
if (!recv_msg->has_result || (ret = recv_msg->result)) {
@@ -359,7 +359,7 @@ int flow_accept(char ** ae_name, qosspec_t * qos)
recv_msg = send_recv_irm_msg_b(&msg);
if (recv_msg == NULL)
- return -1;
+ return -EIRMD;
if (!recv_msg->has_api || !recv_msg->has_port_id) {
irm_msg__free_unpacked(recv_msg, NULL);
@@ -465,7 +465,7 @@ int flow_alloc_resp(int fd, int response)
recv_msg = send_recv_irm_msg(&msg);
if (recv_msg == NULL)
- return -1;
+ return -EIRMD;
if (!recv_msg->has_result) {
irm_msg__free_unpacked(recv_msg, NULL);
@@ -476,16 +476,6 @@ int flow_alloc_resp(int fd, int response)
irm_msg__free_unpacked(recv_msg, NULL);
- if (response) {
- pthread_rwlock_rdlock(&ai.data_lock);
- pthread_rwlock_wrlock(&ai.flows_lock);
-
- reset_flow(fd);
-
- pthread_rwlock_unlock(&ai.flows_lock);
- pthread_rwlock_unlock(&ai.data_lock);
- }
-
return ret;
}
@@ -517,7 +507,7 @@ int flow_alloc(char * dst_name, char * src_ae_name, qosspec_t * qos)
recv_msg = send_recv_irm_msg(&msg);
if (recv_msg == NULL)
- return -1;
+ return -EIRMD;
if (!recv_msg->has_api || !recv_msg->has_port_id) {
irm_msg__free_unpacked(recv_msg, NULL);
@@ -603,27 +593,17 @@ int flow_alloc_res(int fd)
recv_msg = send_recv_irm_msg_b(&msg);
if (recv_msg == NULL)
- result = -1;
+ return -EIRMD;
if (!recv_msg->has_result) {
irm_msg__free_unpacked(recv_msg, NULL);
- result = -1;
+ return -1;
}
result = recv_msg->result;
irm_msg__free_unpacked(recv_msg, NULL);
- if (result) {
- pthread_rwlock_rdlock(&ai.data_lock);
- pthread_rwlock_wrlock(&ai.flows_lock);
-
- reset_flow(fd);
-
- pthread_rwlock_unlock(&ai.flows_lock);
- pthread_rwlock_unlock(&ai.data_lock);
- }
-
return result;
}
@@ -655,9 +635,9 @@ int flow_dealloc(int fd)
pthread_rwlock_unlock(&ai.flows_lock);
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 -1;
+ return -EIRMD;
if (!recv_msg->has_result) {
irm_msg__free_unpacked(recv_msg, NULL);
@@ -1208,7 +1188,7 @@ int ipcp_create_r(pid_t api)
recv_msg = send_recv_irm_msg(&msg);
if (recv_msg == NULL)
- return -1;
+ return -EIRMD;
if (recv_msg->has_result == false) {
irm_msg__free_unpacked(recv_msg, NULL);
@@ -1254,7 +1234,7 @@ int ipcp_flow_req_arr(pid_t api, char * dst_name, char * src_ae_name)
recv_msg = send_recv_irm_msg(&msg);
if (recv_msg == NULL)
- return -1;
+ return -EIRMD;
if (!recv_msg->has_port_id || !recv_msg->has_api) {
irm_msg__free_unpacked(recv_msg, NULL);
@@ -1336,7 +1316,7 @@ int ipcp_flow_alloc_reply(int fd, int response)
recv_msg = send_recv_irm_msg(&msg);
if (recv_msg == NULL)
- return -1;
+ return -EIRMD;
if (recv_msg->has_result == false) {
irm_msg__free_unpacked(recv_msg, NULL);