summaryrefslogtreecommitdiff
path: root/server-tools
diff options
context:
space:
mode:
Diffstat (limited to 'server-tools')
-rw-r--r--server-tools/instance-manager/buffer.cc2
-rw-r--r--server-tools/instance-manager/commands.cc18
-rw-r--r--server-tools/instance-manager/instance.cc2
-rw-r--r--server-tools/instance-manager/instance_map.cc2
-rw-r--r--server-tools/instance-manager/instance_options.cc8
-rw-r--r--server-tools/instance-manager/listener.cc33
-rw-r--r--server-tools/instance-manager/mysql_connection.cc4
-rw-r--r--server-tools/instance-manager/options.cc2
-rw-r--r--server-tools/instance-manager/parse.cc2
-rw-r--r--server-tools/instance-manager/parse.h2
-rw-r--r--server-tools/instance-manager/parse_output.cc8
-rw-r--r--server-tools/instance-manager/protocol.cc12
-rw-r--r--server-tools/instance-manager/user_map.cc2
13 files changed, 62 insertions, 35 deletions
diff --git a/server-tools/instance-manager/buffer.cc b/server-tools/instance-manager/buffer.cc
index a782c2ae33e..57dd1c72f23 100644
--- a/server-tools/instance-manager/buffer.cc
+++ b/server-tools/instance-manager/buffer.cc
@@ -100,7 +100,7 @@ err:
int Buffer::get_size()
{
- return buffer_size;
+ return (uint) buffer_size;
}
diff --git a/server-tools/instance-manager/commands.cc b/server-tools/instance-manager/commands.cc
index 01afa703a47..bb3763ce8c5 100644
--- a/server-tools/instance-manager/commands.cc
+++ b/server-tools/instance-manager/commands.cc
@@ -52,11 +52,11 @@
static inline int put_to_buff(Buffer *buff, const char *str, uint *position)
{
- uint len= strlen(str);
- if (buff->append(*position, str, len))
+ size_t len= strlen(str);
+ if (buff->append(*position, str, (uint) len))
return 1;
- *position+= len;
+ *position+= (uint) len;
return 0;
}
@@ -201,7 +201,7 @@ int Show_instance_status::execute(struct st_net *net,
Instance *instance;
store_to_protocol_packet(&send_buff, (char*) instance_name, &position);
- if (!(instance= instance_map->find(instance_name, strlen(instance_name))))
+ if (!(instance= instance_map->find(instance_name, (uint) strlen(instance_name))))
goto err;
if (instance->is_running())
store_to_protocol_packet(&send_buff, (char*) "online", &position);
@@ -272,7 +272,7 @@ int Show_instance_options::execute(struct st_net *net, ulong connection_id)
{
Instance *instance;
- if (!(instance= instance_map->find(instance_name, strlen(instance_name))))
+ if (!(instance= instance_map->find(instance_name, (uint) strlen(instance_name))))
goto err;
store_to_protocol_packet(&send_buff, (char*) "instance_name", &position);
store_to_protocol_packet(&send_buff, (char*) instance_name, &position);
@@ -452,7 +452,7 @@ int Show_instance_log::execute(struct st_net *net, ulong connection_id)
File fd;
if ((instance= instance_map->find(instance_name,
- strlen(instance_name))) == NULL)
+ (uint) strlen(instance_name))) == NULL)
goto err;
logpath= instance->options.logs[log_type];
@@ -479,13 +479,13 @@ int Show_instance_log::execute(struct st_net *net, ulong connection_id)
buff_size= (size - offset);
- read_buff.reserve(0, buff_size);
+ read_buff.reserve(0, (uint) buff_size);
/* read in one chunk */
read_len= (int)my_seek(fd, file_stat.st_size - size, MY_SEEK_SET, MYF(0));
if ((read_len= my_read(fd, (byte*) read_buff.buffer,
- buff_size, MYF(0))) < 0)
+ (uint) buff_size, MYF(0))) < 0)
return ER_READ_FILE;
store_to_protocol_packet(&send_buff, read_buff.buffer,
&position, read_len);
@@ -569,7 +569,7 @@ int Show_instance_log_files::execute(struct st_net *net, ulong connection_id)
Instance *instance;
if ((instance= instance_map->
- find(instance_name, strlen(instance_name))) == NULL)
+ find(instance_name, (uint) strlen(instance_name))) == NULL)
goto err;
{
diff --git a/server-tools/instance-manager/instance.cc b/server-tools/instance-manager/instance.cc
index 58fe7569db7..e08bf2f66df 100644
--- a/server-tools/instance-manager/instance.cc
+++ b/server-tools/instance-manager/instance.cc
@@ -173,7 +173,7 @@ static int start_process(Instance_options *instance_options,
int cmdlen= 0;
for (int i= 0; instance_options->argv[i] != 0; i++)
- cmdlen+= strlen(instance_options->argv[i]) + 3;
+ cmdlen+= (uint) strlen(instance_options->argv[i]) + 3;
cmdlen++; /* make room for the null */
char *cmdline= new char[cmdlen];
diff --git a/server-tools/instance-manager/instance_map.cc b/server-tools/instance-manager/instance_map.cc
index 39fd20cbc2d..571826edd7b 100644
--- a/server-tools/instance-manager/instance_map.cc
+++ b/server-tools/instance-manager/instance_map.cc
@@ -112,7 +112,7 @@ int Instance_map::process_one_option(const char *group, const char *option)
|| group[sizeof(prefix)] == '\0'))
{
if (!(instance= (Instance *) hash_search(&hash, (byte *) group,
- strlen(group))))
+ (uint) strlen(group))))
{
if (!(instance= new Instance))
goto err;
diff --git a/server-tools/instance-manager/instance_options.cc b/server-tools/instance-manager/instance_options.cc
index d4ca2ad570f..9d88bb0e669 100644
--- a/server-tools/instance-manager/instance_options.cc
+++ b/server-tools/instance-manager/instance_options.cc
@@ -257,7 +257,7 @@ int Instance_options::fill_log_options()
strmov(hostname, "mysql");
hostname[MAX_LOG_OPTION_LENGTH - 1]= 0; /* Safety */
- hostname_length= strlen(hostname);
+ hostname_length= (uint) strlen(hostname);
for (log_files= logs_st; log_files->name; log_files++)
@@ -392,7 +392,7 @@ int Instance_options::complete_initialization(const char *default_path,
if (!mysqld_path)
{
// Need one extra byte, as convert_dirname() adds a slash at the end.
- if (!(mysqld_path= alloc_root(&alloc, strlen(default_path) + 2)))
+ if (!(mysqld_path= alloc_root(&alloc, (uint) strlen(default_path) + 2)))
goto err;
strcpy((char *)mysqld_path, default_path);
}
@@ -401,7 +401,7 @@ int Instance_options::complete_initialization(const char *default_path,
end= convert_dirname((char*)mysqld_path, mysqld_path, NullS);
end[-1]= 0;
- mysqld_path_len= strlen(mysqld_path);
+ mysqld_path_len= (uint) strlen(mysqld_path);
if (mysqld_port)
mysqld_port_val= atoi(strchr(mysqld_port, '=') + 1);
@@ -572,7 +572,7 @@ void Instance_options::print_argv()
int Instance_options::init(const char *instance_name_arg)
{
- instance_name_len= strlen(instance_name_arg);
+ instance_name_len= (uint) strlen(instance_name_arg);
init_alloc_root(&alloc, MEM_ROOT_BLOCK_SIZE, 0);
diff --git a/server-tools/instance-manager/listener.cc b/server-tools/instance-manager/listener.cc
index a950ecf4ed3..36f0cbe85e1 100644
--- a/server-tools/instance-manager/listener.cc
+++ b/server-tools/instance-manager/listener.cc
@@ -35,23 +35,28 @@
#include "portability.h"
+#ifndef __WIN__
static void set_non_blocking(int socket)
{
-#ifndef __WIN__
int flags= fcntl(socket, F_GETFL, 0);
fcntl(socket, F_SETFL, flags | O_NONBLOCK);
#else
+static void set_non_blocking(SOCKET socket)
+{
u_long arg= 1;
ioctlsocket(socket, FIONBIO, &arg);
#endif
}
+#ifndef __WIN__
static void set_no_inherit(int socket)
{
-#ifndef __WIN__
int flags= fcntl(socket, F_GETFD, 0);
fcntl(socket, F_SETFD, flags | FD_CLOEXEC);
+#else
+static void set_no_inherit(SOCKET socket)
+{
#endif
}
@@ -71,7 +76,11 @@ private:
ulong total_connection_count;
Thread_info thread_info;
+#ifdef __WIN__
+ SOCKET sockets[2];
+#else
int sockets[2];
+#endif
int num_sockets;
fd_set read_fds;
private:
@@ -110,9 +119,10 @@ Listener_thread::~Listener_thread()
void Listener_thread::run()
{
- int i, n= 0;
+ int i= 0;
#ifndef __WIN__
+ int n= 0;
/* we use this var to check whether we are running on LinuxThreads */
pid_t thread_pid;
@@ -121,6 +131,8 @@ void Listener_thread::run()
struct sockaddr_un unix_socket_address;
/* set global variable */
linuxthreads= (thread_pid != manager_pid);
+#else
+ SOCKET n= 0;
#endif
thread_registry.register_thread(&thread_info);
@@ -159,7 +171,11 @@ void Listener_thread::run()
signal during shutdown. This results in failing assert
(Thread_registry::~Thread_registry). Valgrind 2.2 works fine.
*/
+#ifdef __WIN__
+ int rc= select(0, &read_fds_arg, 0, 0, &tv);
+#else
int rc= select(n, &read_fds_arg, 0, 0, &tv);
+#endif
if (rc == 0 || rc == -1)
{
@@ -175,11 +191,18 @@ void Listener_thread::run()
/* Assuming that rc > 0 as we asked to wait forever */
if (FD_ISSET(sockets[socket_index], &read_fds_arg))
{
+#ifdef __WIN__
+ SOCKET client_fd= accept(sockets[socket_index], 0, 0);
+ /* accept may return INVALID_SOCKET on failure */
+ if (client_fd != INVALID_SOCKET)
+ {
+#else
int client_fd= accept(sockets[socket_index], 0, 0);
/* accept may return -1 (failure or spurious wakeup) */
if (client_fd >= 0) // connection established
{
set_no_inherit(client_fd);
+#endif
Vio *vio= vio_new(client_fd, socket_index == 0 ?
VIO_TYPE_SOCKET : VIO_TYPE_TCPIP,
@@ -230,7 +253,11 @@ int Listener_thread::create_tcp_socket()
/* value to be set by setsockopt */
int arg= 1;
+#ifdef __WIN__
+ SOCKET ip_socket= socket(AF_INET, SOCK_STREAM, 0);
+#else
int ip_socket= socket(AF_INET, SOCK_STREAM, 0);
+#endif
if (ip_socket == INVALID_SOCKET)
{
log_error("Listener_thead::run(): socket(AF_INET) failed, %s",
diff --git a/server-tools/instance-manager/mysql_connection.cc b/server-tools/instance-manager/mysql_connection.cc
index 2b377d60ad0..1803108c39d 100644
--- a/server-tools/instance-manager/mysql_connection.cc
+++ b/server-tools/instance-manager/mysql_connection.cc
@@ -241,7 +241,7 @@ int Mysql_connection_thread::check_connection()
/* write connection message and read reply */
enum { MIN_HANDSHAKE_SIZE= 2 };
- if (net_write_command(&net, protocol_version, "", 0, buff, pos - buff) ||
+ if (net_write_command(&net, protocol_version, "", 0, buff, (uint) (pos - buff)) ||
(pkt_len= my_net_read(&net)) == packet_error ||
pkt_len < MIN_HANDSHAKE_SIZE)
{
@@ -275,7 +275,7 @@ int Mysql_connection_thread::check_connection()
net_send_error(&net, ER_ACCESS_DENIED_ERROR);
return 1;
}
- if (user_map.authenticate(user, password-user-2, password, scramble))
+ if (user_map.authenticate(user, (uint) (password - user - 2), password, scramble))
{
net_send_error(&net, ER_ACCESS_DENIED_ERROR);
return 1;
diff --git a/server-tools/instance-manager/options.cc b/server-tools/instance-manager/options.cc
index f7eab075952..9eb148c4e3b 100644
--- a/server-tools/instance-manager/options.cc
+++ b/server-tools/instance-manager/options.cc
@@ -59,7 +59,7 @@ char **Options::saved_argv= NULL;
bool Options::is_forced_default_file= 0;
static const char * const ANGEL_PID_FILE_SUFFIX= ".angel.pid";
-static const int ANGEL_PID_FILE_SUFFIX_LEN= strlen(ANGEL_PID_FILE_SUFFIX);
+static const int ANGEL_PID_FILE_SUFFIX_LEN= (uint) strlen(ANGEL_PID_FILE_SUFFIX);
/*
List of options, accepted by the instance manager.
diff --git a/server-tools/instance-manager/parse.cc b/server-tools/instance-manager/parse.cc
index 71f69b596c1..bbbadf3e91a 100644
--- a/server-tools/instance-manager/parse.cc
+++ b/server-tools/instance-manager/parse.cc
@@ -177,7 +177,7 @@ Command *parse_command(Instance_map *map, const char *text)
get_word(&text, &option_len, NONSPACE);
option= text;
if ((tmp= strchr(text, '=')) != NULL)
- option_len= tmp - text;
+ option_len= (uint) (tmp - text);
text+= option_len;
get_word(&text, &word_len);
diff --git a/server-tools/instance-manager/parse.h b/server-tools/instance-manager/parse.h
index 5e9f33beb11..9f7f7d7933c 100644
--- a/server-tools/instance-manager/parse.h
+++ b/server-tools/instance-manager/parse.h
@@ -58,7 +58,7 @@ inline void get_word(const char **text, uint *word_len,
(*word_end != '\0'))
++word_end;
- *word_len= word_end - *text;
+ *word_len= (uint) (word_end - *text);
}
#endif /* INCLUDES_MYSQL_INSTANCE_MANAGER_PARSE_H */
diff --git a/server-tools/instance-manager/parse_output.cc b/server-tools/instance-manager/parse_output.cc
index f8ddf5a2d08..377671b4401 100644
--- a/server-tools/instance-manager/parse_output.cc
+++ b/server-tools/instance-manager/parse_output.cc
@@ -30,11 +30,11 @@ void trim_space(const char **text, uint *word_len)
start++;
*text= start;
- int len= strlen(start);
+ size_t len= strlen(start);
const char *end= start + len - 1;
while (end > start && my_isspace(&my_charset_latin1, *end))
end--;
- *word_len= (end - start)+1;
+ *word_len= (uint) (end - start)+1;
}
/*
@@ -65,7 +65,7 @@ int parse_output_and_get_value(const char *command, const char *word,
uint flag)
{
FILE *output;
- uint wordlen;
+ size_t wordlen;
/* should be enough to store the string from the output */
enum { MAX_LINE_LEN= 512 };
char linebuf[MAX_LINE_LEN];
@@ -111,7 +111,7 @@ int parse_output_and_get_value(const char *command, const char *word,
strmake(result, linep, found_word_len);
}
else /* currently there are only two options */
- strmake(result, linep, input_buffer_len - 1);
+ strmake(result, linep, (uint) (input_buffer_len - 1));
rc= 0;
break;
}
diff --git a/server-tools/instance-manager/protocol.cc b/server-tools/instance-manager/protocol.cc
index 6c7a7f0ecfa..faeee4e95e9 100644
--- a/server-tools/instance-manager/protocol.cc
+++ b/server-tools/instance-manager/protocol.cc
@@ -53,11 +53,11 @@ int net_send_ok(struct st_net *net, unsigned long connection_id,
int2store(pos, 0);
pos+= 2;
- uint position= pos - buff.buffer; /* we might need it for message */
+ uint position= (uint) (pos - buff.buffer); /* we might need it for message */
if (message != NULL)
{
- buff.reserve(position, 9 + strlen(message));
+ buff.reserve(position, 9 + (uint) strlen(message));
store_to_protocol_packet(&buff, message, &position);
}
@@ -82,7 +82,7 @@ int net_send_error(struct st_net *net, uint sql_errno)
memcpy(pos, errno_to_sqlstate(sql_errno), SQLSTATE_LENGTH);
pos+= SQLSTATE_LENGTH;
pos= strmake(pos, err, MYSQL_ERRMSG_SIZE - 1) + 1;
- return my_net_write(net, buff, pos - buff) || net_flush(net);
+ return my_net_write(net, buff, (uint) (pos - buff)) || net_flush(net);
}
@@ -98,7 +98,7 @@ int net_send_error_323(struct st_net *net, uint sql_errno)
int2store(pos, sql_errno);
pos+= 2;
pos= strmake(pos, err, MYSQL_ERRMSG_SIZE - 1) + 1;
- return my_net_write(net, buff, pos - buff) || net_flush(net);
+ return my_net_write(net, buff, (uint) (pos - buff)) || net_flush(net);
}
char *net_store_length(char *pkg, uint length)
@@ -123,7 +123,7 @@ int store_to_protocol_packet(Buffer *buf, const char *string, uint *position,
/* reserve max amount of bytes needed to store length */
if (buf->reserve(*position, 9))
goto err;
- currpos= (net_store_length(buf->buffer + *position,
+ currpos= (uint) (net_store_length(buf->buffer + *position,
(ulonglong) string_len) - buf->buffer);
if (buf->append(currpos, string, string_len))
goto err;
@@ -139,7 +139,7 @@ int store_to_protocol_packet(Buffer *buf, const char *string, uint *position)
{
uint string_len;
- string_len= strlen(string);
+ string_len= (uint) strlen(string);
return store_to_protocol_packet(buf, string, position, string_len);
}
diff --git a/server-tools/instance-manager/user_map.cc b/server-tools/instance-manager/user_map.cc
index 2f77d2f59c1..7871cad7814 100644
--- a/server-tools/instance-manager/user_map.cc
+++ b/server-tools/instance-manager/user_map.cc
@@ -55,7 +55,7 @@ int User::init(const char *line)
goto err;
password= name_end + 1;
}
- user_length= name_end - name_begin;
+ user_length= (uint) (name_end - name_begin);
if (user_length > USERNAME_LENGTH)
goto err;