Commit 3a7c12b2 authored by hf@genie.(none)'s avatar hf@genie.(none)

Libmysqld improvements

parent a6b0579f
......@@ -310,6 +310,415 @@ extern "C"
ulong max_allowed_packet, net_buffer_length;
int STDCALL mysql_server_init(int argc, char **argv, char **groups)
{
char glob_hostname[FN_REFLEN];
/* This mess is to allow people to call the init function without
* having to mess with a fake argv */
int *argcp;
char ***argvp;
int fake_argc = 1;
char *fake_argv[] = { (char *)"", 0 };
const char *fake_groups[] = { "server", "embedded", 0 };
if (argc)
{
argcp = &argc;
argvp = (char***) &argv;
}
else
{
argcp = &fake_argc;
argvp = (char ***) &fake_argv;
}
if (!groups)
groups = (char**) fake_groups;
/* Only call MY_INIT() if it hasn't been called before */
if (!inited)
{
inited=1;
org_my_init_done=my_init_done;
}
if (!org_my_init_done)
{
MY_INIT((char *)"mysql_embedded"); // init my_sys library & pthreads
}
if (init_common_variables("my", argc, argv, (const char **)groups))
{
mysql_server_end();
return 1;
}
/* Get default temporary directory */
opt_mysql_tmpdir=getenv("TMPDIR"); /* Use this if possible */
#if defined( __WIN__) || defined(OS2)
if (!opt_mysql_tmpdir)
opt_mysql_tmpdir=getenv("TEMP");
if (!opt_mysql_tmpdir)
opt_mysql_tmpdir=getenv("TMP");
#endif
if (!opt_mysql_tmpdir || !opt_mysql_tmpdir[0])
opt_mysql_tmpdir=(char*) P_tmpdir; /* purecov: inspected */
if (init_thread_environement())
{
mysql_server_end();
return 1;
}
umask(((~my_umask) & 0666));
if (init_server_components())
{
mysql_server_end();
return 1;
}
error_handler_hook = my_message_sql;
opt_noacl = 1; // No permissions
if (acl_init(opt_noacl))
{
mysql_server_end();
return 1;
}
if (!opt_noacl)
(void) grant_init();
init_max_user_conn();
init_update_queries();
#ifdef HAVE_DLOPEN
if (!opt_noacl)
udf_init();
#endif
if (opt_bin_log)
{
if (!opt_bin_logname)
{
char tmp[FN_REFLEN];
/* TODO: The following should be using fn_format(); We just need to
first change fn_format() to cut the file name if it's too long.
*/
strmake(tmp,glob_hostname,FN_REFLEN-5);
strmov(strcend(tmp,'.'),"-bin");
opt_bin_logname=my_strdup(tmp,MYF(MY_WME));
}
open_log(&mysql_bin_log, glob_hostname, opt_bin_logname, "-bin",
opt_binlog_index_name, LOG_BIN);
using_update_log=1;
}
(void) thr_setconcurrency(concurrency); // 10 by default
if (
#ifdef HAVE_BERKELEY_DB
!berkeley_skip ||
#endif
(flush_time && flush_time != ~(ulong) 0L))
{
pthread_t hThread;
if (pthread_create(&hThread,&connection_attrib,handle_manager,0))
sql_print_error("Warning: Can't create thread to manage maintenance");
}
/*
Update mysqld variables from client variables if set
The client variables are set also by get_one_option() in mysqld.cc
*/
if (max_allowed_packet)
global_system_variables.max_allowed_packet= max_allowed_packet;
if (net_buffer_length)
global_system_variables.net_buffer_length= net_buffer_length;
return 0;
}
#ifdef __DUMMY
int STDCALL mysql_server_init(int argc, char **argv, char **groups)
{
char glob_hostname[FN_REFLEN];
/* This mess is to allow people to call the init function without
* having to mess with a fake argv */
int *argcp;
char ***argvp;
int fake_argc = 1;
char *fake_argv[] = { (char *)"", 0 };
const char *fake_groups[] = { "server", "embedded", 0 };
if (argc)
{
argcp = &argc;
argvp = (char***) &argv;
}
else
{
argcp = &fake_argc;
argvp = (char ***) &fake_argv;
}
if (!groups)
groups = (char**) fake_groups;
my_umask=0660; // Default umask for new files
my_umask_dir=0700; // Default umask for new directories
/* Only call MY_INIT() if it hasn't been called before */
if (!inited)
{
inited=1;
org_my_init_done=my_init_done;
}
if (!org_my_init_done)
{
MY_INIT((char *)"mysql_embedded"); // init my_sys library & pthreads
}
tzset(); // Set tzname
start_time=time((time_t*) 0);
#ifdef HAVE_TZNAME
#if defined(HAVE_LOCALTIME_R) && defined(_REENTRANT)
{
struct tm tm_tmp;
localtime_r(&start_time,&tm_tmp);
strmov(time_zone,tzname[tm_tmp.tm_isdst != 0 ? 1 : 0]);
}
#else
{
struct tm *start_tm;
start_tm=localtime(&start_time);
strmov(time_zone,tzname[start_tm->tm_isdst != 0 ? 1 : 0]);
}
#endif
#endif
if (gethostname(glob_hostname,sizeof(glob_hostname)-4) < 0)
strmov(glob_hostname,"mysql");
#ifndef DBUG_OFF
strxmov(strend(server_version),MYSQL_SERVER_SUFFIX,"-debug",NullS);
#else
strmov(strend(server_version),MYSQL_SERVER_SUFFIX);
#endif
load_defaults("my", (const char **) groups, argcp, argvp);
defaults_argv=*argvp;
/* Get default temporary directory */
opt_mysql_tmpdir=getenv("TMPDIR"); /* Use this if possible */
#if defined( __WIN__) || defined(OS2)
if (!opt_mysql_tmpdir)
opt_mysql_tmpdir=getenv("TEMP");
if (!opt_mysql_tmpdir)
opt_mysql_tmpdir=getenv("TMP");
#endif
if (!opt_mysql_tmpdir || !opt_mysql_tmpdir[0])
opt_mysql_tmpdir=(char*) P_tmpdir; /* purecov: inspected */
set_options();
get_options(*argcp, *argvp);
if (opt_log || opt_update_log || opt_slow_log || opt_bin_log)
strcat(server_version,"-log");
DBUG_PRINT("info",("%s Ver %s for %s on %s\n",my_progname,
server_version, SYSTEM_TYPE,MACHINE_TYPE));
/* These must be set early */
(void) pthread_mutex_init(&LOCK_mysql_create_db,MY_MUTEX_INIT_SLOW);
(void) pthread_mutex_init(&LOCK_Acl,MY_MUTEX_INIT_SLOW);
(void) pthread_mutex_init(&LOCK_open,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_thread_count,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_mapped_file,MY_MUTEX_INIT_SLOW);
(void) pthread_mutex_init(&LOCK_status,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_error_log,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_delayed_insert,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_delayed_status,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_delayed_create,MY_MUTEX_INIT_SLOW);
(void) pthread_mutex_init(&LOCK_manager,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_crypt,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_bytes_sent,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_bytes_received,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_timezone,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_user_conn, MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_active_mi, MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_global_system_variables, MY_MUTEX_INIT_FAST);
(void) my_rwlock_init(&LOCK_grant, NULL);
(void) pthread_cond_init(&COND_thread_count,NULL);
(void) pthread_cond_init(&COND_refresh,NULL);
(void) pthread_cond_init(&COND_thread_cache,NULL);
(void) pthread_cond_init(&COND_flush_thread_cache,NULL);
(void) pthread_cond_init(&COND_manager,NULL);
(void) pthread_cond_init(&COND_rpl_status, NULL);
if (set_default_charset_by_name(sys_charset.value, MYF(MY_WME)))
{
mysql_server_end();
return 1;
}
charsets_list = list_charsets(MYF(MY_CS_COMPILED|MY_CS_CONFIG));
/* Parameter for threads created for connections */
(void) pthread_attr_init(&connection_attrib);
(void) pthread_attr_setdetachstate(&connection_attrib,
PTHREAD_CREATE_DETACHED);
pthread_attr_setstacksize(&connection_attrib,thread_stack);
pthread_attr_setscope(&connection_attrib, PTHREAD_SCOPE_SYSTEM);
#if defined( SET_RLIMIT_NOFILE) || defined( OS2)
/* connections and databases needs lots of files */
{
uint wanted_files=10+(uint) max(max_connections*5,
max_connections+table_cache_size*2);
set_if_bigger(wanted_files, open_files_limit);
// Note that some system returns 0 if we succeed here:
uint files=set_maximum_open_files(wanted_files);
if (files && files < wanted_files && ! open_files_limit)
{
max_connections= (ulong) min((files-10),max_connections);
table_cache_size= (ulong) max((files-10-max_connections)/2,64);
DBUG_PRINT("warning",
("Changed limits: max_connections: %ld table_cache: %ld",
max_connections,table_cache_size));
sql_print_error("Warning: Changed limits: max_connections: %ld table_cache: %ld",max_connections,table_cache_size);
}
}
#endif
unireg_init(opt_specialflag); /* Set up extern variabels */
init_errmessage(); /* Read error messages from file */
lex_init();
item_init();
set_var_init();
mysys_uses_curses=0;
#ifdef USE_REGEX
regex_init();
#endif
if (use_temp_pool && bitmap_init(&temp_pool,1024,1))
{
mysql_server_end();
return 1;
}
/*
We have enough space for fiddling with the argv, continue
*/
umask(((~my_umask) & 0666));
table_cache_init();
hostname_cache_init();
query_cache_result_size_limit(query_cache_limit);
query_cache_resize(query_cache_size);
randominit(&sql_rand,(ulong) start_time,(ulong) start_time/2);
reset_floating_point_exceptions();
init_thr_lock();
init_slave_list();
/* Setup log files */
if (opt_log)
open_log(&mysql_log, glob_hostname, opt_logname, ".log", NullS,
LOG_NORMAL);
if (opt_update_log)
{
open_log(&mysql_update_log, glob_hostname, opt_update_logname, "",
NullS, LOG_NEW);
using_update_log=1;
}
if (opt_slow_log)
open_log(&mysql_slow_log, glob_hostname, opt_slow_logname, "-slow.log",
NullS, LOG_NORMAL);
if (ha_init())
{
sql_print_error("Can't init databases");
exit(1);
}
ha_key_cache();
#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT)
if (locked_in_memory && !geteuid())
{
if (mlockall(MCL_CURRENT))
{
sql_print_error("Warning: Failed to lock memory. Errno: %d\n",errno);
}
else
locked_in_memory=1;
}
#else
locked_in_memory=0;
#endif
if (opt_myisam_log)
(void) mi_log( 1 );
ft_init_stopwords(ft_precompiled_stopwords);
/*
init signals & alarm
After this we can't quit by a simple unireg_abort
*/
error_handler_hook = my_message_sql;
if (pthread_key_create(&THR_THD,NULL) ||
pthread_key_create(&THR_MALLOC,NULL))
{
sql_print_error("Can't create thread-keys");
exit(1);
}
opt_noacl = 1; // No permissions
if (acl_init(opt_noacl))
{
mysql_server_end();
return 1;
}
if (!opt_noacl)
(void) grant_init();
init_max_user_conn();
init_update_queries();
#ifdef HAVE_DLOPEN
if (!opt_noacl)
udf_init();
#endif
if (opt_bin_log)
{
if (!opt_bin_logname)
{
char tmp[FN_REFLEN];
/* TODO: The following should be using fn_format(); We just need to
first change fn_format() to cut the file name if it's too long.
*/
strmake(tmp,glob_hostname,FN_REFLEN-5);
strmov(strcend(tmp,'.'),"-bin");
opt_bin_logname=my_strdup(tmp,MYF(MY_WME));
}
open_log(&mysql_bin_log, glob_hostname, opt_bin_logname, "-bin",
opt_binlog_index_name, LOG_BIN);
using_update_log=1;
}
(void) thr_setconcurrency(concurrency); // 10 by default
if (
#ifdef HAVE_BERKELEY_DB
!berkeley_skip ||
#endif
(flush_time && flush_time != ~(ulong) 0L))
{
pthread_t hThread;
if (pthread_create(&hThread,&connection_attrib,handle_manager,0))
sql_print_error("Warning: Can't create thread to manage maintenance");
}
/*
Update mysqld variables from client variables if set
The client variables are set also by get_one_option() in mysqld.cc
*/
if (max_allowed_packet)
global_system_variables.max_allowed_packet= max_allowed_packet;
if (net_buffer_length)
global_system_variables.net_buffer_length= net_buffer_length;
return 0;
}
int STDCALL mysql_server_init(int argc, char **argv, char **groups)
{
char glob_hostname[FN_REFLEN];
......@@ -591,6 +1000,7 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
global_system_variables.net_buffer_length= net_buffer_length;
return 0;
}
#endif
void STDCALL mysql_server_end()
{
......@@ -830,8 +1240,8 @@ net_field_length(uchar **packet)
return (ulong) uint4korr(pos+1);
}
bool select_send::send_data(List<Item> &items)
#ifdef __DUMMY
bool select_send___send_data(List<Item> &items)
{
List_iterator_fast<Item> li(items);
Item *item;
......@@ -905,6 +1315,56 @@ bool select_send::send_data(List<Item> &items)
DBUG_RETURN(0);
}
#endif
bool select_send::send_data(List<Item> &items)
{
List_iterator_fast<Item> li(items);
Item *item;
MYSQL_ROWS *cur;
int n_fields= items.elements;
ulong len;
CONVERT *convert= thd->variables.convert_set;
CHARSET_INFO *charset_info= thd->packet.charset();
MYSQL_DATA *result= thd->mysql->result->data;
MEM_ROOT *alloc= &result->alloc;
MYSQL_ROW cur_field;
MYSQL_FIELD *mysql_fields= thd->mysql->result->fields;
DBUG_ENTER("send_data");
if (unit->offset_limit_cnt)
{ // using limit offset,count
unit->offset_limit_cnt--;
DBUG_RETURN(0);
}
result->rows++;
if (!(cur= (MYSQL_ROWS *)alloc_root(alloc, sizeof(MYSQL_ROWS)+(n_fields + 1) * sizeof(char *))))
{
my_error(ER_OUT_OF_RESOURCES,MYF(0));
DBUG_RETURN(1);
}
cur->data= (MYSQL_ROW)(((char *)cur) + sizeof(MYSQL_ROWS));
*result->prev_ptr= cur;
result->prev_ptr= &cur->next;
cur_field=cur->data;
for (item=li++; item; item=li++, cur_field++, mysql_fields++)
{
if (item->embedded_send(convert, charset_info, alloc, cur_field, &len))
{
my_error(ER_OUT_OF_RESOURCES,MYF(0));
DBUG_RETURN(1);
}
if (mysql_fields->max_length < len)
mysql_fields->max_length=len;
}
*cur_field= 0;
DBUG_RETURN(0);
}
bool do_command(THD *thd)
{
......
......@@ -473,3 +473,12 @@ bool CONVERT::store(String *packet,const char *from,uint length)
packet->length((uint) (to-packet->ptr()));
return 0;
}
#ifdef EMBEDDED_LIBRARY
void CONVERT::convert_back(char *dest, const char *source, uint length) const
{
for (char *end= dest+length; dest < end; dest++, source++)
*dest= to_map[*source];
}
#endif
......@@ -816,11 +816,64 @@ bool Item::send(THD *thd, String *packet)
return net_store_data(packet,res->ptr(),res->length());
}
bool Item_null::send(THD *thd, String *packet)
{
return net_store_null(packet);
}
#ifdef EMBEDDED_LIBRARY
bool Item::embedded_send(const CONVERT *convert, CHARSET_INFO *charset, MEM_ROOT *alloc,
char **result, ulong *length)
{
char buff[MAX_FIELD_WIDTH];
String s(buff, sizeof(buff), charset), *value;
if (!(value=val_str(&s)) ||
!(*result=alloc_root(alloc, value->length() + 1)))
return true;
*length= value->length();
if (convert)
convert->convert_back(*result, value->ptr(), *length);
else
memcpy(*result, value->ptr(), *length);
(*result)[*length]= 0;
return false;
}
bool Item_null::embedded_send(const CONVERT *convert, CHARSET_INFO *charset, MEM_ROOT *alloc,
char **result, ulong *length)
{
*result= NULL;
return false;
}
bool Item_field::embedded_send(const CONVERT *convert, CHARSET_INFO *charset, MEM_ROOT *alloc,
char **result, ulong *length)
{
if (result_field->is_null())
{
result= NULL;
return false;
}
char buff[MAX_FIELD_WIDTH];
String tmp(buff,sizeof(buff),default_charset_info);
result_field->val_str(&tmp,&tmp);
if (!(*result=alloc_root(alloc, tmp.length() + 1)))
return true;
*length= tmp.length();
if (convert)
convert->convert_back(*result, tmp.ptr(), *length);
else
memcpy(*result, tmp.ptr(), *length);
(*result)[*length]= 0;
return false;
}
#endif
/*
This is used for HAVING clause
Find field in select list having the same name
......
......@@ -22,6 +22,8 @@
struct st_table_list;
void item_init(void); /* Init item functions */
class CONVERT;
class Item {
Item(const Item &); /* Prevent use of these */
void operator=(Item &);
......@@ -59,6 +61,10 @@ class Item {
virtual int save_safe_in_field(Field *field)
{ return save_in_field(field); }
virtual bool send(THD *thd, String *str);
#ifdef EMBEDDED_LIBRARY
virtual bool embedded_send(const CONVERT *convert, CHARSET_INFO *charset, MEM_ROOT *alloc,
char **result, ulong *length);
#endif
virtual bool eq(const Item *, bool binary_cmp) const;
virtual Item_result result_type () const { return REAL_RESULT; }
virtual enum Type type() const =0;
......@@ -128,6 +134,10 @@ class Item_field :public Item_ident
{
return result_field->send(thd,str_arg);
}
#ifdef EMBEDDED_LIBRARY
bool embedded_send(const CONVERT *convert, CHARSET_INFO *charset, MEM_ROOT *alloc,
char **result, ulong *length);
#endif
void make_field(Send_field *field);
bool fix_fields(THD *, struct st_table_list *, Item **);
int save_in_field(Field *field);
......@@ -160,6 +170,10 @@ class Item_null :public Item
enum Item_result result_type () const
{ return STRING_RESULT; }
bool send(THD *thd, String *str);
#ifdef EMBEDDED_LIBRARY
bool embedded_send(const CONVERT *convert, CHARSET_INFO *charset, MEM_ROOT *alloc,
char **result, ulong *length);
#endif
bool basic_const_item() const { return 1; }
Item *new_item() { return new Item_null(name); }
bool is_null() { return 1; }
......@@ -423,6 +437,11 @@ class Item_ref :public Item_ident
return (null_value=(*ref)->get_date(ltime,fuzzydate));
}
bool send(THD *thd, String *tmp) { return (*ref)->send(thd, tmp); }
#ifdef EMBEDDED_LIBRARY
bool embedded_send(const CONVERT *convert, CHARSET_INFO *charset, MEM_ROOT *alloc,
char **result, ulong *length)
{ return (*ref)->embedded_send(convert, charset, alloc, result, length); }
#endif
void make_field(Send_field *field) { (*ref)->make_field(field); }
bool fix_fields(THD *, struct st_table_list *, Item **);
int save_in_field(Field *field) { return (*ref)->save_in_field(field); }
......
......@@ -1768,13 +1768,11 @@ bool open_log(MYSQL_LOG *log, const char *hostname,
no_auto_events);
}
static int init_common_variables(char *progname,
const char *conf_file_name, int argc, char **argv,
static int init_common_variables(const char *conf_file_name, int argc, char **argv,
const char **groups)
{
my_umask=0660; // Default umask for new files
my_umask_dir=0700; // Default umask for new directories
MY_INIT(progname); // init my_sys library & pthreads
umask(((~my_umask) & 0666));
tzset(); // Set tzname
......@@ -1999,7 +1997,74 @@ static void create_maintenance_thread()
}
}
#ifdef _DUMMY
static void create_shutdown_thread()
{
#ifdef __WIN__
{
hEventShutdown=CreateEvent(0, FALSE, FALSE, event_name);
pthread_t hThread;
if (pthread_create(&hThread,&connection_attrib,handle_shutdown,0))
sql_print_error("Warning: Can't create thread to handle shutdown requests");
// On "Stop Service" we have to do regular shutdown
Service.SetShutdownEvent(hEventShutdown);
}
#endif
#ifdef OS2
{
pthread_cond_init( &eventShutdown, NULL);
pthread_t hThread;
if (pthread_create(&hThread,&connection_attrib,handle_shutdown,0))
sql_print_error("Warning: Can't create thread to handle shutdown requests");
}
#endif
}
#ifdef __NT__
void create_named_pipe_thread()
{
if (hPipe == INVALID_HANDLE_VALUE &&
(!have_tcpip || opt_disable_networking))
{
sql_print_error("TCP/IP or --enable-named-pipe should be configured on NT OS");
unireg_abort(1);
}
else
{
pthread_mutex_lock(&LOCK_thread_count);
(void) pthread_cond_init(&COND_handler_count,NULL);
{
pthread_t hThread;
handler_count=0;
if (hPipe != INVALID_HANDLE_VALUE && opt_enable_named_pipe)
{
handler_count++;
if (pthread_create(&hThread,&connection_attrib,
handle_connections_namedpipes, 0))
{
sql_print_error("Warning: Can't create thread to handle named pipes");
handler_count--;
}
}
if (have_tcpip && !opt_disable_networking)
{
handler_count++;
if (pthread_create(&hThread,&connection_attrib,
handle_connections_sockets, 0))
{
sql_print_error("Warning: Can't create thread to handle named pipes");
handler_count--;
}
}
while (handler_count > 0)
pthread_cond_wait(&COND_handler_count,&LOCK_thread_count);
}
pthread_mutex_unlock(&LOCK_thread_count);
}
}
#endif
#ifdef __WIN__
int win_main(int argc, char **argv)
#else
......@@ -2009,24 +2074,17 @@ int main(int argc, char **argv)
int init_error;
DEBUGGER_OFF;
// MAIN_THD;
/*
Initialize signal_th and shutdown_th to main_th for default value
as we need to initialize them to something safe. They are used
when compiled with safemalloc.
*/
// SIGNAL_THD;
// SHUTDOWN_THD;
/*#ifdef _CUSTOMSTARTUPCONFIG_
#ifdef _CUSTOMSTARTUPCONFIG_
if (_cust_check_startup())
{
/ * _cust_check_startup will report startup failure error * /
exit( 1 );
}
#endif
*/
if ((init_error=init_common_variables(argv[0], MYSQL_CONFIG_NAME,
MY_INIT(argv[0]); // init my_sys library & pthreads
if ((init_error=init_common_variables(MYSQL_CONFIG_NAME,
argc, argv, load_default_groups)))
if (init_error == 2)
unireg_abort(1);
......@@ -2145,70 +2203,14 @@ The server will not act as a slave.");
}
}
#ifdef __WIN__
{
hEventShutdown=CreateEvent(0, FALSE, FALSE, event_name);
pthread_t hThread;
if (pthread_create(&hThread,&connection_attrib,handle_shutdown,0))
sql_print_error("Warning: Can't create thread to handle shutdown requests");
// On "Stop Service" we have to do regular shutdown
Service.SetShutdownEvent(hEventShutdown);
}
#endif
#ifdef OS2
{
pthread_cond_init( &eventShutdown, NULL);
pthread_t hThread;
if (pthread_create(&hThread,&connection_attrib,handle_shutdown,0))
sql_print_error("Warning: Can't create thread to handle shutdown requests");
}
#endif
create_shutdown_thread();
create_maintenance_thread();
printf(ER(ER_READY),my_progname,server_version,"");
fflush(stdout);
#ifdef __NT__
if (hPipe == INVALID_HANDLE_VALUE &&
(!have_tcpip || opt_disable_networking))
{
sql_print_error("TCP/IP or --enable-named-pipe should be configured on NT OS");
unireg_abort(1);
}
else
{
pthread_mutex_lock(&LOCK_thread_count);
(void) pthread_cond_init(&COND_handler_count,NULL);
{
pthread_t hThread;
handler_count=0;
if (hPipe != INVALID_HANDLE_VALUE && opt_enable_named_pipe)
{
handler_count++;
if (pthread_create(&hThread,&connection_attrib,
handle_connections_namedpipes, 0))
{
sql_print_error("Warning: Can't create thread to handle named pipes");
handler_count--;
}
}
if (have_tcpip && !opt_disable_networking)
{
handler_count++;
if (pthread_create(&hThread,&connection_attrib,
handle_connections_sockets, 0))
{
sql_print_error("Warning: Can't create thread to handle named pipes");
handler_count--;
}
}
while (handler_count > 0)
pthread_cond_wait(&COND_handler_count,&LOCK_thread_count);
}
pthread_mutex_unlock(&LOCK_thread_count);
}
create_named_pipe_thread();
#else
handle_connections_sockets(0);
#ifdef EXTRA_DEBUG2
......@@ -2254,7 +2256,8 @@ The server will not act as a slave.");
exit(0);
return(0); /* purecov: deadcode */
}
#endif
#ifdef _DUMMY
#ifdef __WIN__
int win_main(int argc, char **argv)
......@@ -2693,6 +2696,7 @@ The server will not act as a slave.");
exit(0);
return(0); /* purecov: deadcode */
}
#endif
/****************************************************************************
Main and thread entry function for Win32
......
......@@ -178,6 +178,9 @@ class CONVERT
convert_array(from_map, (uchar*) a,length);
}
bool store(String *, const char *,uint);
#ifdef EMBEDDED_LIBRARY
void convert_back(char *dest, const char *source, uint length) const;
#endif
inline uint number() { return numb; }
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment