| 366 | static rw_lock_t THR_LOCK_init_settings; |
| 367 | |
| 368 | static CODE_STATE *code_state(void) |
| 369 | { |
| 370 | CODE_STATE *cs, **cs_ptr; |
| 371 | |
| 372 | /* |
| 373 | _dbug_on_ is reset if we don't plan to use any debug commands at all and |
| 374 | we want to run on maximum speed |
| 375 | */ |
| 376 | if (!_dbug_on_) |
| 377 | return 0; |
| 378 | |
| 379 | if (!init_done) |
| 380 | { |
| 381 | init_done=TRUE; |
| 382 | pthread_mutex_init(&THR_LOCK_dbug, NULL); |
| 383 | pthread_mutex_init(&THR_LOCK_gcov, NULL); |
| 384 | my_rwlock_init(&THR_LOCK_init_settings, NULL); |
| 385 | memset(&init_settings, 0, sizeof(init_settings)); |
| 386 | init_settings.out_file=stderr; |
| 387 | init_settings.flags=OPEN_APPEND; |
| 388 | } |
| 389 | |
| 390 | if (!(cs_ptr= (CODE_STATE**) my_thread_var_dbug())) |
| 391 | return 0; /* Thread not initialised */ |
| 392 | if (!(cs= *cs_ptr)) |
| 393 | { |
| 394 | cs=(CODE_STATE*) DbugMalloc(sizeof(*cs)); |
| 395 | memset(cs, 0, sizeof(*cs)); |
| 396 | cs->process= db_process ? db_process : "dbug"; |
| 397 | cs->func="?func"; |
| 398 | cs->file="?file"; |
| 399 | cs->stack=&init_settings; |
| 400 | cs->m_read_lock_count= 0; |
| 401 | *cs_ptr= cs; |
| 402 | } |
| 403 | return cs; |
| 404 | } |
| 405 | |
| 406 | /** |
| 407 | Lock the stack debugging settings. |
no test coverage detected