|
@@ -159,21 +159,38 @@ namespace {
|
|
|
|
|
|
}
|
|
|
|
|
|
+gearmand_thread_st::gearmand_thread_st(gearmand_st& gearmand_):
|
|
|
+ is_thread_lock(false),
|
|
|
+ is_wakeup_event(false),
|
|
|
+ count(0),
|
|
|
+ dcon_count(0),
|
|
|
+ dcon_add_count(0),
|
|
|
+ free_dcon_count(0),
|
|
|
+ _gearmand(gearmand_),
|
|
|
+ next(NULL),
|
|
|
+ prev(NULL),
|
|
|
+ base(NULL),
|
|
|
+ dcon_list(NULL),
|
|
|
+ dcon_add_list(NULL),
|
|
|
+ free_dcon_list(0)
|
|
|
+{
|
|
|
+}
|
|
|
+
|
|
|
/** @} */
|
|
|
|
|
|
/*
|
|
|
* Public definitions
|
|
|
*/
|
|
|
|
|
|
-gearmand_error_t gearmand_thread_create(gearmand_st *gearmand)
|
|
|
+gearmand_error_t gearmand_thread_create(gearmand_st& gearmand)
|
|
|
{
|
|
|
- gearmand_thread_st* thread= new (std::nothrow) gearmand_thread_st;
|
|
|
+ gearmand_thread_st* thread= new (std::nothrow) gearmand_thread_st(gearmand);
|
|
|
if (thread == NULL)
|
|
|
{
|
|
|
return gearmand_merror("new", gearmand_thread_st, 1);
|
|
|
}
|
|
|
|
|
|
- if (! gearman_server_thread_init(gearmand_server(gearmand), &(thread->server_thread),
|
|
|
+ if (! gearman_server_thread_init(gearmand_server(&gearmand), &(thread->server_thread),
|
|
|
_log, thread, gearmand_connection_watch))
|
|
|
{
|
|
|
delete thread;
|
|
@@ -198,9 +215,9 @@ gearmand_error_t gearmand_thread_create(gearmand_st *gearmand)
|
|
|
|
|
|
/* If we have no threads, we still create a fake thread that uses the main
|
|
|
libevent instance. Otherwise create a libevent instance for each thread. */
|
|
|
- if (gearmand->threads == 0)
|
|
|
+ if (gearmand.threads == 0)
|
|
|
{
|
|
|
- thread->base= gearmand->base;
|
|
|
+ thread->base= gearmand.base;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -224,12 +241,12 @@ gearmand_error_t gearmand_thread_create(gearmand_st *gearmand)
|
|
|
}
|
|
|
|
|
|
/* If we are not running multi-threaded, just return the thread context. */
|
|
|
- if (gearmand->threads == 0)
|
|
|
+ if (gearmand.threads == 0)
|
|
|
{
|
|
|
return GEARMAND_SUCCESS;
|
|
|
}
|
|
|
|
|
|
- thread->count= gearmand->thread_count;
|
|
|
+ thread->count= gearmand.thread_count;
|
|
|
|
|
|
int pthread_ret= pthread_mutex_init(&(thread->lock), NULL);
|
|
|
if (pthread_ret != 0)
|