Commit ac250625 authored by monty@hundin.mysql.fi's avatar monty@hundin.mysql.fi

portability fixes

parent 24fe09ac
......@@ -481,6 +481,27 @@ Functions i mysys: (For flags se my_sys.h)
void end_key_cache _A((void));
- End key-cacheing.
@node DBUG,,,
@chapter The DBUG tags to use:
Here is some of the tags we now use:
(We should probably add a couple of new ones)
"enter" Arguments to the function.
"exit" Results from the function.
"info" is something that may be interesting.
"warning" is when something doesn't go the usual route or may be wrong.
"error" when something went wrong.
"loop" write in a loop, that is probably only useful when debugging
the loop. These should normally be deleted when on is
satisfied with the code and it has been in real use for a while.
Some specific to mysqld, because we want to watch these carefully:
"trans" Starting/stopping transactions.
"quit" 'info' when mysqld is preparing to die.
"query" Print query
@node protocol,,,
@chapter MySQL client/server protocol
......
......@@ -334,7 +334,7 @@ bool mysql_change_db(THD *thd,const char *name)
x_free(dbname);
DBUG_RETURN(1);
}
DBUG_PRINT("general",("Use database: %s", dbname));
DBUG_PRINT("info",("Use database: %s", dbname));
if (test_all_bits(thd->master_access,DB_ACLS))
db_access=DB_ACLS;
else
......
......@@ -120,7 +120,7 @@ static bool check_user(THD *thd,enum_server_command command, const char *user,
protocol_version == 9 ||
!(thd->client_capabilities &
CLIENT_LONG_PASSWORD));
DBUG_PRINT("general",
DBUG_PRINT("info",
("Capabilities: %d packet_length: %d Host: '%s' User: '%s' Using password: %s Access: %u db: '%s'",
thd->client_capabilities, thd->max_packet_length,
thd->host_or_ip, thd->priv_user,
......@@ -323,7 +323,7 @@ check_connections(THD *thd)
*/
DBUG_PRINT("info", (("check_connections called by thread %d"),
thd->thread_id));
DBUG_PRINT("general",("New connection received on %s",
DBUG_PRINT("info",("New connection received on %s",
vio_description(net->vio)));
if (!thd->host) // If TCP/IP connection
{
......@@ -347,7 +347,7 @@ check_connections(THD *thd)
if (connect_errors > max_connect_errors)
return(ER_HOST_IS_BLOCKED);
}
DBUG_PRINT("general",("Host: %s ip: %s",
DBUG_PRINT("info",("Host: %s ip: %s",
thd->host ? thd->host : "unknown host",
thd->ip ? thd->ip : "unknown ip"));
if (acl_check_host(thd->host,thd->ip))
......@@ -355,7 +355,7 @@ check_connections(THD *thd)
}
else /* Hostname given means that the connection was on a socket */
{
DBUG_PRINT("general",("Host: %s",thd->host));
DBUG_PRINT("info",("Host: %s",thd->host));
thd->host_or_ip=thd->host;
thd->ip=0;
bzero((char*) &thd->remote,sizeof(struct sockaddr));
......@@ -731,7 +731,7 @@ bool do_command(THD *thd)
net_new_transaction(net);
if ((packet_length=my_net_read(net)) == packet_error)
{
DBUG_PRINT("general",("Got error reading command from socket %s",
DBUG_PRINT("info",("Got error reading command from socket %s",
vio_description(net->vio) ));
return TRUE;
}
......@@ -739,7 +739,7 @@ bool do_command(THD *thd)
{
packet=(char*) net->read_pos;
command = (enum enum_server_command) (uchar) packet[0];
DBUG_PRINT("general",("Command on %s = %d (%s)",
DBUG_PRINT("info",("Command on %s = %d (%s)",
vio_description(net->vio), command,
command_name[command]));
}
......
......@@ -261,7 +261,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
outparam->comment=strdup_root(&outparam->mem_root,
(char*) head+47);
DBUG_PRINT("form",("i_count: %d i_parts: %d index: %d n_length: %d int_length: %d", interval_count,interval_parts, outparam->keys,n_length,int_length));
DBUG_PRINT("info",("i_count: %d i_parts: %d index: %d n_length: %d int_length: %d", interval_count,interval_parts, outparam->keys,n_length,int_length));
if (!(field_ptr = (Field **)
alloc_root(&outparam->mem_root,
......
......@@ -297,9 +297,8 @@ static int authenticate(struct manager_thd* thd);
static char* read_line(struct manager_thd* thd); /* returns pointer to end of
line
*/
static pthread_handler_decl(process_connection,arg);
static pthread_handler_decl(process_launcher_messages,
__attribute__((unused)) arg);
static pthread_handler_decl(process_connection, arg);
static pthread_handler_decl(process_launcher_messages, arg);
static int exec_line(struct manager_thd* thd,char* buf,char* buf_end);
#ifdef DO_STACKTRACE
......@@ -1024,7 +1023,8 @@ static void log_msg(const char* fmt, int msg_type, va_list args)
pthread_mutex_unlock(&lock_log);
}
#define LOG_MSG_FUNC(type,TYPE) inline static void type \
/* No 'inline' here becasue functions with ... can't do that portable */
#define LOG_MSG_FUNC(type,TYPE) static void type \
(const char* fmt,...) { \
va_list args; \
va_start(args,fmt); \
......@@ -1038,7 +1038,7 @@ LOG_MSG_FUNC(log_info,LOG_INFO)
#ifndef DBUG_OFF
LOG_MSG_FUNC(log_debug,LOG_DEBUG)
#else
inline void log_debug(const char* __attribute__((unused)) fmt,...) {}
void log_debug(const char* __attribute__((unused)) fmt,...) {}
#endif
static pthread_handler_decl(process_launcher_messages,
......@@ -1367,6 +1367,12 @@ static int run_server_loop()
int client_sock;
uint len;
Vio* vio;
pthread_attr_t thr_attr;
(void) pthread_attr_init(&thr_attr);
#if !defined(HAVE_DEC_3_2_THREADS)
pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_SYSTEM);
(void) pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED);
#endif
for (;!shutdown_requested;)
{
......@@ -1412,7 +1418,7 @@ static int run_server_loop()
manager_thd_free(thd);
continue;
}
else if (pthread_create(&th,0,process_connection,(void*)thd))
else if (pthread_create(&th,&thr_attr,process_connection,(void*)thd))
{
client_msg(vio,MANAGER_INTERNAL_ERR,"Could not create thread, errno=%d",
errno);
......@@ -1420,6 +1426,7 @@ static int run_server_loop()
continue;
}
}
(void) pthread_attr_destroy(&thr_attr);
return 0;
}
......@@ -1659,13 +1666,20 @@ static void init_user_hash()
static void init_globals()
{
pthread_attr_t thr_attr;
if (hash_init(&exec_hash,1024,0,0,get_exec_key,manager_exec_free,MYF(0)))
die("Exec hash initialization failed");
if (!one_thread)
{
(void) pthread_attr_init(&thr_attr);
#if !defined(HAVE_DEC_3_2_THREADS)
pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_SYSTEM);
(void) pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED);
#endif
fork_launcher();
if (pthread_create(&launch_msg_th,0,process_launcher_messages,0))
if (pthread_create(&launch_msg_th,&thr_attr,process_launcher_messages,0))
die("Could not start launcher message handler thread");
/* (void) pthread_attr_destroy(&thr_attr); */
}
init_user_hash();
loop_th=pthread_self();
......
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