summaryrefslogtreecommitdiff
path: root/src/lib/dev.c
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-10-14 11:32:22 +0000
committerSander Vrijders <sander.vrijders@ugent.be>2017-10-14 11:32:22 +0000
commitbf1602c915dee8bd6cbb69aba1fe88619b9c0eed (patch)
tree8c93fcb67d61ca40b060f9c9ea1b62389f247dbd /src/lib/dev.c
parent1888c137a8ff315bc549c16740aa727da8c666f5 (diff)
parentbedd1d4eadde9ab64f924c69eba716b015599e67 (diff)
downloadouroboros-bf1602c915dee8bd6cbb69aba1fe88619b9c0eed.tar.gz
ouroboros-bf1602c915dee8bd6cbb69aba1fe88619b9c0eed.zip
Merged in dstaesse/ouroboros/be-deprecate-ouroboros-init-fini (pull request #626)
Be deprecate ouroboros init fini
Diffstat (limited to 'src/lib/dev.c')
-rw-r--r--src/lib/dev.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c
index e6e5b4d4..85dbfb0a 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -595,11 +595,16 @@ static int flow_init(int port_id,
return fd;
}
-int ouroboros_init(const char * ap_name)
+__attribute__((constructor)) static void init(int argc,
+ char ** argv,
+ char ** envp)
{
- int i;
- int j;
- int ret = -ENOMEM;
+ const char * ap_name = argv[0];
+ int i;
+ int j;
+
+ (void) argc;
+ (void) envp;
assert(ai.ap_name == NULL);
@@ -618,10 +623,8 @@ int ouroboros_init(const char * ap_name)
goto fail_fqset;
ai.rdrb = shm_rdrbuff_open();
- if (ai.rdrb == NULL) {
- ret = -EIRMD;
+ if (ai.rdrb == NULL)
goto fail_rdrb;
- }
ai.flows = malloc(sizeof(*ai.flows) * AP_MAX_FLOWS);
if (ai.flows == NULL)
@@ -651,10 +654,8 @@ int ouroboros_init(const char * ap_name)
if (ai.ap_name == NULL)
goto fail_ap_name;
- if (api_announce((char *) ai.ap_name)) {
- ret = -EIRMD;
+ if (api_announce((char *) ai.ap_name))
goto fail_announce;
- }
}
for (i = 0; i < SYS_MAX_FLOWS; ++i) {
@@ -680,7 +681,7 @@ int ouroboros_init(const char * ap_name)
if (ai.tw == NULL)
goto fail_timerwheel;
- return 0;
+ return;
fail_timerwheel:
pthread_rwlock_destroy(&ai.lock);
@@ -710,10 +711,12 @@ int ouroboros_init(const char * ap_name)
fail_fqueues:
bmp_destroy(ai.fds);
fail_fds:
- return ret;
+ fprintf(stderr, "FATAL: ouroboros-dev init failed. "
+ "Make sure an IRMd is running.\n\n");
+ exit(EXIT_FAILURE);
}
-void ouroboros_fini()
+__attribute__((destructor)) static void fini(void)
{
int i = 0;