Commit bb8e5b62 authored by petr@mysql.com's avatar petr@mysql.com

various fixes

parent 6b50b5b0
......@@ -81,10 +81,10 @@ int Buffer::reserve(uint position, uint len_arg)
if (position + len_arg>= buffer_size)
{
buffer= (char *) realloc(buffer,
min(MAX_BUFFER_SIZE,
max((uint) (buffer_size*1.5),
position + len_arg)));
buffer= (char *) my_realloc(buffer,
min(MAX_BUFFER_SIZE,
max((uint) (buffer_size*1.5),
position + len_arg)), MYF(0));
if (buffer == NULL)
goto err;
buffer_size= (uint) (buffer_size*1.5);
......
......@@ -17,6 +17,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <my_global.h>
#include <my_sys.h>
#ifdef __GNUC__
#pragma interface
......@@ -45,7 +46,7 @@ class Buffer
/*
As append() will invokes realloc() anyway, it's ok if malloc returns 0
*/
if (!(buffer= (char*) malloc(buffer_size)))
if (!(buffer= (char*) my_malloc(buffer_size, MYF(0))))
buffer_size= 0;
}
......
......@@ -184,8 +184,8 @@ int Show_instance_status::do_command(struct st_net *net,
}
if (my_net_write(net, send_buff.buffer, (uint) position) ||
send_buff.is_error())
if (send_buff.is_error() ||
my_net_write(net, send_buff.buffer, (uint) position))
goto err;
}
......@@ -271,8 +271,8 @@ int Show_instance_options::do_command(struct st_net *net,
store_to_string(&send_buff,
(char *) instance->options.mysqld_path,
&position);
if (my_net_write(net, send_buff.buffer, (uint) position) ||
send_buff.is_error())
if (send_buff.is_error() ||
my_net_write(net, send_buff.buffer, (uint) position))
goto err;
}
......@@ -281,8 +281,8 @@ int Show_instance_options::do_command(struct st_net *net,
position= 0;
store_to_string(&send_buff, (char *) "nonguarded", &position);
store_to_string(&send_buff, "", &position);
if (my_net_write(net, send_buff.buffer, (uint) position) ||
send_buff.is_error())
if (send_buff.is_error() ||
my_net_write(net, send_buff.buffer, (uint) position))
goto err;
}
......@@ -299,8 +299,8 @@ int Show_instance_options::do_command(struct st_net *net,
store_to_string(&send_buff, option_value + 1, &position);
/* join name and the value into the same option again */
*option_value= '=';
if (my_net_write(net, send_buff.buffer, (uint) position) ||
send_buff.is_error())
if (send_buff.is_error() ||
my_net_write(net, send_buff.buffer, (uint) position))
goto err;
}
}
......
......@@ -80,9 +80,7 @@ void Instance_options::get_pid_filename(char *result)
char datadir[MAX_PATH_LEN];
if (mysqld_datadir == NULL)
{
get_default_option(datadir, sizeof(datadir), "--datadir");
}
else
strxnmov(datadir, MAX_PATH_LEN - 1, strchr(mysqld_datadir, '=') + 1,
"/", NullS);
......@@ -106,8 +104,8 @@ pid_t Instance_options::get_pid()
FILE *pid_file_stream;
/* get the pid */
if (pid_file_stream= my_fopen(pid_file_with_path,
O_RDONLY | O_BINARY, MYF(0)))
if ((pid_file_stream= my_fopen(pid_file_with_path,
O_RDONLY | O_BINARY, MYF(0))) != NULL)
{
pid_t pid;
......
......@@ -171,7 +171,14 @@ void manager(const Options &options)
while (!shutdown_complete)
{
sigwait(&mask, &signo);
int status= 0;
if (status= my_sigwait(&mask, &signo))
{
log_error("sigwait() failed");
goto err;
}
switch (signo)
{
case THR_SERVER_ALARM:
......
......@@ -36,6 +36,10 @@
DESCRIPTION
Parse output of the "command". Find the "word" and return the next one
RETURN
0 - ok
1 - error occured
*/
int parse_output_and_get_value(const char *command, const char *word,
......@@ -49,7 +53,8 @@ int parse_output_and_get_value(const char *command, const char *word,
wordlen= strlen(word);
output= popen(command, "r");
if ((output= popen(command, "r")) == NULL)
goto err;
/*
We want fully buffered stream. We also want system to
......@@ -69,15 +74,18 @@ int parse_output_and_get_value(const char *command, const char *word,
these are '/', '-' and '.' in the path expressions and filenames)
*/
get_word((const char **) &linep, &lineword_len, NONSPACE);
if (!strncmp(word, linep, wordlen) && *result != '\0')
if (!strncmp(word, linep, wordlen))
{
/*
If we have found the word, return the next one. This is usually
an option value.
*/
linep+= lineword_len; /* swallow the previous one */
get_word((const char **) &linep, &lineword_len, NONSPACE);
DBUG_ASSERT(result_len > lineword_len);
if (result_len <= lineword_len)
goto err;
strncpy(result, linep, lineword_len);
result[lineword_len]= '\0';
goto pclose;
}
}
......@@ -87,4 +95,7 @@ int parse_output_and_get_value(const char *command, const char *word,
return 1;
return 0;
err:
return 1;
}
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