mirror of
https://github.com/simon987/sist2.git
synced 2025-04-19 18:26:43 +00:00
parent
33ae585879
commit
660fbf75d8
12
src/tpool.c
12
src/tpool.c
@ -77,14 +77,14 @@ static void worker_thread_loop(tpool_t *pool) {
|
|||||||
job_t *job = database_get_work(ProcData.ipc_db, pool->shm->job_type);
|
job_t *job = database_get_work(ProcData.ipc_db, pool->shm->job_type);
|
||||||
|
|
||||||
if (job != NULL) {
|
if (job != NULL) {
|
||||||
pthread_mutex_lock(&(pool->shm->data_mutex));
|
|
||||||
pool->shm->busy_count += 1;
|
|
||||||
pthread_mutex_unlock(&(pool->shm->data_mutex));
|
|
||||||
|
|
||||||
if (pool->shm->stop) {
|
if (pool->shm->stop) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pthread_mutex_lock(&(pool->shm->data_mutex));
|
||||||
|
pool->shm->busy_count += 1;
|
||||||
|
pthread_mutex_unlock(&(pool->shm->data_mutex));
|
||||||
|
|
||||||
if (job->type == JOB_PARSE_JOB) {
|
if (job->type == JOB_PARSE_JOB) {
|
||||||
parse(job->parse_job);
|
parse(job->parse_job);
|
||||||
} else if (job->type == JOB_BULK_LINE) {
|
} else if (job->type == JOB_BULK_LINE) {
|
||||||
@ -200,11 +200,11 @@ static void *tpool_worker(void *arg) {
|
|||||||
pool->shm->ipc_ctx.completed_job_count += 1;
|
pool->shm->ipc_ctx.completed_job_count += 1;
|
||||||
pthread_mutex_unlock(&(pool->shm->ipc_ctx.mutex));
|
pthread_mutex_unlock(&(pool->shm->ipc_ctx.mutex));
|
||||||
|
|
||||||
|
if (WIFSIGNALED(status)) {
|
||||||
pthread_mutex_lock(&(pool->shm->data_mutex));
|
pthread_mutex_lock(&(pool->shm->data_mutex));
|
||||||
pool->shm->busy_count -= 1;
|
pool->shm->busy_count -= 1;
|
||||||
pthread_mutex_unlock(&(pool->shm->data_mutex));
|
pthread_mutex_unlock(&(pool->shm->data_mutex));
|
||||||
|
|
||||||
if (WIFSIGNALED(status)) {
|
|
||||||
int crashed_thread_id = -1;
|
int crashed_thread_id = -1;
|
||||||
for (int i = 0; i < MAX_THREADS; i++) {
|
for (int i = 0; i < MAX_THREADS; i++) {
|
||||||
if (pool->shm->thread_id_to_pid_mapping[i] == pid) {
|
if (pool->shm->thread_id_to_pid_mapping[i] == pid) {
|
||||||
@ -265,7 +265,7 @@ void tpool_wait(tpool_t *pool) {
|
|||||||
if (pool->shm->ipc_ctx.job_count > 0) {
|
if (pool->shm->ipc_ctx.job_count > 0) {
|
||||||
pthread_cond_wait(&(pool->shm->done_working_cond), &pool->shm->mutex);
|
pthread_cond_wait(&(pool->shm->done_working_cond), &pool->shm->mutex);
|
||||||
} else {
|
} else {
|
||||||
if (pool->shm->ipc_ctx.job_count == 0 && pool->shm->busy_count == 0) {
|
if (pool->shm->ipc_ctx.job_count == 0 && pool->shm->busy_count <= 0) {
|
||||||
pool->shm->stop = TRUE;
|
pool->shm->stop = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user