List:Internals« Previous MessageNext Message »
From:Sergei Golubchik Date:June 24 2009 7:59pm
Subject:Re: How to handle my_errno and self-made threads correctly?
View as plain text  
Hi, Patrick!

On Jun 24, Patrick Lau wrote:
> 
> 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);
.... 
> 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..

Not surprising.
See how my_errno is defined:

#define my_errno my_thread_var->thr_errno

and my_thread_var is

#define my_thread_var (_my_thread_var())

where _my_thread_var() is

struct st_my_thread_var *_my_thread_var(void)
{
  return  my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys);
}

So, you need to have THR_KEY_mysys properly initialized in your new
thread.  The correct way of doing it is to call my_thread_init() early
in the beginning of your new thread and my_thread_end() - just before
the end of it.

Regards / Mit vielen Grüßen,
Sergei

-- 
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /   Sergei Golubchik <serg@stripped>
 / /|_/ / // /\ \/ /_/ / /__  Principal Software Engineer/Server Architect
/_/  /_/\_, /___/\___\_\___/  Sun Microsystems GmbH, HRB München 161028
       <___/                  Sonnenallee 1, 85551 Kirchheim-Heimstetten
Geschäftsführer: Thomas Schroeder, Wolfgang Engels, Wolf Frenkel
Vorsitzender des Aufsichtsrates: Martin Häring
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