changeset 97:2fcbd483c1c3

client: bail on error Instead of blindly plowing through whatever errors we may encounter, preform an orderly exit. Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Sat, 17 Oct 2015 11:48:44 -0400
parents e76e3ee73fb5
children 366635b72c32
files src/client/main.c
diffstat 1 files changed, 23 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/client/main.c	Sat Oct 17 11:33:05 2015 -0400
+++ b/src/client/main.c	Sat Oct 17 11:48:44 2015 -0400
@@ -24,6 +24,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 
+#include <nomad/error.h>
 #include <nomad/types.h>
 #include <nomad/objstore.h>
 #include <nomad/connsvc.h>
@@ -49,19 +50,36 @@
 	 * generated randomly.
 	 */
 	nomad_set_local_node_id(0xabba);
+
 	ret = objstore_init();
+	if (ret) {
+		fprintf(stderr, "objstore_init() = %d (%s)\n", ret,
+			strerror(ret));
 
-	fprintf(stderr, "objstore_init() = %d\n", ret);
+		if (ret == ENOENT)
+			fprintf(stderr, "Did you set LD_LIBRARY_PATH?\n");
+
+		goto err;
+	}
 
 	store = objstore_store_create("abc", OS_MODE_STORE);
+	fprintf(stderr, "store = %p\n", store);
 
-	fprintf(stderr, "store = %p\n", store);
+	if (IS_ERR(store)) {
+		ret = PTR_ERR(store);
+		fprintf(stderr, "error: %s\n", strerror(ret));
+		goto err_objstore;
+	}
 
 	ret = connsvc(NULL, CLIENT_DAEMON_PORT, process_connection, store);
 
-	fprintf(stderr, "connsvc() = %d\n", ret);
+	fprintf(stderr, "connsvc() = %d (%s)\n", ret, strerror(ret));
+
+	/* XXX: undo objstore_store_create() */
 
-	abort();
+err_objstore:
+	/* XXX: undo objstore_init() */
 
-	return 0;
+err:
+	return ret;
 }