aboutsummaryrefslogtreecommitdiffstats
path: root/src/mds-registry/mds-registry.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-12-09 13:15:10 +0100
committerMattias Andrée <maandree@operamail.com>2014-12-09 13:15:10 +0100
commit7a994c9631c590d6a73c842fa5d2d3567b4771dd (patch)
tree228ade01f99ba217151a0ed20f29c5f3a5028619 /src/mds-registry/mds-registry.c
parentmds-kbdc: compile-layout: macro_call: fix bug: do not duplicate the arguments if there are none (diff)
parentreport an error, rather than causing failure the caller but not for the called function (diff)
downloadmds-7a994c9631c590d6a73c842fa5d2d3567b4771dd.tar.gz
mds-7a994c9631c590d6a73c842fa5d2d3567b4771dd.tar.bz2
mds-7a994c9631c590d6a73c842fa5d2d3567b4771dd.tar.xz
merge track-errors and resolve conflict
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/mds-registry/mds-registry.c')
-rw-r--r--src/mds-registry/mds-registry.c44
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(&reg_table, 32))
- {
- xperror(*argv);
- hash_table_destroy(&reg_table, NULL, NULL);
- return 1;
- }
+ fail_if (full_send(message, strlen(message))); stage++;
+ fail_if (hash_table_create_tuned(&reg_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(&reg_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)