List:Internals« Previous MessageNext Message »
From:Patrick Lau Date:June 24 2009 2:46pm
Subject:How to handle my_errno and self-made threads correctly?
View as plain text  
Hi

Im trying to create a second thread inside sub_select which reads all
the data at once...

Somehow like this:

pthread_setspecific(THR_THD,current_thread);
....
while (1){
		pthread_mutex_lock(&push2router_mutex);
		join_tab->table->in_use=current_thread;
		error= info->read_record(info);
		if (error == 0){
			debug.write_debug("-----------------child Thread - start
push----------------\n");
			push_err=push2router(join,join_tab);
			debug.write_debug("-----------------child Thread - end
push----------------\n");
			pthread_mutex_unlock(&push2router_mutex);
		}
		else {

			pthread_mutex_unlock(&push2router_mutex);
					
			// no data...
			break;
		}
	}

But whenever it reaches end of file, especially

DBUG_RETURN(my_errno= HA_ERR_END_OF_FILE) in Storage Engine it crashes...

But replacing this by

DBUG_RETURN(HA_ERR_END_OF_FILE);

it works perfectly..

So I think the cause is the new threat I created...

Here the thread creation part:

THD *push_thread= new THD;
_args->myselfasTHD = push_thread;
_args->parentTHD = current_thd;
t_ret = pthread_create(&push_thread->real_id, NULL, push_interface,
(void*)_args);


Thanks for any comments in advance....
Patrick
Thread
How to handle my_errno and self-made threads correctly?Patrick Lau24 Jun
  • Re: How to handle my_errno and self-made threads correctly?Sergei Golubchik24 Jun