diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2014-12-03 20:30:25 +0100 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2014-12-03 20:30:25 +0100 |
commit | e7d346892881259a62386d18c14a7cf1ba9a916f (patch) | |
tree | 15966fc2a40c1a3b4fab71d1386713600c7e1b44 | |
parent | 5c214383ebb7efb088e184854ddd3a7530086c83 (diff) | |
download | biruda-e7d346892881259a62386d18c14a7cf1ba9a916f.tar.gz biruda-e7d346892881259a62386d18c14a7cf1ba9a916f.tar.bz2 |
handling worker state and mode
-rw-r--r-- | src/biruda.c | 4 | ||||
-rw-r--r-- | src/worker.c | 20 |
2 files changed, 21 insertions, 3 deletions
diff --git a/src/biruda.c b/src/biruda.c index ec48b26..b900fcc 100644 --- a/src/biruda.c +++ b/src/biruda.c @@ -65,7 +65,9 @@ static int test_config( const struct gengetopt_args_info *args_info ) static int conf_validate_worker_execution( cfg_t *cfg, cfg_opt_t *opt, const char *value, void *result ) { - if( strcmp( value, "direct" ) == 0 ) { + if( strcmp( value, "disabled" ) == 0 ) { + *(worker_execution_mode_t *)result = WORKER_EXECUTION_DISABLED; + } else if( strcmp( value, "direct" ) == 0 ) { *(worker_execution_mode_t *)result = WORKER_EXECUTION_DIRECT; } else { cfg_error( cfg, "invalid value for worker execution mode option '%s': %s", diff --git a/src/worker.c b/src/worker.c index 77ae401..70cb64b 100644 --- a/src/worker.c +++ b/src/worker.c @@ -152,8 +152,24 @@ static void *worker_func( void *thread_data ) int worker_init( worker_t *worker ) { - if( worker->state == WORKER_STATE_RUNNING ) { - return 0; + switch( worker->state ) { + case WORKER_STATE_RUNNING: + fprintf( stderr, "worker %s is already running\n", worker->name ); + return 0; + + case WORKER_STATE_STOPPED: + // execute, skip + break; + } + + switch( worker->mode ) { + case WORKER_EXECUTION_DIRECT: + // execute, skip + break; + + case WORKER_EXECUTION_DISABLED: + fprintf( stderr, "worker %s is disabled, won't execute\n", worker->name ); + return 0; } pthread_attr_t attr; |