PageRenderTime 26ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/dep/mysqllite/mysys/my_init.c

https://github.com/chucho/FaceCore
C | 607 lines | 421 code | 91 blank | 95 comment | 62 complexity | 6a05ef40292f5937af4572a73d32358d MD5 | raw file
  1. /* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation; version 2 of the License.
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License
  10. along with this program; if not, write to the Free Software
  11. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
  12. #include "mysys_priv.h"
  13. #include "my_static.h"
  14. #include "mysys_err.h"
  15. #include <m_string.h>
  16. #include <m_ctype.h>
  17. #include <signal.h>
  18. #ifdef __WIN__
  19. #ifdef _MSC_VER
  20. #include <locale.h>
  21. #include <crtdbg.h>
  22. /* WSAStartup needs winsock library*/
  23. #pragma comment(lib, "ws2_32")
  24. #endif
  25. my_bool have_tcpip=0;
  26. static void my_win_init(void);
  27. static my_bool win32_init_tcp_ip();
  28. #else
  29. #define my_win_init()
  30. #endif
  31. #define SCALE_SEC 100
  32. #define SCALE_USEC 10000
  33. my_bool my_init_done= 0;
  34. /** True if @c my_basic_init() has been called. */
  35. my_bool my_basic_init_done= 0;
  36. uint mysys_usage_id= 0; /* Incremented for each my_init() */
  37. ulong my_thread_stack_size= 65536;
  38. static ulong atoi_octal(const char *str)
  39. {
  40. long int tmp;
  41. while (*str && my_isspace(&my_charset_latin1, *str))
  42. str++;
  43. str2int(str,
  44. (*str == '0' ? 8 : 10), /* Octalt or decimalt */
  45. 0, INT_MAX, &tmp);
  46. return (ulong) tmp;
  47. }
  48. MYSQL_FILE *mysql_stdin= NULL;
  49. static MYSQL_FILE instrumented_stdin;
  50. /**
  51. Perform a limited initialisation of mysys.
  52. This initialisation is sufficient to:
  53. - allocate memory,
  54. - read configuration files,
  55. - parse command lines arguments.
  56. To complete the mysys initialisation,
  57. call my_init().
  58. @return 0 on success
  59. */
  60. my_bool my_basic_init(void)
  61. {
  62. char * str;
  63. if (my_basic_init_done)
  64. return 0;
  65. my_basic_init_done= 1;
  66. mysys_usage_id++;
  67. my_umask= 0660; /* Default umask for new files */
  68. my_umask_dir= 0700; /* Default umask for new directories */
  69. /* Default creation of new files */
  70. if ((str= getenv("UMASK")) != 0)
  71. my_umask= (int) (atoi_octal(str) | 0600);
  72. /* Default creation of new dir's */
  73. if ((str= getenv("UMASK_DIR")) != 0)
  74. my_umask_dir= (int) (atoi_octal(str) | 0700);
  75. init_glob_errs();
  76. instrumented_stdin.m_file= stdin;
  77. instrumented_stdin.m_psi= NULL; /* not yet instrumented */
  78. mysql_stdin= & instrumented_stdin;
  79. if (my_thread_global_init())
  80. return 1;
  81. #if defined(SAFE_MUTEX)
  82. safe_mutex_global_init(); /* Must be called early */
  83. #endif
  84. #if defined(MY_PTHREAD_FASTMUTEX) && !defined(SAFE_MUTEX)
  85. fastmutex_global_init(); /* Must be called early */
  86. #endif
  87. #if defined(HAVE_PTHREAD_INIT)
  88. pthread_init(); /* Must be called before DBUG_ENTER */
  89. #endif
  90. if (my_thread_basic_global_init())
  91. return 1;
  92. /* $HOME is needed early to parse configuration files located in ~/ */
  93. if ((home_dir= getenv("HOME")) != 0)
  94. home_dir= intern_filename(home_dir_buff, home_dir);
  95. return 0;
  96. }
  97. /*
  98. Init my_sys functions and my_sys variabels
  99. SYNOPSIS
  100. my_init()
  101. RETURN
  102. 0 ok
  103. 1 Couldn't initialize environment
  104. */
  105. my_bool my_init(void)
  106. {
  107. if (my_init_done)
  108. return 0;
  109. my_init_done= 1;
  110. if (my_basic_init())
  111. return 1;
  112. if (my_thread_global_init())
  113. return 1;
  114. {
  115. DBUG_ENTER("my_init");
  116. DBUG_PROCESS((char*) (my_progname ? my_progname : "unknown"));
  117. my_win_init();
  118. DBUG_PRINT("exit", ("home: '%s'", home_dir));
  119. #ifdef __WIN__
  120. win32_init_tcp_ip();
  121. #endif
  122. DBUG_RETURN(0);
  123. }
  124. } /* my_init */
  125. /* End my_sys */
  126. void my_end(int infoflag)
  127. {
  128. /*
  129. this code is suboptimal to workaround a bug in
  130. Sun CC: Sun C++ 5.6 2004/06/02 for x86, and should not be
  131. optimized until this compiler is not in use anymore
  132. */
  133. FILE *info_file= DBUG_FILE;
  134. my_bool print_info= (info_file != stderr);
  135. if (!my_init_done)
  136. return;
  137. /*
  138. We do not use DBUG_ENTER here, as after cleanup DBUG is no longer
  139. operational, so we cannot use DBUG_RETURN.
  140. */
  141. DBUG_PRINT("info",("Shutting down: infoflag: %d print_info: %d",
  142. infoflag, print_info));
  143. if (!info_file)
  144. {
  145. info_file= stderr;
  146. print_info= 0;
  147. }
  148. if ((infoflag & MY_CHECK_ERROR) || print_info)
  149. { /* Test if some file is left open */
  150. if (my_file_opened | my_stream_opened)
  151. {
  152. char ebuff[512];
  153. my_snprintf(ebuff, sizeof(ebuff), EE(EE_OPEN_WARNING),
  154. my_file_opened, my_stream_opened);
  155. my_message_stderr(EE_OPEN_WARNING, ebuff, ME_BELL);
  156. DBUG_PRINT("error", ("%s", ebuff));
  157. my_print_open_files();
  158. }
  159. }
  160. free_charsets();
  161. my_error_unregister_all();
  162. my_once_free();
  163. if ((infoflag & MY_GIVE_INFO) || print_info)
  164. {
  165. #ifdef HAVE_GETRUSAGE
  166. struct rusage rus;
  167. #ifdef HAVE_purify
  168. /* Purify assumes that rus is uninitialized after getrusage call */
  169. bzero((char*) &rus, sizeof(rus));
  170. #endif
  171. if (!getrusage(RUSAGE_SELF, &rus))
  172. fprintf(info_file,"\n\
  173. User time %.2f, System time %.2f\n\
  174. Maximum resident set size %ld, Integral resident set size %ld\n\
  175. Non-physical pagefaults %ld, Physical pagefaults %ld, Swaps %ld\n\
  176. Blocks in %ld out %ld, Messages in %ld out %ld, Signals %ld\n\
  177. Voluntary context switches %ld, Involuntary context switches %ld\n",
  178. (rus.ru_utime.tv_sec * SCALE_SEC +
  179. rus.ru_utime.tv_usec / SCALE_USEC) / 100.0,
  180. (rus.ru_stime.tv_sec * SCALE_SEC +
  181. rus.ru_stime.tv_usec / SCALE_USEC) / 100.0,
  182. rus.ru_maxrss, rus.ru_idrss,
  183. rus.ru_minflt, rus.ru_majflt,
  184. rus.ru_nswap, rus.ru_inblock, rus.ru_oublock,
  185. rus.ru_msgsnd, rus.ru_msgrcv, rus.ru_nsignals,
  186. rus.ru_nvcsw, rus.ru_nivcsw);
  187. #endif
  188. #if defined(__WIN__) && defined(_MSC_VER)
  189. _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE );
  190. _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDERR );
  191. _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE );
  192. _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDERR );
  193. _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
  194. _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR );
  195. _CrtCheckMemory();
  196. _CrtDumpMemoryLeaks();
  197. #endif
  198. }
  199. if (!(infoflag & MY_DONT_FREE_DBUG))
  200. {
  201. DBUG_END(); /* Must be done before my_thread_end */
  202. }
  203. my_thread_end();
  204. my_thread_global_end();
  205. #if defined(SAFE_MUTEX)
  206. /*
  207. Check on destroying of mutexes. A few may be left that will get cleaned
  208. up by C++ destructors
  209. */
  210. safe_mutex_end((infoflag & (MY_GIVE_INFO | MY_CHECK_ERROR)) ? stderr :
  211. (FILE *) 0);
  212. #endif /* defined(SAFE_MUTEX) */
  213. #ifdef __WIN__
  214. if (have_tcpip)
  215. WSACleanup();
  216. #endif /* __WIN__ */
  217. my_init_done=0;
  218. my_basic_init_done= 0;
  219. } /* my_end */
  220. #ifdef __WIN__
  221. /*
  222. my_parameter_handler
  223. Invalid parameter handler we will use instead of the one "baked"
  224. into the CRT for MSC v8. This one just prints out what invalid
  225. parameter was encountered. By providing this routine, routines like
  226. lseek will return -1 when we expect them to instead of crash.
  227. */
  228. void my_parameter_handler(const wchar_t * expression, const wchar_t * function,
  229. const wchar_t * file, unsigned int line,
  230. uintptr_t pReserved)
  231. {
  232. DBUG_PRINT("my",("Expression: %s function: %s file: %s, line: %d",
  233. expression, function, file, line));
  234. }
  235. #ifdef __MSVC_RUNTIME_CHECKS
  236. #include <rtcapi.h>
  237. /* Turn off runtime checks for 'handle_rtc_failure' */
  238. #pragma runtime_checks("", off)
  239. /*
  240. handle_rtc_failure
  241. Catch the RTC error and dump it to stderr
  242. */
  243. int handle_rtc_failure(int err_type, const char *file, int line,
  244. const char* module, const char *format, ...)
  245. {
  246. va_list args;
  247. va_start(args, format);
  248. fprintf(stderr, "Error:");
  249. vfprintf(stderr, format, args);
  250. fprintf(stderr, " At %s:%d\n", file, line);
  251. va_end(args);
  252. (void) fflush(stderr);
  253. return 0; /* Error is handled */
  254. }
  255. #pragma runtime_checks("", restore)
  256. #endif
  257. #define OFFSET_TO_EPOC ((__int64) 134774 * 24 * 60 * 60 * 1000 * 1000 * 10)
  258. #define MS 10000000
  259. static void win_init_time(void)
  260. {
  261. /* The following is used by time functions */
  262. FILETIME ft;
  263. LARGE_INTEGER li, t_cnt;
  264. DBUG_ASSERT(sizeof(LARGE_INTEGER) == sizeof(query_performance_frequency));
  265. if (QueryPerformanceFrequency((LARGE_INTEGER *)&query_performance_frequency) == 0)
  266. query_performance_frequency= 0;
  267. else
  268. {
  269. GetSystemTimeAsFileTime(&ft);
  270. li.LowPart= ft.dwLowDateTime;
  271. li.HighPart= ft.dwHighDateTime;
  272. query_performance_offset= li.QuadPart-OFFSET_TO_EPOC;
  273. QueryPerformanceCounter(&t_cnt);
  274. query_performance_offset-= (t_cnt.QuadPart /
  275. query_performance_frequency * MS +
  276. t_cnt.QuadPart %
  277. query_performance_frequency * MS /
  278. query_performance_frequency);
  279. }
  280. }
  281. /*
  282. Open HKEY_LOCAL_MACHINE\SOFTWARE\MySQL and set any strings found
  283. there as environment variables
  284. */
  285. static void win_init_registry(void)
  286. {
  287. HKEY key_handle;
  288. if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, (LPCTSTR)"SOFTWARE\\MySQL",
  289. 0, KEY_READ, &key_handle) == ERROR_SUCCESS)
  290. {
  291. LONG ret;
  292. DWORD index= 0;
  293. DWORD type;
  294. char key_name[256], key_data[1024];
  295. DWORD key_name_len= sizeof(key_name) - 1;
  296. DWORD key_data_len= sizeof(key_data) - 1;
  297. while ((ret= RegEnumValue(key_handle, index++,
  298. key_name, &key_name_len,
  299. NULL, &type, (LPBYTE)&key_data,
  300. &key_data_len)) != ERROR_NO_MORE_ITEMS)
  301. {
  302. char env_string[sizeof(key_name) + sizeof(key_data) + 2];
  303. if (ret == ERROR_MORE_DATA)
  304. {
  305. /* Registry value larger than 'key_data', skip it */
  306. DBUG_PRINT("error", ("Skipped registry value that was too large"));
  307. }
  308. else if (ret == ERROR_SUCCESS)
  309. {
  310. if (type == REG_SZ)
  311. {
  312. strxmov(env_string, key_name, "=", key_data, NullS);
  313. /* variable for putenv must be allocated ! */
  314. putenv(strdup(env_string)) ;
  315. }
  316. }
  317. else
  318. {
  319. /* Unhandled error, break out of loop */
  320. break;
  321. }
  322. key_name_len= sizeof(key_name) - 1;
  323. key_data_len= sizeof(key_data) - 1;
  324. }
  325. RegCloseKey(key_handle);
  326. }
  327. }
  328. static void my_win_init(void)
  329. {
  330. DBUG_ENTER("my_win_init");
  331. #if defined(_MSC_VER)
  332. #if _MSC_VER < 1300
  333. /*
  334. Clear the OS system variable TZ and avoid the 100% CPU usage
  335. Only for old versions of Visual C++
  336. */
  337. _putenv("TZ=");
  338. #endif
  339. #if _MSC_VER >= 1400
  340. /* this is required to make crt functions return -1 appropriately */
  341. _set_invalid_parameter_handler(my_parameter_handler);
  342. #endif
  343. #endif
  344. #ifdef __MSVC_RUNTIME_CHECKS
  345. /*
  346. Install handler to send RTC (Runtime Error Check) warnings
  347. to log file
  348. */
  349. _RTC_SetErrorFunc(handle_rtc_failure);
  350. #endif
  351. _tzset();
  352. win_init_time();
  353. win_init_registry();
  354. DBUG_VOID_RETURN;
  355. }
  356. /*------------------------------------------------------------------
  357. Name: CheckForTcpip| Desc: checks if tcpip has been installed on system
  358. According to Microsoft Developers documentation the first registry
  359. entry should be enough to check if TCP/IP is installed, but as expected
  360. this doesn't work on all Win32 machines :(
  361. ------------------------------------------------------------------*/
  362. #define TCPIPKEY "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters"
  363. #define WINSOCK2KEY "SYSTEM\\CurrentControlSet\\Services\\Winsock2\\Parameters"
  364. #define WINSOCKKEY "SYSTEM\\CurrentControlSet\\Services\\Winsock\\Parameters"
  365. static my_bool win32_have_tcpip(void)
  366. {
  367. HKEY hTcpipRegKey;
  368. if (RegOpenKeyEx ( HKEY_LOCAL_MACHINE, TCPIPKEY, 0, KEY_READ,
  369. &hTcpipRegKey) != ERROR_SUCCESS)
  370. {
  371. if (RegOpenKeyEx ( HKEY_LOCAL_MACHINE, WINSOCK2KEY, 0, KEY_READ,
  372. &hTcpipRegKey) != ERROR_SUCCESS)
  373. {
  374. if (RegOpenKeyEx ( HKEY_LOCAL_MACHINE, WINSOCKKEY, 0, KEY_READ,
  375. &hTcpipRegKey) != ERROR_SUCCESS)
  376. if (!getenv("HAVE_TCPIP") || have_tcpip) /* Provide a workaround */
  377. return (FALSE);
  378. }
  379. }
  380. RegCloseKey ( hTcpipRegKey);
  381. return (TRUE);
  382. }
  383. static my_bool win32_init_tcp_ip()
  384. {
  385. if (win32_have_tcpip())
  386. {
  387. WORD wVersionRequested = MAKEWORD( 2, 2 );
  388. WSADATA wsaData;
  389. /* Be a good citizen: maybe another lib has already initialised
  390. sockets, so dont clobber them unless necessary */
  391. if (WSAStartup( wVersionRequested, &wsaData ))
  392. {
  393. /* Load failed, maybe because of previously loaded
  394. incompatible version; try again */
  395. WSACleanup( );
  396. if (!WSAStartup( wVersionRequested, &wsaData ))
  397. have_tcpip=1;
  398. }
  399. else
  400. {
  401. if (wsaData.wVersion != wVersionRequested)
  402. {
  403. /* Version is no good, try again */
  404. WSACleanup( );
  405. if (!WSAStartup( wVersionRequested, &wsaData ))
  406. have_tcpip=1;
  407. }
  408. else
  409. have_tcpip=1;
  410. }
  411. }
  412. return(0);
  413. }
  414. #endif /* __WIN__ */
  415. #ifdef HAVE_PSI_INTERFACE
  416. #if !defined(HAVE_PREAD) && !defined(_WIN32)
  417. PSI_mutex_key key_my_file_info_mutex;
  418. #endif /* !defined(HAVE_PREAD) && !defined(_WIN32) */
  419. #if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
  420. PSI_mutex_key key_LOCK_localtime_r;
  421. #endif /* !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R) */
  422. #ifndef HAVE_GETHOSTBYNAME_R
  423. PSI_mutex_key key_LOCK_gethostbyname_r;
  424. #endif /* HAVE_GETHOSTBYNAME_R */
  425. PSI_mutex_key key_BITMAP_mutex, key_IO_CACHE_append_buffer_lock,
  426. key_IO_CACHE_SHARE_mutex, key_KEY_CACHE_cache_lock, key_LOCK_alarm,
  427. key_my_thread_var_mutex, key_THR_LOCK_charset, key_THR_LOCK_heap,
  428. key_THR_LOCK_isam, key_THR_LOCK_lock, key_THR_LOCK_malloc,
  429. key_THR_LOCK_mutex, key_THR_LOCK_myisam, key_THR_LOCK_net,
  430. key_THR_LOCK_open, key_THR_LOCK_threads, key_THR_LOCK_time,
  431. key_TMPDIR_mutex, key_THR_LOCK_myisam_mmap;
  432. static PSI_mutex_info all_mysys_mutexes[]=
  433. {
  434. #if !defined(HAVE_PREAD) && !defined(_WIN32)
  435. { &key_my_file_info_mutex, "st_my_file_info:mutex", 0},
  436. #endif /* !defined(HAVE_PREAD) && !defined(_WIN32) */
  437. #if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
  438. { &key_LOCK_localtime_r, "LOCK_localtime_r", PSI_FLAG_GLOBAL},
  439. #endif /* !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R) */
  440. #ifndef HAVE_GETHOSTBYNAME_R
  441. { &key_LOCK_gethostbyname_r, "LOCK_gethostbyname_r", PSI_FLAG_GLOBAL},
  442. #endif /* HAVE_GETHOSTBYNAME_R */
  443. { &key_BITMAP_mutex, "BITMAP::mutex", 0},
  444. { &key_IO_CACHE_append_buffer_lock, "IO_CACHE::append_buffer_lock", 0},
  445. { &key_IO_CACHE_SHARE_mutex, "IO_CACHE::SHARE_mutex", 0},
  446. { &key_KEY_CACHE_cache_lock, "KEY_CACHE::cache_lock", 0},
  447. { &key_LOCK_alarm, "LOCK_alarm", PSI_FLAG_GLOBAL},
  448. { &key_my_thread_var_mutex, "my_thread_var::mutex", 0},
  449. { &key_THR_LOCK_charset, "THR_LOCK_charset", PSI_FLAG_GLOBAL},
  450. { &key_THR_LOCK_heap, "THR_LOCK_heap", PSI_FLAG_GLOBAL},
  451. { &key_THR_LOCK_isam, "THR_LOCK_isam", PSI_FLAG_GLOBAL},
  452. { &key_THR_LOCK_lock, "THR_LOCK_lock", PSI_FLAG_GLOBAL},
  453. { &key_THR_LOCK_malloc, "THR_LOCK_malloc", PSI_FLAG_GLOBAL},
  454. { &key_THR_LOCK_mutex, "THR_LOCK::mutex", 0},
  455. { &key_THR_LOCK_myisam, "THR_LOCK_myisam", PSI_FLAG_GLOBAL},
  456. { &key_THR_LOCK_net, "THR_LOCK_net", PSI_FLAG_GLOBAL},
  457. { &key_THR_LOCK_open, "THR_LOCK_open", PSI_FLAG_GLOBAL},
  458. { &key_THR_LOCK_threads, "THR_LOCK_threads", PSI_FLAG_GLOBAL},
  459. { &key_THR_LOCK_time, "THR_LOCK_time", PSI_FLAG_GLOBAL},
  460. { &key_TMPDIR_mutex, "TMPDIR_mutex", PSI_FLAG_GLOBAL},
  461. { &key_THR_LOCK_myisam_mmap, "THR_LOCK_myisam_mmap", PSI_FLAG_GLOBAL}
  462. };
  463. PSI_cond_key key_COND_alarm, key_IO_CACHE_SHARE_cond,
  464. key_IO_CACHE_SHARE_cond_writer, key_my_thread_var_suspend,
  465. key_THR_COND_threads;
  466. static PSI_cond_info all_mysys_conds[]=
  467. {
  468. { &key_COND_alarm, "COND_alarm", PSI_FLAG_GLOBAL},
  469. { &key_IO_CACHE_SHARE_cond, "IO_CACHE_SHARE::cond", 0},
  470. { &key_IO_CACHE_SHARE_cond_writer, "IO_CACHE_SHARE::cond_writer", 0},
  471. { &key_my_thread_var_suspend, "my_thread_var::suspend", 0},
  472. { &key_THR_COND_threads, "THR_COND_threads", 0}
  473. };
  474. #ifdef USE_ALARM_THREAD
  475. PSI_thread_key key_thread_alarm;
  476. static PSI_thread_info all_mysys_threads[]=
  477. {
  478. { &key_thread_alarm, "alarm", PSI_FLAG_GLOBAL}
  479. };
  480. #endif /* USE_ALARM_THREAD */
  481. #ifdef HUGETLB_USE_PROC_MEMINFO
  482. PSI_file_key key_file_proc_meminfo;
  483. #endif /* HUGETLB_USE_PROC_MEMINFO */
  484. PSI_file_key key_file_charset, key_file_cnf;
  485. static PSI_file_info all_mysys_files[]=
  486. {
  487. #ifdef HUGETLB_USE_PROC_MEMINFO
  488. { &key_file_proc_meminfo, "proc_meminfo", 0},
  489. #endif /* HUGETLB_USE_PROC_MEMINFO */
  490. { &key_file_charset, "charset", 0},
  491. { &key_file_cnf, "cnf", 0}
  492. };
  493. void my_init_mysys_psi_keys()
  494. {
  495. const char* category= "mysys";
  496. int count;
  497. if (PSI_server == NULL)
  498. return;
  499. count= sizeof(all_mysys_mutexes)/sizeof(all_mysys_mutexes[0]);
  500. PSI_server->register_mutex(category, all_mysys_mutexes, count);
  501. count= sizeof(all_mysys_conds)/sizeof(all_mysys_conds[0]);
  502. PSI_server->register_cond(category, all_mysys_conds, count);
  503. #ifdef USE_ALARM_THREAD
  504. count= sizeof(all_mysys_threads)/sizeof(all_mysys_threads[0]);
  505. PSI_server->register_thread(category, all_mysys_threads, count);
  506. #endif /* USE_ALARM_THREAD */
  507. count= sizeof(all_mysys_files)/sizeof(all_mysys_files[0]);
  508. PSI_server->register_file(category, all_mysys_files, count);
  509. }
  510. #endif /* HAVE_PSI_INTERFACE */