core: warning when a task is pushed but no workers
authorDaniel-Constantin Mierla <miconda@gmail.com>
Thu, 9 Nov 2017 05:42:49 +0000 (06:42 +0100)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Thu, 9 Nov 2017 05:42:49 +0000 (06:42 +0100)
- helper functions to get the number of workers

src/core/async_task.c
src/core/async_task.h

index 956bd9a..ab2376a 100644 (file)
@@ -50,6 +50,25 @@ static int _async_task_usleep = 0;
 
 int async_task_run(int idx);
 
+/**
+ *
+ */
+int async_task_workers_get(void)
+{
+       return _async_task_workers;
+}
+
+/**
+ *
+ */
+int async_task_workers_active(void)
+{
+       if(_async_task_workers<=0)
+               return 0;
+
+       return 1;
+}
+
 /**
  *
  */
@@ -195,8 +214,10 @@ int async_task_push(async_task_t *task)
 {
        int len;
 
-       if(_async_task_workers<=0)
+       if(_async_task_workers<=0) {
+               LM_WARN("async task pushed, but no async workers - ignoring\n");
                return 0;
+       }
 
        len = write(_async_task_sockets[1], &task, sizeof(async_task_t*));
        if(len<=0) {
index 620009b..55c558c 100644 (file)
@@ -37,5 +37,7 @@ int async_task_initialized(void);
 int async_task_set_workers(int n);
 int async_task_push(async_task_t *task);
 int async_task_set_usleep(int n);
+int async_task_workers_get(void);
+int async_task_workers_active(void);
 
 #endif