|
@@ -506,9 +506,9 @@ static void *job_thread(void *arg)
|
|
|
for (;;) {
|
|
for (;;) {
|
|
|
xs *job = NULL;
|
|
xs *job = NULL;
|
|
|
|
|
|
|
|
- job_wait(&job);
|
|
|
|
|
|
|
+ p_state->th_state[pid] = THST_WAIT;
|
|
|
|
|
|
|
|
- srv_debug(2, xs_fmt("job thread %d wake up", pid));
|
|
|
|
|
|
|
+ job_wait(&job);
|
|
|
|
|
|
|
|
if (job == NULL) /* corrupted message? */
|
|
if (job == NULL) /* corrupted message? */
|
|
|
continue;
|
|
continue;
|
|
@@ -520,6 +520,8 @@ static void *job_thread(void *arg)
|
|
|
/* it's a socket */
|
|
/* it's a socket */
|
|
|
FILE *f = NULL;
|
|
FILE *f = NULL;
|
|
|
|
|
|
|
|
|
|
+ p_state->th_state[pid] = THST_IN;
|
|
|
|
|
+
|
|
|
xs_data_get(&f, job);
|
|
xs_data_get(&f, job);
|
|
|
|
|
|
|
|
if (f != NULL)
|
|
if (f != NULL)
|
|
@@ -527,10 +529,14 @@ static void *job_thread(void *arg)
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
/* it's a q_item */
|
|
/* it's a q_item */
|
|
|
|
|
+ p_state->th_state[pid] = THST_OUT;
|
|
|
|
|
+
|
|
|
process_queue_item(job);
|
|
process_queue_item(job);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ p_state->th_state[pid] = THST_STOP;
|
|
|
|
|
+
|
|
|
srv_debug(1, xs_fmt("job thread %d stopped", pid));
|
|
srv_debug(1, xs_fmt("job thread %d stopped", pid));
|
|
|
|
|
|
|
|
return NULL;
|
|
return NULL;
|
|
@@ -556,6 +562,8 @@ static void *background_thread(void *arg)
|
|
|
time_t t;
|
|
time_t t;
|
|
|
int cnt = 0;
|
|
int cnt = 0;
|
|
|
|
|
|
|
|
|
|
+ p_state->th_state[0] = THST_IN;
|
|
|
|
|
+
|
|
|
{
|
|
{
|
|
|
xs *list = user_list();
|
|
xs *list = user_list();
|
|
|
char *p, *uid;
|
|
char *p, *uid;
|
|
@@ -588,6 +596,8 @@ static void *background_thread(void *arg)
|
|
|
if (cnt == 0) {
|
|
if (cnt == 0) {
|
|
|
/* sleep 3 seconds */
|
|
/* sleep 3 seconds */
|
|
|
|
|
|
|
|
|
|
+ p_state->th_state[0] = THST_WAIT;
|
|
|
|
|
+
|
|
|
#ifdef USE_POLL_FOR_SLEEP
|
|
#ifdef USE_POLL_FOR_SLEEP
|
|
|
poll(NULL, 0, 3 * 1000);
|
|
poll(NULL, 0, 3 * 1000);
|
|
|
#else
|
|
#else
|
|
@@ -603,6 +613,8 @@ static void *background_thread(void *arg)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ p_state->th_state[0] = THST_STOP;
|
|
|
|
|
+
|
|
|
srv_log(xs_fmt("background thread stopped"));
|
|
srv_log(xs_fmt("background thread stopped"));
|
|
|
|
|
|
|
|
return NULL;
|
|
return NULL;
|