diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2014-12-04 19:35:19 +0100 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2014-12-04 19:35:19 +0100 |
commit | aad5ac1625e6830bd63b57f646479883f06f7d88 (patch) | |
tree | 95561271f1981b214e7dec675e24cd107ee289f4 /src/master.c | |
parent | 720079063a4e97794dada308faac5834c0c2b067 (diff) | |
download | biruda-aad5ac1625e6830bd63b57f646479883f06f7d88.tar.gz biruda-aad5ac1625e6830bd63b57f646479883f06f7d88.tar.bz2 |
added stopping of worker
Diffstat (limited to 'src/master.c')
-rw-r--r-- | src/master.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/master.c b/src/master.c index d7bc64c..9a35a73 100644 --- a/src/master.c +++ b/src/master.c @@ -217,6 +217,25 @@ static char *create_start_request( const char *name ) return res; } +static char *create_stop_request( const char *name ) +{ + json_object *obj = json_object_new_object( ); + json_object *op = json_object_new_string( "stop" ); + json_object_object_add( obj, "op", op ); + json_object *role = json_object_new_string( "master" ); + json_object_object_add( obj, "role", role ); + json_object *worker = json_object_new_string( name ); + json_object_object_add( obj, "worker", worker ); + + /* produce message as string, caller must free it */ + const char *msg = json_object_to_json_string( obj ); + char *res = alloc_message( msg ); + + json_object_put( obj ); + + return res; +} + #define MAX_NOF_COMMANDS 12 static int nof_queued_commands = 0; @@ -408,3 +427,11 @@ int master_start_worker( const char *name ) return res; } + +int master_stop_worker( const char *name ) +{ + char *msg = create_stop_request( name ); + int res = enqueue_request( msg ); + + return res; +} |