aboutsummaryrefslogtreecommitdiffstats
path: root/src/mds-server/slavery.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-12-09 03:42:16 +0100
committerMattias Andrée <maandree@operamail.com>2014-12-09 03:42:16 +0100
commit8b69e6f4f9e239e660b26695c6a7f5007fcadf4e (patch)
treefb80b3ef0e017ca36568da6312c292c479122a27 /src/mds-server/slavery.c
parentwith a few exceptions and some remaining files, never return directly on failure, always goto fail by invoking fail_if (diff)
downloadmds-8b69e6f4f9e239e660b26695c6a7f5007fcadf4e.tar.gz
mds-8b69e6f4f9e239e660b26695c6a7f5007fcadf4e.tar.bz2
mds-8b69e6f4f9e239e660b26695c6a7f5007fcadf4e.tar.xz
with a few exceptions, never return directly on failure, always goto fail by invoking fail_if
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/mds-server/slavery.c')
-rw-r--r--src/mds-server/slavery.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/mds-server/slavery.c b/src/mds-server/slavery.c
index 7ff801d..cf5e45d 100644
--- a/src/mds-server/slavery.c
+++ b/src/mds-server/slavery.c
@@ -47,11 +47,15 @@ void* slave_loop(void*);
int fetch_message(client_t* client)
{
int r = mds_message_read(&(client->message), client->socket_fd);
+
if (r == 0)
return 0;
if (r == -2)
- eprint("corrupt message received.");
+ {
+ eprint("corrupt message received.");
+ fail_if (1);
+ }
else if (errno == ECONNRESET)
{
r = mds_message_read(&(client->message), client->socket_fd);
@@ -60,11 +64,14 @@ int fetch_message(client_t* client)
}
else if (errno != EINTR)
{
- r = -2;
xperror(*argv);
+ fail_if (1);
}
+ fail_if (r == -2);
return r;
+ fail:
+ return -2;
}
@@ -81,14 +88,16 @@ int create_slave(pthread_t* thread_slot, int slave_fd)
{
xperror(*argv);
with_mutex (slave_mutex, running_slaves--;);
- return -1;
+ fail_if (1);
}
if ((errno = pthread_detach(*thread_slot)))
{
xperror(*argv);
- return -1;
+ fail_if (1);
}
return 0;
+ fail:
+ return -1;
}
@@ -96,7 +105,7 @@ int create_slave(pthread_t* thread_slot, int slave_fd)
* Initialise a client, except for threading
*
* @param client_fd The file descriptor of the client's socket
- * @return The client information, NULL on error
+ * @return The client information, `NULL` on error
*/
client_t* initialise_client(int client_fd)
{