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
59d8e511
Commit
59d8e511
authored
Feb 15, 2005
by
petr@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some more cleanups and fixes
parent
bb8e5b62
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
77 additions
and
32 deletions
+77
-32
server-tools/instance-manager/commands.cc
server-tools/instance-manager/commands.cc
+1
-1
server-tools/instance-manager/instance.cc
server-tools/instance-manager/instance.cc
+3
-2
server-tools/instance-manager/instance.h
server-tools/instance-manager/instance.h
+2
-1
server-tools/instance-manager/instance_map.cc
server-tools/instance-manager/instance_map.cc
+34
-13
server-tools/instance-manager/instance_map.h
server-tools/instance-manager/instance_map.h
+1
-1
server-tools/instance-manager/instance_options.cc
server-tools/instance-manager/instance_options.cc
+9
-3
server-tools/instance-manager/instance_options.h
server-tools/instance-manager/instance_options.h
+1
-1
server-tools/instance-manager/manager.cc
server-tools/instance-manager/manager.cc
+13
-3
server-tools/instance-manager/mysqlmanager.cc
server-tools/instance-manager/mysqlmanager.cc
+5
-1
server-tools/instance-manager/options.cc
server-tools/instance-manager/options.cc
+5
-3
server-tools/instance-manager/options.h
server-tools/instance-manager/options.h
+1
-1
server-tools/instance-manager/parse_output.cc
server-tools/instance-manager/parse_output.cc
+2
-2
No files found.
server-tools/instance-manager/commands.cc
View file @
59d8e511
...
@@ -276,7 +276,7 @@ int Show_instance_options::do_command(struct st_net *net,
...
@@ -276,7 +276,7 @@ int Show_instance_options::do_command(struct st_net *net,
goto
err
;
goto
err
;
}
}
if
(
instance
->
options
.
nonguarded
=
=
NULL
)
if
(
instance
->
options
.
nonguarded
!
=
NULL
)
{
{
position
=
0
;
position
=
0
;
store_to_string
(
&
send_buff
,
(
char
*
)
"nonguarded"
,
&
position
);
store_to_string
(
&
send_buff
,
(
char
*
)
"nonguarded"
,
&
position
);
...
...
server-tools/instance-manager/instance.cc
View file @
59d8e511
...
@@ -296,8 +296,9 @@ int Instance::init(const char *name_arg)
...
@@ -296,8 +296,9 @@ int Instance::init(const char *name_arg)
}
}
int
Instance
::
complete_initialization
(
Instance_map
*
instance_map_arg
)
int
Instance
::
complete_initialization
(
Instance_map
*
instance_map_arg
,
const
char
*
mysqld_path
)
{
{
instance_map
=
instance_map_arg
;
instance_map
=
instance_map_arg
;
return
0
;
return
options
.
complete_initialization
(
mysqld_path
)
;
}
}
server-tools/instance-manager/instance.h
View file @
59d8e511
...
@@ -34,7 +34,8 @@ class Instance
...
@@ -34,7 +34,8 @@ class Instance
~
Instance
();
~
Instance
();
int
init
(
const
char
*
name
);
int
init
(
const
char
*
name
);
int
complete_initialization
(
Instance_map
*
instance_map_arg
);
int
complete_initialization
(
Instance_map
*
instance_map_arg
,
const
char
*
mysqld_path
);
bool
is_running
();
bool
is_running
();
int
start
();
int
start
();
...
...
server-tools/instance-manager/instance_map.cc
View file @
59d8e511
...
@@ -74,7 +74,7 @@ static void delete_instance(void *u)
...
@@ -74,7 +74,7 @@ static void delete_instance(void *u)
1 - error occured
1 - error occured
*/
*/
static
int
process_option
(
void
*
ctx
,
const
char
*
group
,
const
char
*
option
)
static
int
process_option
(
void
*
ctx
,
const
char
*
group
,
const
char
*
option
)
{
{
Instance_map
*
map
=
NULL
;
Instance_map
*
map
=
NULL
;
Instance
*
instance
=
NULL
;
Instance
*
instance
=
NULL
;
...
@@ -178,18 +178,41 @@ Instance_map::find(const char *name, uint name_len)
...
@@ -178,18 +178,41 @@ Instance_map::find(const char *name, uint name_len)
}
}
void
Instance_map
::
complete_initialization
()
int
Instance_map
::
complete_initialization
()
{
{
Instance
*
instance
;
Instance
*
instance
;
uint
i
=
0
;
uint
i
=
0
;
while
(
i
<
hash
.
records
)
if
(
hash
.
records
==
0
)
/* no instances found */
{
{
instance
=
(
Instance
*
)
hash_element
(
&
hash
,
i
);
if
((
instance
=
new
Instance
)
==
0
)
instance
->
complete_initialization
(
this
);
goto
err
;
instance
->
options
.
complete_initialization
(
mysqld_path
);
i
++
;
if
(
instance
->
init
(
"mysqld"
)
||
add_instance
(
instance
))
goto
err_instance
;
/*
After an instance have been added to the instance_map,
hash_free should handle it's deletion.
*/
if
(
instance
->
complete_initialization
(
this
,
mysqld_path
))
goto
err
;
}
}
else
while
(
i
<
hash
.
records
)
{
instance
=
(
Instance
*
)
hash_element
(
&
hash
,
i
);
if
(
instance
->
complete_initialization
(
this
,
mysqld_path
))
goto
err
;
i
++
;
}
return
0
;
err:
return
1
;
err_instance:
delete
instance
;
return
1
;
}
}
...
@@ -197,13 +220,11 @@ void Instance_map::complete_initialization()
...
@@ -197,13 +220,11 @@ void Instance_map::complete_initialization()
int
Instance_map
::
load
()
int
Instance_map
::
load
()
{
{
int
error
;
if
(
process_default_option_files
(
"my"
,
process_option
,
(
void
*
)
this
)
||
complete_initialization
())
error
=
process_default_option_files
(
"my"
,
process_option
,
(
void
*
)
this
);
return
1
;
complete_initialization
();
return
error
;
return
0
;
}
}
...
...
server-tools/instance-manager/instance_map.h
View file @
59d8e511
...
@@ -72,7 +72,7 @@ class Instance_map
...
@@ -72,7 +72,7 @@ class Instance_map
/* adds instance to internal hash */
/* adds instance to internal hash */
int
add_instance
(
Instance
*
instance
);
int
add_instance
(
Instance
*
instance
);
/* inits instances argv's after all options have been loaded */
/* inits instances argv's after all options have been loaded */
void
complete_initialization
();
int
complete_initialization
();
public:
public:
const
char
*
mysqld_path
;
const
char
*
mysqld_path
;
...
...
server-tools/instance-manager/instance_options.cc
View file @
59d8e511
...
@@ -74,13 +74,17 @@ int Instance_options::get_default_option(char *result, size_t result_len,
...
@@ -74,13 +74,17 @@ int Instance_options::get_default_option(char *result, size_t result_len,
}
}
void
Instance_options
::
get_pid_filename
(
char
*
result
)
int
Instance_options
::
get_pid_filename
(
char
*
result
)
{
{
const
char
*
pid_file
=
mysqld_pid_file
;
const
char
*
pid_file
=
mysqld_pid_file
;
char
datadir
[
MAX_PATH_LEN
];
char
datadir
[
MAX_PATH_LEN
];
if
(
mysqld_datadir
==
NULL
)
if
(
mysqld_datadir
==
NULL
)
get_default_option
(
datadir
,
sizeof
(
datadir
),
"--datadir"
);
{
/* we might get an error here if we have wrong path to the mysqld binary */
if
(
get_default_option
(
datadir
,
sizeof
(
datadir
),
"--datadir"
))
return
1
;
}
else
else
strxnmov
(
datadir
,
MAX_PATH_LEN
-
1
,
strchr
(
mysqld_datadir
,
'='
)
+
1
,
strxnmov
(
datadir
,
MAX_PATH_LEN
-
1
,
strchr
(
mysqld_datadir
,
'='
)
+
1
,
"/"
,
NullS
);
"/"
,
NullS
);
...
@@ -90,6 +94,7 @@ void Instance_options::get_pid_filename(char *result)
...
@@ -90,6 +94,7 @@ void Instance_options::get_pid_filename(char *result)
/* get the full path to the pidfile */
/* get the full path to the pidfile */
my_load_path
(
result
,
pid_file
,
datadir
);
my_load_path
(
result
,
pid_file
,
datadir
);
return
0
;
}
}
...
@@ -145,7 +150,8 @@ int Instance_options::complete_initialization(const char *default_path)
...
@@ -145,7 +150,8 @@ int Instance_options::complete_initialization(const char *default_path)
add_option
(
pidfilename
);
add_option
(
pidfilename
);
}
}
get_pid_filename
(
pid_file_with_path
);
if
(
get_pid_filename
(
pid_file_with_path
))
goto
err
;
/* we need to reserve space for the final zero + possible default options */
/* we need to reserve space for the final zero + possible default options */
if
(
!
(
argv
=
(
char
**
)
alloc_root
(
&
alloc
,
(
options_array
.
elements
+
1
if
(
!
(
argv
=
(
char
**
)
alloc_root
(
&
alloc
,
(
options_array
.
elements
+
1
...
...
server-tools/instance-manager/instance_options.h
View file @
59d8e511
...
@@ -48,7 +48,7 @@ class Instance_options
...
@@ -48,7 +48,7 @@ class Instance_options
int
add_option
(
const
char
*
option
);
int
add_option
(
const
char
*
option
);
int
init
(
const
char
*
instance_name_arg
);
int
init
(
const
char
*
instance_name_arg
);
pid_t
get_pid
();
pid_t
get_pid
();
void
get_pid_filename
(
char
*
result
);
int
get_pid_filename
(
char
*
result
);
int
unlink_pidfile
();
int
unlink_pidfile
();
void
print_argv
();
void
print_argv
();
...
...
server-tools/instance-manager/manager.cc
View file @
59d8e511
...
@@ -77,8 +77,18 @@ void manager(const Options &options)
...
@@ -77,8 +77,18 @@ void manager(const Options &options)
instance_map
.
guardian
=
&
guardian_thread
;
instance_map
.
guardian
=
&
guardian_thread
;
if
(
instance_map
.
init
()
||
user_map
.
init
()
||
instance_map
.
load
()
||
if
(
instance_map
.
init
()
||
user_map
.
init
())
user_map
.
load
(
options
.
password_file_name
))
return
;
if
(
instance_map
.
load
())
{
log_error
(
"Cannot init instances repository. This might be caused by "
"the wrong config file options. For instance, missing mysqld "
"binary. Aborting."
);
return
;
}
if
(
user_map
.
load
(
options
.
password_file_name
))
return
;
return
;
/* write pid file */
/* write pid file */
...
@@ -173,7 +183,7 @@ void manager(const Options &options)
...
@@ -173,7 +183,7 @@ void manager(const Options &options)
{
{
int
status
=
0
;
int
status
=
0
;
if
(
status
=
my_sigwait
(
&
mask
,
&
signo
)
)
if
(
(
status
=
my_sigwait
(
&
mask
,
&
signo
))
!=
0
)
{
{
log_error
(
"sigwait() failed"
);
log_error
(
"sigwait() failed"
);
goto
err
;
goto
err
;
...
...
server-tools/instance-manager/mysqlmanager.cc
View file @
59d8e511
...
@@ -74,7 +74,8 @@ int main(int argc, char *argv[])
...
@@ -74,7 +74,8 @@ int main(int argc, char *argv[])
Options
options
;
Options
options
;
struct
passwd
*
user_info
;
struct
passwd
*
user_info
;
options
.
load
(
argc
,
argv
);
if
(
options
.
load
(
argc
,
argv
))
goto
err
;
if
((
user_info
=
check_user
(
options
.
user
)))
if
((
user_info
=
check_user
(
options
.
user
)))
{
{
...
@@ -96,6 +97,9 @@ int main(int argc, char *argv[])
...
@@ -96,6 +97,9 @@ int main(int argc, char *argv[])
options
.
cleanup
();
options
.
cleanup
();
my_end
(
0
);
my_end
(
0
);
return
0
;
return
0
;
err:
my_end
(
0
);
return
1
;
}
}
/******************* Auxilary functions implementation **********************/
/******************* Auxilary functions implementation **********************/
...
...
server-tools/instance-manager/options.cc
View file @
59d8e511
...
@@ -207,14 +207,16 @@ C_MODE_END
...
@@ -207,14 +207,16 @@ C_MODE_END
May not return.
May not return.
*/
*/
void
Options
::
load
(
int
argc
,
char
**
argv
)
int
Options
::
load
(
int
argc
,
char
**
argv
)
{
{
int
rc
;
/* config-file options are prepended to command-line ones */
/* config-file options are prepended to command-line ones */
load_defaults
(
"my"
,
default_groups
,
&
argc
,
&
argv
);
load_defaults
(
"my"
,
default_groups
,
&
argc
,
&
argv
);
if
(
int
rc
=
handle_options
(
&
argc
,
&
argv
,
my_long_options
,
get_one_option
))
if
(
rc
=
handle_options
(
&
argc
,
&
argv
,
my_long_options
,
get_one_option
))
exit
(
rc
)
;
return
rc
;
Options
::
saved_argv
=
argv
;
Options
::
saved_argv
=
argv
;
return
0
;
}
}
void
Options
::
cleanup
()
void
Options
::
cleanup
()
...
...
server-tools/instance-manager/options.h
View file @
59d8e511
...
@@ -41,7 +41,7 @@ struct Options
...
@@ -41,7 +41,7 @@ struct Options
static
char
**
saved_argv
;
static
char
**
saved_argv
;
static
void
load
(
int
argc
,
char
**
argv
);
static
int
load
(
int
argc
,
char
**
argv
);
void
cleanup
();
void
cleanup
();
};
};
...
...
server-tools/instance-manager/parse_output.cc
View file @
59d8e511
...
@@ -91,8 +91,8 @@ int parse_output_and_get_value(const char *command, const char *word,
...
@@ -91,8 +91,8 @@ int parse_output_and_get_value(const char *command, const char *word,
}
}
pclose:
pclose:
if
(
pclose
(
output
))
/* we are not interested in the termination status */
return
1
;
pclose
(
output
)
;
return
0
;
return
0
;
...
...
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