diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/dev.c | 42 | ||||
-rw-r--r-- | src/lib/irm.c | 25 | ||||
-rw-r--r-- | src/tools/irm/irm.c | 22 | ||||
-rw-r--r-- | src/tools/irm/irm_bind_ap.c | 4 |
4 files changed, 43 insertions, 50 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); diff --git a/src/lib/irm.c b/src/lib/irm.c index 0d9d0f86..969a78c3 100644 --- a/src/lib/irm.c +++ b/src/lib/irm.c @@ -47,7 +47,7 @@ pid_t irm_create_ipcp(char * name, 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); @@ -75,7 +75,7 @@ int irm_destroy_ipcp(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); @@ -147,9 +147,8 @@ int irm_bootstrap_ipcp(pid_t api, } recv_msg = send_recv_irm_msg(&msg); - if (recv_msg == NULL) { - return -1; - } + if (recv_msg == NULL) + return -EIRMD; if (recv_msg->has_result == false) { irm_msg__free_unpacked(recv_msg, NULL); @@ -179,7 +178,7 @@ ssize_t irm_list_ipcps(char * name, recv_msg = send_recv_irm_msg(&msg); if (recv_msg == NULL) { free(msg.dif_name); - return -1; + return -EIRMD; } if (recv_msg->apis == NULL) { @@ -227,7 +226,7 @@ int irm_enroll_ipcp(pid_t api, recv_msg = send_recv_irm_msg(&msg); if (recv_msg == NULL) { free(msg.dif_name); - return -1; + return -EIRMD; } if (recv_msg->has_result == false) { @@ -362,7 +361,7 @@ int irm_bind_ap(char * ap, free(full_ap_name); if (recv_msg == NULL) - return -1; + return -EIRMD; if (recv_msg->has_result == false) { irm_msg__free_unpacked(recv_msg, NULL); @@ -391,7 +390,7 @@ int irm_bind_api(pid_t api, char * name) 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); @@ -419,7 +418,7 @@ int irm_unbind_ap(char * ap, char * name) 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); @@ -448,7 +447,7 @@ int irm_unbind_api(pid_t api, char * name) 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); @@ -481,7 +480,7 @@ int irm_reg(char * name, 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); @@ -515,7 +514,7 @@ int irm_unreg(char * name, 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); diff --git a/src/tools/irm/irm.c b/src/tools/irm/irm.c index 7b2f3331..ce92d3d5 100644 --- a/src/tools/irm/irm.c +++ b/src/tools/irm/irm.c @@ -20,12 +20,15 @@ */ #include <ouroboros/irm.h> -#include <stdio.h> -#include <string.h> +#include <ouroboros/errno.h> #include "irm_ops.h" #include "irm_utils.h" +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + static void usage(void) { printf("Usage: irm [OPERATION]\n\n" @@ -71,12 +74,23 @@ static int do_cmd(const char * argv0, return -1; } -int main(int argc, char ** argv) { +int main(int argc, char ** argv) +{ + int ret = 0; if (argc < 2) { usage(); return -1; } - return do_cmd(argv[1], argc - 1, argv + 1); + ret = do_cmd(argv[1], argc - 1, argv + 1); + + if (ret == -EIRMD) + printf("Failed to communicate with the " + "Ouroboros IPC Resource Manager daemon.\n"); + + if (ret) + exit(EXIT_FAILURE); + + exit(EXIT_SUCCESS); } diff --git a/src/tools/irm/irm_bind_ap.c b/src/tools/irm/irm_bind_ap.c index e8e5eb26..a5be5a03 100644 --- a/src/tools/irm/irm_bind_ap.c +++ b/src/tools/irm/irm_bind_ap.c @@ -90,13 +90,13 @@ int do_bind_ap(int argc, char ** argv) ret = irm_bind_ap(ap_name, name, flags, argc, argv); if (ret == -ENOENT) { printf("%s does not exist.\n", ap_name); - return -1; + return ret; } if (ret == -EPERM) { printf("Cannot execute %s, please check permissions.\n", ap_name); - return -1; + return ret; } if (temp != NULL) |