MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / my_thread_init

Function my_thread_init

mysys/my_thr_init.c:264–341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

262*/
263
264my_bool my_thread_init(void)
265{
266 struct st_my_thread_var *tmp;
267 my_bool error=0;
268
269 if (!my_thread_global_init_done)
270 return 1; /* cannot proceed with unintialized library */
271
272#ifdef EXTRA_DEBUG_THREADS
273 fprintf(stderr,"my_thread_init(): thread_id: 0x%lx\n",
274 (ulong) pthread_self());
275#endif
276
277 if (_my_thread_var())
278 {
279#ifdef EXTRA_DEBUG_THREADS
280 fprintf(stderr,"my_thread_init() called more than once in thread 0x%lx\n",
281 (long) pthread_self());
282#endif
283 goto end;
284 }
285
286#ifdef _MSC_VER
287 install_sigabrt_handler();
288#endif
289
290 if (!(tmp= (struct st_my_thread_var *) calloc(1, sizeof(*tmp))))
291 {
292 error= 1;
293 goto end;
294 }
295 set_mysys_var(tmp);
296 tmp->pthread_self= pthread_self();
297 mysql_mutex_init(key_my_thread_var_mutex, &tmp->mutex, MY_MUTEX_INIT_FAST);
298 mysql_cond_init(key_my_thread_var_suspend, &tmp->suspend, NULL);
299
300#if defined(_GNU_SOURCE) && (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600)
301 {
302 pthread_attr_t attr;
303 char* stack_addr;
304 size_t stack_size;
305
306 if (pthread_attr_init(&attr) ||
307 pthread_getattr_np(tmp->pthread_self, &attr) ||
308 pthread_attr_getstack(&attr, (void**)&stack_addr, &stack_size))
309 {
310 error= 1;
311 goto end;
312 }
313 tmp->stack_ends_here= stack_addr;
314
315 if (pthread_attr_destroy(&attr))
316 {
317 error= 1;
318 goto end;
319 }
320 }
321#else //defined(_GNU_SOURCE) && (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600)

Callers 8

handle_shutdownFunction · 0.85
timer_notify_threadFunction · 0.85
my_thread_global_initFunction · 0.85
alarm_handlerFunction · 0.85
test_threadFunction · 0.85
signal_handFunction · 0.85
test_threadFunction · 0.85
timer_notify_threadFunction · 0.85

Calls 7

_my_thread_varFunction · 0.85
install_sigabrt_handlerFunction · 0.85
set_mysys_varFunction · 0.85
pthread_attr_initFunction · 0.85
pthread_attr_destroyFunction · 0.85
my_getpagesizeFunction · 0.85
my_thread_nameFunction · 0.85

Tested by 2

test_threadFunction · 0.68
test_threadFunction · 0.68