Skip to content

Commit 8513468

Browse files
ipuustinYogaraj-Alamenda
authored andcommitted
Fix multibuffer polling.
Multibuffer thread code never succeeded in joining the polling thread, because the polling thread didn't check thread-local keep_polling variable. This prevented multithreaded software using QAT engine from exiting. Fix a memory leak by matching ptread_key_create() with pthread_key_delete(). Also remove pthread_setspecific() call from thread destructor. Documentation specifies that the thread key value is set to NULL before destructor is called with the previously associated value. Signed-off-by: Ismo Puustinen <ismo.puustinen@intel.com> Signed-off-by: Yogaraj Alamenda <yogarajx.alamenda@intel.com>
1 parent 670839b commit 8513468

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

qat_sw_init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,6 @@ void mb_thread_local_destructor(void *tlv_ptr)
414414
} else {
415415
DEBUG("tlv NULL\n");
416416
}
417-
418-
pthread_setspecific(mb_thread_key, NULL);
419417
}
420418

421419
int multibuff_init(ENGINE *e)
@@ -461,5 +459,7 @@ int multibuff_finish_int(ENGINE *e, int reset_globals)
461459

462460
PRINT_RDTSC_AVERAGES();
463461

462+
ret = pthread_key_delete(mb_thread_key) == 0;
463+
464464
return ret;
465465
}

qat_sw_polling.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ void *multibuff_timer_poll_func(void *thread_ptr)
357357

358358
DEBUG("Polling Timeout %ld tlv %p\n", mb_poll_timeout_time.tv_nsec, tlv);
359359

360-
while (multibuff_keep_polling) {
360+
while (tlv->keep_polling && multibuff_keep_polling) {
361361
while ((sig = sigtimedwait((const sigset_t *)&tlv->set, NULL, &mb_poll_timeout_time)) == -1 &&
362362
errno == EINTR &&
363363
eintr_count < QAT_SW_NUM_EVENT_RETRIES) {

0 commit comments

Comments
 (0)