diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-12-08 19:28:41 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-12-08 19:28:41 +0100 |
commit | 718a400d599f3df3a64c2c0659a48fb9d22b6105 (patch) | |
tree | 48041ab3edec8580781fc37c201f6fb7e6794d51 /src/mds-registry | |
parent | no more goto fail (diff) | |
download | mds-718a400d599f3df3a64c2c0659a48fb9d22b6105.tar.gz mds-718a400d599f3df3a64c2c0659a48fb9d22b6105.tar.bz2 mds-718a400d599f3df3a64c2c0659a48fb9d22b6105.tar.xz |
m + make sure we never lose errno
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/mds-registry')
-rw-r--r-- | src/mds-registry/reexec.c | 18 | ||||
-rw-r--r-- | src/mds-registry/registry.c | 9 | ||||
-rw-r--r-- | src/mds-registry/slave.c | 7 |
3 files changed, 15 insertions, 19 deletions
diff --git a/src/mds-registry/reexec.c b/src/mds-registry/reexec.c index 6247e18..6b36cc8 100644 --- a/src/mds-registry/reexec.c +++ b/src/mds-registry/reexec.c @@ -202,20 +202,10 @@ int unmarshal_server(char* state_buf) mds_message_destroy(&received); if (stage >= 1) hash_table_destroy(®_table, (free_func*)reg_table_free_key, (free_func*)reg_table_free_value); - if (stage >= 2) - free(command); - if (stage >= 3) - { - client_list_destroy(list); - free(list); - } - if (stage >= 5) - linked_list_destroy(&slave_list); - if (stage >= 6) - { - slave_destroy(slave); - free(slave); - } + if (stage >= 2) free(command); + if (stage >= 3) client_list_destroy(list), free(list); + if (stage >= 5) linked_list_destroy(&slave_list); + if (stage >= 6) slave_destroy(slave), free(slave); abort(); return -1; } diff --git a/src/mds-registry/registry.c b/src/mds-registry/registry.c index b8a24ac..918b137 100644 --- a/src/mds-registry/registry.c +++ b/src/mds-registry/registry.c @@ -125,6 +125,8 @@ static int handle_close_message(void) */ static int registry_action_add(int has_key, char* command, size_t command_key, uint64_t client) { + int saved_errno; + if (has_key) { /* Add server to protocol if the protocol is already in the table. */ @@ -143,7 +145,7 @@ static int registry_action_add(int has_key, char* command, size_t command_key, u /* Duplicate the protocol name so it can be accessed later. */ if ((command = strdup(command)) == NULL) { - free(list); + saved_errno = errno, free(list), errno = saved_errno; fail_if (1); } /* Create list of servers, add server to list and add the protocol to the table. */ @@ -152,9 +154,11 @@ static int registry_action_add(int has_key, char* command, size_t command_key, u client_list_add(list, client) || (hash_table_put(®_table, command_key, (size_t)address) == 0)) { + saved_errno = errno; client_list_destroy(list); free(list); free(command); + errno = saved_errno; fail_if (1); } } @@ -210,6 +214,7 @@ static int registry_action_act(char* command, int action, uint64_t client, hash_ { size_t command_key = (size_t)(void*)command; int has_key = hash_table_contains_key(®_table, command_key); + int saved_errno; if (action == 1) { @@ -228,7 +233,7 @@ static int registry_action_act(char* command, int action, uint64_t client, hash_ if (hash_table_put(wait_set, command_key, 1) == 0) if (errno) { - free(command); + saved_errno = errno, free(command), errno = saved_errno; fail_if (1); } } diff --git a/src/mds-registry/slave.c b/src/mds-registry/slave.c index 8e29f17..54774e2 100644 --- a/src/mds-registry/slave.c +++ b/src/mds-registry/slave.c @@ -271,6 +271,7 @@ int advance_slaves(char* command) slave_t* slave_create(hash_table_t* restrict wait_set, const char* restrict recv_client_id, const char* restrict recv_message_id) { slave_t* restrict rc = NULL; + int saved_errno; fail_if (xmalloc(rc, 1, slave_t)); @@ -284,9 +285,9 @@ slave_t* slave_create(hash_table_t* restrict wait_set, const char* restrict recv return rc; pfail: - slave_destroy(rc); - free(rc); - return NULL; + saved_errno = errno; + slave_destroy(rc), free(rc); + return errno = saved_errno, NULL; } |