summaryrefslogtreecommitdiff
path: root/src/worker.c
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2014-11-30 16:42:35 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2014-11-30 16:42:35 +0100
commit55f9c3d2f3320917dba48c4c532c54483a0bce2b (patch)
treed28cac3ffca7e4467390149f15073d0530e730c8 /src/worker.c
parent1cb35fad9924bfa1ae33a6e6aff2e6c5d5b5f454 (diff)
downloadbiruda-55f9c3d2f3320917dba48c4c532c54483a0bce2b.tar.gz
biruda-55f9c3d2f3320917dba48c4c532c54483a0bce2b.tar.bz2
updating worker state now in master from coordinator state messages
Diffstat (limited to 'src/worker.c')
-rw-r--r--src/worker.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/worker.c b/src/worker.c
index f70f84b..06ecc7e 100644
--- a/src/worker.c
+++ b/src/worker.c
@@ -21,6 +21,15 @@ const char *worker_exection_mode_str( worker_execution_mode_t mode )
}
}
+const char *worker_state_str( worker_state_t state )
+{
+ switch( state ) {
+ case WORKER_STATE_STOPPED: return "stopped";
+ case WORKER_STATE_RUNNING: return "running";
+ default: return "<unknown>";
+ }
+}
+
worker_execution_mode_t worker_execution_mode_from_str( const char *s )
{
if( strcasecmp( s, "disabled" ) == 0 ) {
@@ -33,6 +42,18 @@ worker_execution_mode_t worker_execution_mode_from_str( const char *s )
}
}
+worker_state_t worker_state_from_str( const char *s )
+{
+ if( strcasecmp( s, "stopped" ) == 0 ) {
+ return WORKER_STATE_STOPPED;
+ } else if( strcasecmp( s, "running" ) == 0 ) {
+ return WORKER_STATE_RUNNING;
+ } else {
+ fprintf( stderr, "Warning: unknown worker state '%s' (assuming 'stopped')!\n", s );
+ return WORKER_STATE_STOPPED;
+ }
+}
+
typedef struct {
GPid pid;
gint out, err;
@@ -52,6 +73,8 @@ int worker_init( worker_t *worker )
g_error( "Starting worker failed" );
return -1;
}
+
+ worker->state = WORKER_STATE_RUNNING;
return 0;
}
@@ -65,6 +88,7 @@ void worker_terminate( worker_t *worker )
#else
#error TODO kill on Windows
#endif
+ worker->state = WORKER_STATE_STOPPED;
free( worker->execution_data );
worker->execution_data = NULL;
}