cleanup killing threads. As a consequence fixes invalid read/writes in tmqh flow

remotes/origin/HEAD
Anoop Saldanha 14 years ago committed by Victor Julien
parent f0e4578640
commit fea6a426a5

@ -1395,18 +1395,6 @@ void TmThreadKillThread(ThreadVars *tv)
TmThreadsSetFlag(tv, THV_KILL);
TmThreadsSetFlag(tv, THV_DEINIT);
if (tv->inq != NULL) {
/* signal the queue for the number of users */
if (tv->InShutdownHandler != NULL) {
tv->InShutdownHandler(tv);
}
for (i = 0; i < (tv->inq->reader_cnt + tv->inq->writer_cnt); i++) {
if (tv->inq->q_type == 0)
SCCondSignal(&trans_q[tv->inq->id].cond_q);
else
SCCondSignal(&data_queues[tv->inq->id].cond_q);
}
/* to be sure, signal more */
int cnt = 0;
while (1) {
@ -1420,17 +1408,23 @@ void TmThreadKillThread(ThreadVars *tv)
if (tv->InShutdownHandler != NULL) {
tv->InShutdownHandler(tv);
}
if (tv->inq != NULL) {
for (i = 0; i < (tv->inq->reader_cnt + tv->inq->writer_cnt); i++) {
if (tv->inq->q_type == 0)
SCCondSignal(&trans_q[tv->inq->id].cond_q);
else
SCCondSignal(&data_queues[tv->inq->id].cond_q);
}
usleep(100);
}
SCLogDebug("signalled tv->inq->id %" PRIu32 "", tv->inq->id);
}
if (tv->cond != NULL ) {
pthread_cond_broadcast(tv->cond);
}
usleep(100);
}
if (tv->outctx != NULL) {
Tmqh *tmqh = TmqhGetQueueHandlerByName(tv->outqh_name);
if (tmqh == NULL)
@ -1441,20 +1435,6 @@ void TmThreadKillThread(ThreadVars *tv)
}
}
if (tv->cond != NULL ) {
int cnt = 0;
while (1) {
if (TmThreadsCheckFlag(tv, THV_CLOSED)) {
SCLogDebug("signalled the thread %" PRId32 " times", cnt);
break;
}
cnt++;
pthread_cond_broadcast(tv->cond);
usleep(100);
}
}
/* join it */
pthread_join(tv->t, NULL);
SCLogDebug("thread %s stopped", tv->name);

Loading…
Cancel
Save