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
b9fcdfbb
Commit
b9fcdfbb
authored
Jul 21, 2005
by
petr@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WL #2713 Change IM behaviour so, that it only reads and alters one config file only.
Implemented on brian's request.
parent
aa2d5ee5
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
105 additions
and
32 deletions
+105
-32
server-tools/instance-manager/Makefile.am
server-tools/instance-manager/Makefile.am
+1
-0
server-tools/instance-manager/commands.cc
server-tools/instance-manager/commands.cc
+24
-6
server-tools/instance-manager/commands.h
server-tools/instance-manager/commands.h
+1
-0
server-tools/instance-manager/instance_map.cc
server-tools/instance-manager/instance_map.cc
+19
-8
server-tools/instance-manager/instance_map.h
server-tools/instance-manager/instance_map.h
+2
-2
server-tools/instance-manager/manager.cc
server-tools/instance-manager/manager.cc
+2
-1
server-tools/instance-manager/mysqlmanager.cc
server-tools/instance-manager/mysqlmanager.cc
+1
-1
server-tools/instance-manager/options.cc
server-tools/instance-manager/options.cc
+52
-13
server-tools/instance-manager/options.h
server-tools/instance-manager/options.h
+3
-1
No files found.
server-tools/instance-manager/Makefile.am
View file @
b9fcdfbb
...
@@ -34,6 +34,7 @@ liboptions_a_CXXFLAGS= $(CXXFLAGS) \
...
@@ -34,6 +34,7 @@ liboptions_a_CXXFLAGS= $(CXXFLAGS) \
-DDEFAULT_MYSQLD_PATH
=
"
$(libexecdir)
/mysqld
$(EXEEXT)
"
\
-DDEFAULT_MYSQLD_PATH
=
"
$(libexecdir)
/mysqld
$(EXEEXT)
"
\
-DDEFAULT_MONITORING_INTERVAL
=
"20"
\
-DDEFAULT_MONITORING_INTERVAL
=
"20"
\
-DDEFAULT_PORT
=
"2273"
\
-DDEFAULT_PORT
=
"2273"
\
-DDEFAULT_CONFIG_FILE
=
"/etc/my.cnf"
\
-DPROTOCOL_VERSION
=
@PROTOCOL_VERSION@
-DPROTOCOL_VERSION
=
@PROTOCOL_VERSION@
liboptions_a_SOURCES
=
options.h options.cc priv.h priv.cc
liboptions_a_SOURCES
=
options.h options.cc priv.h priv.cc
...
...
server-tools/instance-manager/commands.cc
View file @
b9fcdfbb
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#include "mysql_manager_error.h"
#include "mysql_manager_error.h"
#include "protocol.h"
#include "protocol.h"
#include "buffer.h"
#include "buffer.h"
#include "options.h"
#include <m_string.h>
#include <m_string.h>
#include <mysql.h>
#include <mysql.h>
...
@@ -643,6 +644,12 @@ Set_option::Set_option(Instance_map *instance_map_arg,
...
@@ -643,6 +644,12 @@ Set_option::Set_option(Instance_map *instance_map_arg,
if
((
instance
=
instance_map
->
find
(
name
,
len
)))
if
((
instance
=
instance_map
->
find
(
name
,
len
)))
{
{
instance_name
=
instance
->
options
.
instance_name
;
instance_name
=
instance
->
options
.
instance_name
;
if
(
instance_map
->
single_defaults_file_option
!=
NULL
)
single_defaults_file
=
strchr
(
instance_map
->
single_defaults_file_option
,
'='
)
+
1
;
else
single_defaults_file
=
NULL
;
/* add prefix for add_option */
/* add prefix for add_option */
if
((
option_len_arg
<
MAX_OPTION_LEN
-
1
)
||
if
((
option_len_arg
<
MAX_OPTION_LEN
-
1
)
||
(
option_value_len_arg
<
MAX_OPTION_LEN
-
1
))
(
option_value_len_arg
<
MAX_OPTION_LEN
-
1
))
...
@@ -689,15 +696,26 @@ int Set_option::correct_file(int skip)
...
@@ -689,15 +696,26 @@ int Set_option::correct_file(int skip)
{
{
int
error
;
int
error
;
error
=
modify_defaults_file
(
"/etc/my.cnf"
,
option
,
if
(
single_defaults_file
!=
NULL
)
error
=
modify_defaults_file
(
single_defaults_file
,
option
,
option_value
,
instance_name
,
skip
);
else
error
=
modify_defaults_file
(
Options
::
default_config_file
,
option
,
option_value
,
instance_name
,
skip
);
option_value
,
instance_name
,
skip
);
if
(
error
>
0
)
switch
(
error
)
{
case
0
:
return
0
;
/* everything was fine */
case
1
:
return
ER_OUT_OF_RESOURCES
;
return
ER_OUT_OF_RESOURCES
;
else
if
(
error
<
0
)
case
2
:
return
ER_ACCESS_OPTION_FILE
;
return
ER_ACCESS_OPTION_FILE
;
default:
DBUG_ASSERT
(
0
);
/* should never get here */
}
/* everything was fine */
return
0
;
/* keep compiler happy */
return
0
;
}
}
...
...
server-tools/instance-manager/commands.h
View file @
b9fcdfbb
...
@@ -187,6 +187,7 @@ class Set_option : public Command
...
@@ -187,6 +187,7 @@ class Set_option : public Command
public:
public:
const
char
*
instance_name
;
const
char
*
instance_name
;
uint
instance_name_len
;
uint
instance_name_len
;
const
char
*
single_defaults_file
;
/* buffer for the option */
/* buffer for the option */
enum
{
MAX_OPTION_LEN
=
1024
};
enum
{
MAX_OPTION_LEN
=
1024
};
char
option
[
MAX_OPTION_LEN
];
char
option
[
MAX_OPTION_LEN
];
...
...
server-tools/instance-manager/instance_map.cc
View file @
b9fcdfbb
...
@@ -22,6 +22,8 @@
...
@@ -22,6 +22,8 @@
#include "buffer.h"
#include "buffer.h"
#include "instance.h"
#include "instance.h"
#include "log.h"
#include "options.h"
#include <m_ctype.h>
#include <m_ctype.h>
#include <mysql_com.h>
#include <mysql_com.h>
...
@@ -112,8 +114,9 @@ C_MODE_END
...
@@ -112,8 +114,9 @@ C_MODE_END
Instance_map
::
Instance_map
(
const
char
*
default_mysqld_path_arg
,
Instance_map
::
Instance_map
(
const
char
*
default_mysqld_path_arg
,
const
char
*
first_option_arg
)
:
const
char
*
single_defaults_file_option_arg
)
:
mysqld_path
(
default_mysqld_path_arg
),
first_option
(
first_option_arg
)
mysqld_path
(
default_mysqld_path_arg
),
single_defaults_file_option
(
single_defaults_file_option_arg
)
{
{
pthread_mutex_init
(
&
LOCK_instance_map
,
0
);
pthread_mutex_init
(
&
LOCK_instance_map
,
0
);
}
}
...
@@ -202,7 +205,8 @@ int Instance_map::complete_initialization()
...
@@ -202,7 +205,8 @@ int Instance_map::complete_initialization()
hash_free should handle it's deletion => goto err, not
hash_free should handle it's deletion => goto err, not
err_instance.
err_instance.
*/
*/
if
(
instance
->
complete_initialization
(
this
,
mysqld_path
,
DEFAULT_SINGLE_INSTANCE
))
if
(
instance
->
complete_initialization
(
this
,
mysqld_path
,
DEFAULT_SINGLE_INSTANCE
))
goto
err
;
goto
err
;
}
}
else
else
...
@@ -236,18 +240,25 @@ int Instance_map::load()
...
@@ -236,18 +240,25 @@ int Instance_map::load()
/* the name of the program may be orbitrary here in fact */
/* the name of the program may be orbitrary here in fact */
argv_options
[
0
]
=
"mysqlmanager"
;
argv_options
[
0
]
=
"mysqlmanager"
;
if
(
first
_option
!=
NULL
)
if
(
single_defaults_file
_option
!=
NULL
)
{
{
argc
=
2
;
argc
=
2
;
argv_options
[
1
]
=
first
_option
;
argv_options
[
1
]
=
single_defaults_file
_option
;
argv_options
[
2
]
=
'\0'
;
argv_options
[
2
]
=
'\0'
;
}
}
else
else
argv_options
[
1
]
=
'\0'
;
argv_options
[
1
]
=
'\0'
;
if
(
my_search_option_files
(
"my"
,
&
argc
,
(
char
***
)
&
argv
,
&
args_used
,
/*
process_option
,
(
void
*
)
this
)
||
If the routine failed, we'll simply fallback to defaults in
complete_initialization
())
complete_initialization().
*/
if
(
my_search_option_files
(
Options
::
default_config_file
,
&
argc
,
(
char
***
)
&
argv
,
&
args_used
,
process_option
,
(
void
*
)
this
))
log_info
(
"Falling back to compiled-in defaults"
);
if
(
complete_initialization
())
return
1
;
return
1
;
return
0
;
return
0
;
...
...
server-tools/instance-manager/instance_map.h
View file @
b9fcdfbb
...
@@ -65,7 +65,7 @@ class Instance_map
...
@@ -65,7 +65,7 @@ class Instance_map
int
init
();
int
init
();
Instance_map
(
const
char
*
default_mysqld_path_arg
,
Instance_map
(
const
char
*
default_mysqld_path_arg
,
const
char
*
first
_option_arg
);
const
char
*
single_defaults_file
_option_arg
);
~
Instance_map
();
~
Instance_map
();
/* loads options from config files */
/* loads options from config files */
...
@@ -77,10 +77,10 @@ class Instance_map
...
@@ -77,10 +77,10 @@ class Instance_map
public:
public:
const
char
*
mysqld_path
;
const
char
*
mysqld_path
;
const
char
*
single_defaults_file_option
;
Guardian_thread
*
guardian
;
Guardian_thread
*
guardian
;
private:
private:
const
char
*
first_option
;
enum
{
START_HASH_SIZE
=
16
};
enum
{
START_HASH_SIZE
=
16
};
pthread_mutex_t
LOCK_instance_map
;
pthread_mutex_t
LOCK_instance_map
;
HASH
hash
;
HASH
hash
;
...
...
server-tools/instance-manager/manager.cc
View file @
b9fcdfbb
...
@@ -68,7 +68,8 @@ void manager(const Options &options)
...
@@ -68,7 +68,8 @@ void manager(const Options &options)
*/
*/
User_map
user_map
;
User_map
user_map
;
Instance_map
instance_map
(
options
.
default_mysqld_path
,
options
.
first_option
);
Instance_map
instance_map
(
options
.
default_mysqld_path
,
options
.
single_defaults_file_option
);
Guardian_thread
guardian_thread
(
thread_registry
,
Guardian_thread
guardian_thread
(
thread_registry
,
&
instance_map
,
&
instance_map
,
options
.
monitoring_interval
);
options
.
monitoring_interval
);
...
...
server-tools/instance-manager/mysqlmanager.cc
View file @
b9fcdfbb
...
@@ -83,7 +83,7 @@ int main(int argc, char *argv[])
...
@@ -83,7 +83,7 @@ int main(int argc, char *argv[])
if
(
set_user
(
options
.
user
,
user_info
))
if
(
set_user
(
options
.
user
,
user_info
))
{
{
options
.
cleanup
();
options
.
cleanup
();
return
1
;
goto
err
;
}
}
}
}
...
...
server-tools/instance-manager/options.cc
View file @
b9fcdfbb
...
@@ -36,7 +36,8 @@ const char *Options::pid_file_name= QUOTE(DEFAULT_PID_FILE_NAME);
...
@@ -36,7 +36,8 @@ const char *Options::pid_file_name= QUOTE(DEFAULT_PID_FILE_NAME);
const
char
*
Options
::
socket_file_name
=
QUOTE
(
DEFAULT_SOCKET_FILE_NAME
);
const
char
*
Options
::
socket_file_name
=
QUOTE
(
DEFAULT_SOCKET_FILE_NAME
);
const
char
*
Options
::
password_file_name
=
QUOTE
(
DEFAULT_PASSWORD_FILE_NAME
);
const
char
*
Options
::
password_file_name
=
QUOTE
(
DEFAULT_PASSWORD_FILE_NAME
);
const
char
*
Options
::
default_mysqld_path
=
QUOTE
(
DEFAULT_MYSQLD_PATH
);
const
char
*
Options
::
default_mysqld_path
=
QUOTE
(
DEFAULT_MYSQLD_PATH
);
const
char
*
Options
::
first_option
=
0
;
/* No default value */
const
char
*
Options
::
default_config_file
=
QUOTE
(
DEFAULT_CONFIG_FILE
);
const
char
*
Options
::
single_defaults_file_option
=
0
;
/* No default value */
const
char
*
Options
::
bind_address
=
0
;
/* No default value */
const
char
*
Options
::
bind_address
=
0
;
/* No default value */
const
char
*
Options
::
user
=
0
;
/* No default value */
const
char
*
Options
::
user
=
0
;
/* No default value */
uint
Options
::
monitoring_interval
=
DEFAULT_MONITORING_INTERVAL
;
uint
Options
::
monitoring_interval
=
DEFAULT_MONITORING_INTERVAL
;
...
@@ -204,31 +205,69 @@ C_MODE_END
...
@@ -204,31 +205,69 @@ C_MODE_END
/*
/*
- call load_defaults to load configuration file section
- Process argv of original program: get tid of --defaults-extra-file
and print a message if met there.
- call load_defaults to load configuration file section and save the pointer
for free_defaults.
- call handle_options to assign defaults and command-line arguments
- call handle_options to assign defaults and command-line arguments
to the class members
to the class members.
if either of these function fail, exit the program
if either of these function fail, return the error code.
May not return.
*/
*/
int
Options
::
load
(
int
argc
,
char
**
argv
)
int
Options
::
load
(
int
argc
,
char
**
argv
)
{
{
int
rc
;
int
rc
;
char
**
original_argv
;
int
original_argc
;
char
*
original_argv_buff
[
1024
];
int
use_new_argv
=
0
;
if
(
argc
>=
2
)
saved_argv
=
argv
;
original_argv
=
original_argv_buff
;
original_argc
=
argc
;
if
(
argc
>=
2
&&
is_prefix
(
argv
[
1
],
"--defaults-file="
))
{
if
(
is_prefix
(
argv
[
1
],
"--defaults-file="
))
{
{
if
(
is_prefix
(
argv
[
1
],
"--defaults-file="
)
||
/* set --defaults-file, so that we read only this file */
is_prefix
(
argv
[
1
],
"--defaults-extra-file="
))
Options
::
single_defaults_file_option
=
argv
[
1
];
Options
::
first_option
=
argv
[
1
];
}
if
(
is_prefix
(
argv
[
1
],
"--defaults-extra-file="
))
{
int
argv_pos
=
1
;
original_argv
[
0
]
=
argv
[
0
];
use_new_argv
=
1
;
/* skip --defaullts-extra-file */
while
(
++
argv_pos
!=
argc
)
original_argv
[
argv_pos
]
=
argv
[
argv_pos
];
original_argv
[
argv_pos
]
=
0
;
/* the log is not enabled yet */
fprintf
(
stderr
,
"--defaults-extra-file is not supported by IM."
" Skipping the option.
\n
"
);
original_argc
--
;
}
}
}
/* here load_defaults will save pointer to free allocated memory */
if
(
use_new_argv
)
saved_argv
=
original_argv
;
else
saved_argv
=
argv
;
/* 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
(
default_config_file
,
default_groups
,
&
original_argc
,
Options
::
saved_argv
=
argv
;
&
saved_argv
);
if
((
rc
=
handle_options
(
&
original_argc
,
&
saved_argv
,
my_long_options
,
get_one_option
))
!=
0
)
goto
err
;
if
((
rc
=
handle_options
(
&
argc
,
&
argv
,
my_long_options
,
get_one_option
))
!=
0
)
return
rc
;
return
0
;
return
0
;
err:
return
rc
;
}
}
void
Options
::
cleanup
()
void
Options
::
cleanup
()
...
...
server-tools/instance-manager/options.h
View file @
b9fcdfbb
...
@@ -36,11 +36,13 @@ struct Options
...
@@ -36,11 +36,13 @@ struct Options
static
const
char
*
default_mysqld_path
;
static
const
char
*
default_mysqld_path
;
static
const
char
*
user
;
static
const
char
*
user
;
/* the option which should be passed to process_default_option_files */
/* the option which should be passed to process_default_option_files */
static
const
char
*
first
_option
;
static
const
char
*
single_defaults_file
_option
;
static
uint
monitoring_interval
;
static
uint
monitoring_interval
;
static
uint
port_number
;
static
uint
port_number
;
static
const
char
*
bind_address
;
static
const
char
*
bind_address
;
static
const
char
*
default_config_file
;
/* argv pointer returned by load_defaults() to be used by free_defaults() */
static
char
**
saved_argv
;
static
char
**
saved_argv
;
static
int
load
(
int
argc
,
char
**
argv
);
static
int
load
(
int
argc
,
char
**
argv
);
...
...
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