summaryrefslogtreecommitdiff
path: root/src/webserver.c
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2014-12-04 19:35:19 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2014-12-04 19:35:19 +0100
commitaad5ac1625e6830bd63b57f646479883f06f7d88 (patch)
tree95561271f1981b214e7dec675e24cd107ee289f4 /src/webserver.c
parent720079063a4e97794dada308faac5834c0c2b067 (diff)
downloadbiruda-aad5ac1625e6830bd63b57f646479883f06f7d88.tar.gz
biruda-aad5ac1625e6830bd63b57f646479883f06f7d88.tar.bz2
added stopping of worker
Diffstat (limited to 'src/webserver.c')
-rw-r--r--src/webserver.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/webserver.c b/src/webserver.c
index 01dcd51..312105a 100644
--- a/src/webserver.c
+++ b/src/webserver.c
@@ -65,7 +65,11 @@ static int handle_request( void *cls, struct MHD_Connection *connection,
printf( "Got POST operation '%s'\n", op );
- if( op != NULL && strcmp( op, "start" ) == 0 ) {
+ if( op == NULL ) {
+ return MHD_NO;
+ }
+
+ if( strcmp( op, "start" ) == 0 ) {
const char *name = MHD_lookup_connection_value( connection, MHD_GET_ARGUMENT_KIND, "name" );
@@ -86,6 +90,28 @@ static int handle_request( void *cls, struct MHD_Connection *connection,
ret = MHD_queue_response( connection, ( res == 0 ) ? MHD_HTTP_OK : MHD_HTTP_INTERNAL_SERVER_ERROR, response );
MHD_destroy_response( response );
}
+ } else if( strcmp( op, "stop" ) == 0 ) {
+
+ const char *name = MHD_lookup_connection_value( connection, MHD_GET_ARGUMENT_KIND, "name" );
+
+ if( name != NULL ) {
+
+ printf( "Got POST parameter for stopping a worker with name '%s'\n", name );
+
+ int res = master_stop_worker( name );
+
+ if( res < 0 ) {
+ snprintf( biruda_msg, sizeof( biruda_msg ), "Queueing stop request message failed\n" );
+ } else {
+ snprintf( biruda_msg, sizeof( biruda_msg ), "Queued stop worker request\n" );
+ }
+
+ response = MHD_create_response_from_buffer( strlen( biruda_msg ),
+ (void *)biruda_msg, MHD_RESPMEM_MUST_COPY );
+ ret = MHD_queue_response( connection, ( res == 0 ) ? MHD_HTTP_OK : MHD_HTTP_INTERNAL_SERVER_ERROR, response );
+ MHD_destroy_response( response );
+ }
+
} else {
return MHD_NO;
}