diff options
Diffstat (limited to 'src/mds-registry/mds-registry.c')
-rw-r--r-- | src/mds-registry/mds-registry.c | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/src/mds-registry/mds-registry.c b/src/mds-registry/mds-registry.c index 741423c..4b49525 100644 --- a/src/mds-registry/mds-registry.c +++ b/src/mds-registry/mds-registry.c @@ -66,7 +66,7 @@ int preinitialise_server(void) return 0; - pfail: + fail: xperror(*argv); if (stage >= 1) pthread_mutex_destroy(&slave_mutex); if (stage >= 2) pthread_cond_destroy(&slave_cond); @@ -82,6 +82,7 @@ int preinitialise_server(void) */ int initialise_server(void) { + int stage = 0; const char* const message = "Command: intercept\n" "Message ID: 0\n" @@ -103,23 +104,20 @@ int initialise_server(void) that happen between the crash and the recovery. */ - if (full_send(message, strlen(message))) - return 1; - if (hash_table_create_tuned(®_table, 32)) - { - xperror(*argv); - hash_table_destroy(®_table, NULL, NULL); - return 1; - } + fail_if (full_send(message, strlen(message))); stage++; + fail_if (hash_table_create_tuned(®_table, 32)); stage++; reg_table.key_comparator = (compare_func*)string_comparator; reg_table.hasher = (hash_func*)string_hash; fail_if (server_initialised() < 0); fail_if (mds_message_initialise(&received)); return 0; - pfail: + fail: xperror(*argv); - mds_message_destroy(&received); + if (stage == 1) + hash_table_destroy(®_table, NULL, NULL); + if (stage == 2) + mds_message_destroy(&received); return 1; } @@ -135,13 +133,12 @@ int postinitialise_server(void) if (connected) return 0; - if (reconnect_to_display()) - { - mds_message_destroy(&received); - return 1; - } + fail_if (reconnect_to_display()); connected = 1; return 0; + fail: + mds_message_destroy(&received); + return 1; } @@ -171,27 +168,26 @@ int master_loop(void) if (r == -2) { eprint("corrupt message received, aborting."); - goto fail; + goto done; } else if (errno == EINTR) continue; - else if (errno != ECONNRESET) - goto pfail; + else + fail_if (errno != ECONNRESET); eprint("lost connection to server."); mds_message_destroy(&received); mds_message_initialise(&received); connected = 0; - if (reconnect_to_display()) - goto fail; + fail_if (reconnect_to_display()); connected = 1; } rc = 0; - goto fail; - pfail: - xperror(*argv); + goto done; fail: + xperror(*argv); + done: /* Join with all slaves threads. */ with_mutex (slave_mutex, while (running_slaves > 0) |