diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-08-02 21:34:22 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-08-02 21:34:22 +0200 |
commit | 70c2d0af540ecc44a104abb034ee5ff1c910dd48 (patch) | |
tree | 9a5c2deb9caf865245f1fd7d6a84eae73958d6c5 /src/mds-registry/slave.c | |
parent | mds-registry: notify client (diff) | |
download | mds-70c2d0af540ecc44a104abb034ee5ff1c910dd48.tar.gz mds-70c2d0af540ecc44a104abb034ee5ff1c910dd48.tar.bz2 mds-70c2d0af540ecc44a104abb034ee5ff1c910dd48.tar.xz |
mds-registry: marshal and unmarshal the slave list
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/mds-registry/slave.c')
-rw-r--r-- | src/mds-registry/slave.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/mds-registry/slave.c b/src/mds-registry/slave.c index 6c5406d..27d054a 100644 --- a/src/mds-registry/slave.c +++ b/src/mds-registry/slave.c @@ -112,6 +112,33 @@ static void* slave_loop(void* data) /** + * Start a slave thread with an already created slave + * + * @param slave The slave + * @return Non-zero on error, `errno` will be set accordingly + */ +int start_created_slave(slave_t* restrict slave) +{ + if ((errno = pthread_mutex_lock(&slave_mutex))) + return -1; + + if ((errno = pthread_create(&(slave->thread), NULL, slave_loop, (void*)(intptr_t)slave))) + { + pthread_mutex_unlock(&slave_mutex); + return -1; + } + + if ((errno = pthread_detach(slave->thread))) + xperror(*argv); + + running_slaves++; + pthread_mutex_unlock(&slave_mutex); + + return 0; +} + + +/** * Start a slave thread * * @param wait_set Set of protocols for which to wait that they become available |