mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 05:22:25 +01:00
a8c288054e
Fix various mismatches between function's language linkage. Any particular function that is declared in C++ but should be callable from C must have C linkage. Note that function types with different linkages are also distinct. Thus, if a function type is declared in C code, it will have C linkage (same if declared in a extern "C" block). client/mysql.cc: Mismatch between prototype and declaration. client/mysqltest.cc: mysqltest used to be C code. Use C linkage where appropriate. cmd-line-utils/readline/input.c: Isolate unreachable code. include/my_alloc.h: Function type must have C linkage. include/my_base.h: Function type must have C linkage. include/my_global.h: Add helper macros to avoid spurious namespace indentation. include/mysql.h.pp: Update ABI file. mysys/my_gethwaddr.c: Remove stray carriage return and fix coding style. plugin/semisync/semisync_master_plugin.cc: Callback function types have C linkage. plugin/semisync/semisync_slave_plugin.cc: Callback function types have C linkage. sql/derror.cc: Expected function type has C linkage. sql/field.cc: Use helper macro and fix indentation. sql/handler.cc: Expected function type has C linkage. sql/item_sum.cc: Correct function linkages. Remove now unnecessary cast. sql/item_sum.h: Add prototypes with the appropriate linkage as otherwise they are distinct. sql/mysqld.cc: Wrap functions in C linkage mode. sql/opt_range.cc: C language linkage is ignored for class member functions. sql/partition_info.cc: Add wrapper functions with C linkage for class member functions. sql/rpl_utility.h: Use helper macro and fix indentation. sql/sql_class.cc: Change type of thd argument -- THD is a class. Use helper macro and fix indentation. sql/sql_class.h: Change type of thd argument -- THD is a class. sql/sql_select.cc: Expected function type has C linkage. sql/sql_select.h: Move prototype to sql_test.h sql/sql_show.cc: Expected function type has C linkage. sql/sql_test.cc: Fix required function prototype and fix coding style. sql/sql_test.h: Removed unnecessary export and add another. storage/myisammrg/ha_myisammrg.cc: Expected function type has C linkage. storage/perfschema/pfs.cc: PSI headers are declared with C language linkage, which also applies to function types.
134 lines
3.6 KiB
C++
134 lines
3.6 KiB
C++
/* Copyright (C) 2008-2009 Sun Microsystems, Inc
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
/**
|
|
@file storage/perfschema/pfs_server.cc
|
|
Private interface for the server (implementation).
|
|
*/
|
|
|
|
#include "my_global.h"
|
|
#include "my_sys.h"
|
|
#include "mysys_err.h"
|
|
#include "sql_priv.h"
|
|
#include "pfs_server.h"
|
|
#include "pfs.h"
|
|
#include "pfs_global.h"
|
|
#include "pfs_instr_class.h"
|
|
#include "pfs_instr.h"
|
|
#include "pfs_events_waits.h"
|
|
#include "pfs_timer.h"
|
|
|
|
PFS_global_param pfs_param;
|
|
|
|
C_MODE_START
|
|
static void destroy_pfs_thread(void *key);
|
|
C_MODE_END
|
|
|
|
static void cleanup_performance_schema(void);
|
|
|
|
struct PSI_bootstrap*
|
|
initialize_performance_schema(const PFS_global_param *param)
|
|
{
|
|
pfs_initialized= false;
|
|
|
|
if (! param->m_enabled)
|
|
{
|
|
/*
|
|
The performance schema is disabled in the startup command line.
|
|
All the instrumentation is turned off.
|
|
*/
|
|
return NULL;
|
|
}
|
|
|
|
init_timers();
|
|
PFS_atomic::init();
|
|
|
|
if (pthread_key_create(&THR_PFS, destroy_pfs_thread))
|
|
return NULL;
|
|
|
|
THR_PFS_initialized= true;
|
|
|
|
if (init_sync_class(param->m_mutex_class_sizing,
|
|
param->m_rwlock_class_sizing,
|
|
param->m_cond_class_sizing) ||
|
|
init_thread_class(param->m_thread_class_sizing) ||
|
|
init_table_share(param->m_table_share_sizing) ||
|
|
init_file_class(param->m_file_class_sizing) ||
|
|
init_instruments(param) ||
|
|
init_events_waits_history_long(
|
|
param->m_events_waits_history_long_sizing) ||
|
|
init_file_hash() ||
|
|
init_table_share_hash())
|
|
{
|
|
/*
|
|
The performance schema initialization failed.
|
|
Free the memory used, and disable the instrumentation.
|
|
*/
|
|
cleanup_performance_schema();
|
|
return NULL;
|
|
}
|
|
|
|
pfs_initialized= true;
|
|
return &PFS_bootstrap;
|
|
}
|
|
|
|
static void destroy_pfs_thread(void *key)
|
|
{
|
|
PFS_thread* pfs= reinterpret_cast<PFS_thread*> (key);
|
|
DBUG_ASSERT(pfs);
|
|
/*
|
|
This automatic cleanup is a last resort and best effort to avoid leaks,
|
|
and may not work on windows due to the implementation of pthread_key_create().
|
|
Please either use:
|
|
- my_thread_end()
|
|
- or PSI_server->delete_current_thread()
|
|
in the instrumented code, to explicitly cleanup the instrumentation.
|
|
|
|
Avoid invalid writes when the main() thread completes after shutdown:
|
|
the memory pointed by pfs is already released.
|
|
*/
|
|
if (pfs_initialized)
|
|
destroy_thread(pfs);
|
|
}
|
|
|
|
static void cleanup_performance_schema(void)
|
|
{
|
|
cleanup_instruments();
|
|
cleanup_sync_class();
|
|
cleanup_thread_class();
|
|
cleanup_table_share();
|
|
cleanup_file_class();
|
|
cleanup_events_waits_history_long();
|
|
cleanup_table_share_hash();
|
|
cleanup_file_hash();
|
|
PFS_atomic::cleanup();
|
|
}
|
|
|
|
void shutdown_performance_schema(void)
|
|
{
|
|
pfs_initialized= false;
|
|
cleanup_performance_schema();
|
|
/*
|
|
Be careful to not delete un-initialized keys,
|
|
this would affect key 0, which is THR_KEY_mysys,
|
|
*/
|
|
if (THR_PFS_initialized)
|
|
{
|
|
my_pthread_setspecific_ptr(THR_PFS, NULL);
|
|
pthread_key_delete(THR_PFS);
|
|
THR_PFS_initialized= false;
|
|
}
|
|
}
|
|
|