Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
65d79b9d
Commit
65d79b9d
authored
Jun 07, 2005
by
petr@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
post-review fixes
parent
c7581758
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
60 additions
and
57 deletions
+60
-57
server-tools/instance-manager/commands.cc
server-tools/instance-manager/commands.cc
+0
-4
server-tools/instance-manager/instance.cc
server-tools/instance-manager/instance.cc
+2
-2
server-tools/instance-manager/instance.h
server-tools/instance-manager/instance.h
+1
-1
server-tools/instance-manager/instance_map.cc
server-tools/instance-manager/instance_map.cc
+2
-2
server-tools/instance-manager/instance_options.cc
server-tools/instance-manager/instance_options.cc
+23
-19
server-tools/instance-manager/instance_options.h
server-tools/instance-manager/instance_options.h
+4
-2
server-tools/instance-manager/listener.cc
server-tools/instance-manager/listener.cc
+1
-1
server-tools/instance-manager/log.cc
server-tools/instance-manager/log.cc
+1
-1
server-tools/instance-manager/parse_output.cc
server-tools/instance-manager/parse_output.cc
+22
-23
server-tools/instance-manager/parse_output.h
server-tools/instance-manager/parse_output.h
+4
-2
No files found.
server-tools/instance-manager/commands.cc
View file @
65d79b9d
...
...
@@ -644,10 +644,6 @@ Set_option::Set_option(Instance_map *instance_map_arg,
{
strmake
(
option
,
option_arg
,
option_len_arg
);
strmake
(
option_value
,
option_value_arg
,
option_value_len_arg
);
/* strncpy(option, option_arg, option_len_arg);
option[option_len_arg]= 0;
strncpy(option_value, option_value_arg, option_value_len_arg);
option_value[option_value_len_arg]= 0; */
}
else
{
...
...
server-tools/instance-manager/instance.cc
View file @
65d79b9d
...
...
@@ -326,8 +326,8 @@ int Instance::init(const char *name_arg)
int
Instance
::
complete_initialization
(
Instance_map
*
instance_map_arg
,
const
char
*
mysqld_path
,
int
only_instanc
e
)
uint
instance_typ
e
)
{
instance_map
=
instance_map_arg
;
return
options
.
complete_initialization
(
mysqld_path
,
only_instanc
e
);
return
options
.
complete_initialization
(
mysqld_path
,
instance_typ
e
);
}
server-tools/instance-manager/instance.h
View file @
65d79b9d
...
...
@@ -33,7 +33,7 @@ class Instance
~
Instance
();
int
init
(
const
char
*
name
);
int
complete_initialization
(
Instance_map
*
instance_map_arg
,
const
char
*
mysqld_path
,
int
only_instance
=
0
);
const
char
*
mysqld_path
,
uint
instance_type
);
bool
is_running
();
int
start
();
...
...
server-tools/instance-manager/instance_map.cc
View file @
65d79b9d
...
...
@@ -202,14 +202,14 @@ int Instance_map::complete_initialization()
hash_free should handle it's deletion => goto err, not
err_instance.
*/
if
(
instance
->
complete_initialization
(
this
,
mysqld_path
,
1
))
if
(
instance
->
complete_initialization
(
this
,
mysqld_path
,
DEFAULT_SINGLE_INSTANCE
))
goto
err
;
}
else
while
(
i
<
hash
.
records
)
{
instance
=
(
Instance
*
)
hash_element
(
&
hash
,
i
);
if
(
instance
->
complete_initialization
(
this
,
mysqld_path
))
if
(
instance
->
complete_initialization
(
this
,
mysqld_path
,
USUAL_INSTANCE
))
goto
err
;
i
++
;
}
...
...
server-tools/instance-manager/instance_options.cc
View file @
65d79b9d
...
...
@@ -95,7 +95,7 @@ int Instance_options::get_default_option(char *result, size_t result_len,
/* +2 eats first "--" from the option string (E.g. "--datadir") */
rc
=
parse_output_and_get_value
(
cmd
.
buffer
,
option_name
+
2
,
result
,
result_len
);
result
,
result_len
,
GET_VALUE
);
return
rc
;
err:
...
...
@@ -121,9 +121,8 @@ int Instance_options::get_default_option(char *result, size_t result_len,
int
Instance_options
::
fill_instance_version
()
{
enum
{
MAX_VERSION_STRING_LENGTH
=
160
};
enum
{
RETURN_LINE
=
1
};
char
result
[
MAX_VERSION_STRING_LENGTH
];
char
version_option
[]
=
" --version"
;
char
version_option
[]
=
" --
no-defaults --
version"
;
int
rc
=
1
;
Buffer
cmd
(
mysqld_path_len
+
sizeof
(
version_option
));
...
...
@@ -133,7 +132,7 @@ int Instance_options::fill_instance_version()
rc
=
parse_output_and_get_value
(
cmd
.
buffer
,
mysqld_path
,
result
,
MAX_VERSION_STRING_LENGTH
,
RETURN
_LINE
);
GET
_LINE
);
if
(
*
result
!=
'\0'
)
{
...
...
@@ -198,8 +197,8 @@ int Instance_options::fill_log_options()
goto
err
;
}
else
/* below is safe, as --datadir always has a value */
str
ncpy
(
datadir
,
strchr
(
mysqld_datadir
,
'='
)
+
1
,
MAX_LOG_OPTION_LENGTH
);
str
make
(
datadir
,
strchr
(
mysqld_datadir
,
'='
)
+
1
,
MAX_LOG_OPTION_LENGTH
-
1
);
if
(
gethostname
(
hostname
,
sizeof
(
hostname
)
-
1
)
<
0
)
strmov
(
hostname
,
"mysql"
);
...
...
@@ -232,7 +231,7 @@ int Instance_options::fill_log_options()
if
((
MAX_LOG_OPTION_LENGTH
-
strlen
(
full_name
))
>
strlen
(
log_files
->
default_suffix
))
{
str
cpy
(
full_name
+
strlen
(
full_name
),
str
mov
(
full_name
+
strlen
(
full_name
),
log_files
->
default_suffix
);
}
else
...
...
@@ -338,7 +337,7 @@ pid_t Instance_options::get_pid()
int
Instance_options
::
complete_initialization
(
const
char
*
default_path
,
int
only_instanc
e
)
uint
instance_typ
e
)
{
const
char
*
tmp
;
...
...
@@ -369,18 +368,23 @@ int Instance_options::complete_initialization(const char *default_path,
found, we would like to model mysqld pid file values.
*/
if
(
!
gethostname
(
hostname
,
sizeof
(
hostname
)
-
1
))
(
only_instance
==
0
)
?
strxnmov
(
pidfilename
,
MAX_PATH_LEN
-
1
,
"--pid-file="
,
instance_name
,
"-"
,
hostname
,
".pid"
,
NullS
)
:
strxnmov
(
pidfilename
,
MAX_PATH_LEN
-
1
,
"--pid-file="
,
hostname
,
".pid"
,
NullS
);
{
if
(
instance_type
&
DEFAULT_SINGLE_INSTANCE
)
strxnmov
(
pidfilename
,
MAX_PATH_LEN
-
1
,
"--pid-file="
,
instance_name
,
"-"
,
hostname
,
".pid"
,
NullS
);
else
strxnmov
(
pidfilename
,
MAX_PATH_LEN
-
1
,
"--pid-file="
,
hostname
,
".pid"
,
NullS
);
}
else
(
only_instance
==
0
)
?
strxnmov
(
pidfilename
,
MAX_PATH_LEN
-
1
,
"--pid-file="
,
instance_name
,
".pid"
,
NullS
)
:
strxnmov
(
pidfilename
,
MAX_PATH_LEN
-
1
,
"--pid-file="
,
"mysql"
,
".pid"
,
NullS
);
{
if
(
instance_type
&
DEFAULT_SINGLE_INSTANCE
)
strxnmov
(
pidfilename
,
MAX_PATH_LEN
-
1
,
"--pid-file="
,
instance_name
,
".pid"
,
NullS
);
else
strxnmov
(
pidfilename
,
MAX_PATH_LEN
-
1
,
"--pid-file="
,
"mysql"
,
".pid"
,
NullS
);
}
add_option
(
pidfilename
);
}
...
...
server-tools/instance-manager/instance_options.h
View file @
65d79b9d
...
...
@@ -34,6 +34,8 @@
don't have to synchronize between threads.
*/
enum
{
USUAL_INSTANCE
=
0
,
DEFAULT_SINGLE_INSTANCE
};
class
Instance_options
{
public:
...
...
@@ -45,7 +47,7 @@ class Instance_options
{}
~
Instance_options
();
/* fills in argv */
int
complete_initialization
(
const
char
*
default_path
,
int
only_instanc
e
);
int
complete_initialization
(
const
char
*
default_path
,
uint
instance_typ
e
);
int
add_option
(
const
char
*
option
);
int
init
(
const
char
*
instance_name_arg
);
...
...
@@ -66,7 +68,7 @@ class Instance_options
char
**
argv
;
/*
Here we cache the version string, obtained from mysqld --version.
In the case when mysqld binary is not found we get
"unknown"
here.
In the case when mysqld binary is not found we get
NULL
here.
*/
const
char
*
mysqld_version
;
/* We need the some options, so we store them as a separate pointers */
...
...
server-tools/instance-manager/listener.cc
View file @
65d79b9d
...
...
@@ -163,7 +163,7 @@ void Listener_thread::run()
unix_socket_address
.
sun_family
=
AF_UNIX
;
strmake
(
unix_socket_address
.
sun_path
,
options
.
socket_file_name
,
sizeof
(
unix_socket_address
.
sun_path
));
unlink
(
unix_socket_address
.
sun_path
);
/
/ in case we have stale socket file
unlink
(
unix_socket_address
.
sun_path
);
/
* in case we have stale socket file */
{
/*
...
...
server-tools/instance-manager/log.cc
View file @
65d79b9d
...
...
@@ -76,7 +76,7 @@ static inline void log(FILE *file, const char *format, va_list args)
if
(
buff_msg
==
0
)
{
strmake
(
buff_stack
,
"log(): message is too big, my_malloc() failed"
,
sizeof
(
buff_stack
));
sizeof
(
buff_stack
)
-
1
);
buff_msg
=
buff_stack
;
break
;
}
...
...
server-tools/instance-manager/parse_output.cc
View file @
65d79b9d
...
...
@@ -16,10 +16,11 @@
#include <my_global.h>
#include "parse.h"
#include "parse_output.h"
#include <stdio.h>
#include <my_sys.h>
#include <string.h>
#include <
m_
string.h>
/*
...
...
@@ -28,17 +29,17 @@
SYNOPSYS
parse_output_and_get_value()
command the command to execue with popen.
word the word to look for (usually an option name)
result the buffer to store the next word (option value)
result_len
self-explanatory
get_all_line flag, which is set
if we want to get all the line after
the matched word
.
command
the command to execue with popen.
word
the word to look for (usually an option name)
result
the buffer to store the next word (option value)
input_buffer_len
self-explanatory
flag this equals to GET_LINE
if we want to get all the line after
the matched word and GET_VALUE otherwise
.
DESCRIPTION
Parse output of the "command". Find the "word" and return the next one
if
get_all_line is 0
. Return the rest of the parsed string otherwise.
if
flag is GET_VALUE
. Return the rest of the parsed string otherwise.
RETURN
0 - ok
...
...
@@ -46,8 +47,8 @@
*/
int
parse_output_and_get_value
(
const
char
*
command
,
const
char
*
word
,
char
*
result
,
size_t
result
_len
,
int
get_all_line
)
char
*
result
,
size_t
input_buffer
_len
,
uint
flag
)
{
FILE
*
output
;
uint
wordlen
;
...
...
@@ -68,7 +69,7 @@ int parse_output_and_get_value(const char *command, const char *word,
while
(
fgets
(
linebuf
,
sizeof
(
linebuf
)
-
1
,
output
))
{
uint
line
word_len
=
0
;
uint
found_
word_len
=
0
;
char
*
linep
=
linebuf
;
linebuf
[
sizeof
(
linebuf
)
-
1
]
=
'\0'
;
/* safety */
...
...
@@ -77,26 +78,24 @@ int parse_output_and_get_value(const char *command, const char *word,
Get the word, which might contain non-alphanumeric characters. (Usually
these are '/', '-' and '.' in the path expressions and filenames)
*/
get_word
((
const
char
**
)
&
linep
,
&
line
word_len
,
NONSPACE
);
get_word
((
const
char
**
)
&
linep
,
&
found_
word_len
,
NONSPACE
);
if
(
!
strncmp
(
word
,
linep
,
wordlen
))
{
/*
If we have found the word, return the next one
. T
his is usually
an option value
.
If we have found the word, return the next one
(t
his is usually
an option value
) or the whole line (if flag)
*/
linep
+=
line
word_len
;
/* swallow the previous one */
if
(
!
get_all_line
)
linep
+=
found_
word_len
;
/* swallow the previous one */
if
(
flag
&
GET_VALUE
)
/* not GET_LINE */
{
get_word
((
const
char
**
)
&
linep
,
&
line
word_len
,
NONSPACE
);
if
(
result_len
<=
line
word_len
)
get_word
((
const
char
**
)
&
linep
,
&
found_
word_len
,
NONSPACE
);
if
(
input_buffer_len
<=
found_
word_len
)
goto
err
;
strncpy
(
result
,
linep
,
lineword_len
);
result
[
lineword_len
]
=
'\0'
;
strmake
(
result
,
linep
,
found_word_len
);
}
else
else
/* currently there are only two options */
{
strncpy
(
result
,
linep
,
result_len
);
result
[
result_len
]
=
'\0'
;
/* safety */
strmake
(
result
,
linep
,
input_buffer_len
-
1
);
}
goto
pclose
;
}
...
...
server-tools/instance-manager/parse_output.h
View file @
65d79b9d
...
...
@@ -16,8 +16,10 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
enum
{
GET_VALUE
=
1
,
GET_LINE
};
int
parse_output_and_get_value
(
const
char
*
command
,
const
char
*
word
,
char
*
result
,
size_t
result
_len
,
int
get_all_line
=
0
);
char
*
result
,
size_t
input_buffer
_len
,
uint
flag
);
#endif
/* INCLUDES_MYSQL_INSTANCE_MANAGER_PARSE_OUTPUT_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment