From: Guus Sliepen Date: Wed, 30 Jul 2014 15:06:47 +0000 (+0200) Subject: Add missing meshlink_errnos in meshlink_start(). X-Git-Url: http://git.meshlink.io/?a=commitdiff_plain;h=0334735f0ff7fc3fc004aaf91e8a19b9709f7289;p=meshlink Add missing meshlink_errnos in meshlink_start(). --- diff --git a/src/meshlink.c b/src/meshlink.c index e5ff36f0..e4061f93 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -783,12 +783,15 @@ meshlink_handle_t *meshlink_open(const char *confbase, const char *name) { if(access(filename, R_OK)) { if(errno == ENOENT) { // If not, create it - if(!meshlink_setup(mesh)) + if(!meshlink_setup(mesh)) { // meshlink_errno is set by meshlink_setup() return NULL; + } } else { fprintf(stderr, "Cannot not read from %s: %s\n", filename, strerror(errno)); - return meshlink_close(mesh), NULL; + meshlink_close(mesh); + meshlink_errno = MESHLINK_ESTORAGE; + return NULL; } } @@ -796,8 +799,11 @@ meshlink_handle_t *meshlink_open(const char *confbase, const char *name) { init_configuration(&mesh->config); - if(!read_server_config(mesh)) - return meshlink_close(mesh), NULL; + if(!read_server_config(mesh)) { + meshlink_close(mesh); + meshlink_errno = MESHLINK_ESTORAGE; + return NULL; + }; #ifdef HAVE_MINGW struct WSAData wsa_state; @@ -807,8 +813,11 @@ meshlink_handle_t *meshlink_open(const char *confbase, const char *name) { // Setup up everything // TODO: we should not open listening sockets yet - if(!setup_network(mesh)) - return meshlink_close(mesh), NULL; + if(!setup_network(mesh)) { + meshlink_close(mesh); + meshlink_errno = MESHLINK_ENETWORK; + return NULL; + } return mesh; }