Applied a patch from Philip Guenther:
- assumed that pthread_create() and pthread_join() set errno. They don't: they return the error value instead
This commit is contained in:
@ -461,15 +461,17 @@ int oper_handler_init(void)
|
||||
|
||||
if (batch_mode)
|
||||
{
|
||||
int err;
|
||||
pthread_mutex_init(&batch_mutex, NULL);
|
||||
pthread_cond_init(&batch_cond, NULL);
|
||||
|
||||
/* Create batch thread */
|
||||
pthread_attr_init(&batch_attr);
|
||||
if (pthread_create(&batch_thread, &batch_attr, &batch_runner_proc, NULL)
|
||||
if ((err = pthread_create(&batch_thread, &batch_attr, &batch_runner_proc, NULL))
|
||||
!= 0)
|
||||
{
|
||||
log_errno(LOG_FATAL, "Batch thread creation failed");
|
||||
log_text(LOG_FATAL, "Batch thread creation failed, errno = %d (%s)",
|
||||
err, strerror(err));
|
||||
return 1;
|
||||
}
|
||||
batch_status = BATCH_STATUS_STOP;
|
||||
@ -561,15 +563,17 @@ int oper_handler_done(void)
|
||||
|
||||
if (batch_mode)
|
||||
{
|
||||
int err;
|
||||
/* Stop the batch thread */
|
||||
pthread_mutex_lock(&batch_mutex);
|
||||
batch_status = BATCH_STATUS_STOP;
|
||||
pthread_cond_signal(&batch_cond);
|
||||
pthread_mutex_unlock(&batch_mutex);
|
||||
|
||||
if (pthread_join(batch_thread, NULL))
|
||||
if ((err = pthread_join(batch_thread, NULL)))
|
||||
{
|
||||
log_errno(LOG_FATAL, "Batch thread join failed");
|
||||
log_text(LOG_FATAL, "Batch thread join failed, errno = %d (%s)",
|
||||
err, strerror(err));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@ -412,7 +412,8 @@ void *runner_thread(void *arg)
|
||||
int run_test(sb_test_t *test)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
int err;
|
||||
|
||||
/* initialize test */
|
||||
if (test->ops.init != NULL && test->ops.init() != 0)
|
||||
return 1;
|
||||
@ -461,10 +462,11 @@ int run_test(sb_test_t *test)
|
||||
{
|
||||
if (sb_globals.error)
|
||||
return 1;
|
||||
if (pthread_create(&(threads[i].thread), &thread_attr, &runner_thread,
|
||||
(void*)&(threads[i])) != 0)
|
||||
if ((err = pthread_create(&(threads[i].thread), &thread_attr, &runner_thread,
|
||||
(void*)&(threads[i]))) != 0)
|
||||
{
|
||||
log_errno(LOG_FATAL, "Thread #%d creation failed", i);
|
||||
log_text(LOG_FATAL, "Thread #%d creation failed, errno = %d (%s)",
|
||||
i, err, strerror(err));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -473,9 +475,10 @@ int run_test(sb_test_t *test)
|
||||
log_text(LOG_NOTICE, "Threads started!\n");
|
||||
for(i = 0; i < sb_globals.num_threads; i++)
|
||||
{
|
||||
if(pthread_join(threads[i].thread, NULL))
|
||||
if((err = pthread_join(threads[i].thread, NULL)) != 0)
|
||||
{
|
||||
log_errno(LOG_FATAL, "Thread #%d join failed", i);
|
||||
log_text(LOG_FATAL, "Thread #%d join failed, errno = %d (%s)",
|
||||
i, err, strerror(err));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user