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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
670e938e
Commit
670e938e
authored
Feb 07, 2008
by
msvensson@pilot.mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk-internal:/home/bk/mysql-5.1-build
into pilot.mysql.com:/data/msvensson/mysql/mysql-5.1-build
parents
5d2c9639
8c11d95f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
99 deletions
+63
-99
storage/ndb/tools/waiter.cpp
storage/ndb/tools/waiter.cpp
+42
-85
vio/viossl.c
vio/viossl.c
+21
-14
No files found.
storage/ndb/tools/waiter.cpp
View file @
670e938e
...
@@ -21,13 +21,11 @@
...
@@ -21,13 +21,11 @@
#include <NdbMain.h>
#include <NdbMain.h>
#include <NdbOut.hpp>
#include <NdbOut.hpp>
#include <NdbSleep.h>
#include <NdbSleep.h>
#include <kernel/ndb_limits.h>
#include <NDBT.hpp>
#include <NDBT.hpp>
int
static
int
waitClusterStatus
(
const
char
*
_addr
,
ndb_mgm_node_status
_status
,
waitClusterStatus
(
const
char
*
_addr
,
ndb_mgm_node_status
_status
);
unsigned
int
_timeout
);
enum
ndb_waiter_options
{
enum
ndb_waiter_options
{
OPT_WAIT_STATUS_NOT_STARTED
=
NDB_STD_OPTIONS_LAST
,
OPT_WAIT_STATUS_NOT_STARTED
=
NDB_STD_OPTIONS_LAST
,
...
@@ -55,12 +53,13 @@ static struct my_option my_long_options[] =
...
@@ -55,12 +53,13 @@ static struct my_option my_long_options[] =
"Wait for cluster to enter single user mode"
,
"Wait for cluster to enter single user mode"
,
(
uchar
**
)
&
_single_user
,
(
uchar
**
)
&
_single_user
,
0
,
(
uchar
**
)
&
_single_user
,
(
uchar
**
)
&
_single_user
,
0
,
GET_BOOL
,
NO_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
GET_BOOL
,
NO_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
{
"timeout"
,
't'
,
"Timeout to wait"
,
{
"timeout"
,
't'
,
"Timeout to wait
in seconds
"
,
(
uchar
**
)
&
_timeout
,
(
uchar
**
)
&
_timeout
,
0
,
(
uchar
**
)
&
_timeout
,
(
uchar
**
)
&
_timeout
,
0
,
GET_INT
,
REQUIRED_ARG
,
120
,
0
,
0
,
0
,
0
,
0
},
GET_INT
,
REQUIRED_ARG
,
120
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
,
GET_NO_ARG
,
NO_ARG
,
0
,
0
,
0
,
0
,
0
,
0
}
{
0
,
0
,
0
,
0
,
0
,
0
,
GET_NO_ARG
,
NO_ARG
,
0
,
0
,
0
,
0
,
0
,
0
}
};
};
static
void
usage
()
static
void
usage
()
{
{
ndb_std_print_version
();
ndb_std_print_version
();
...
@@ -70,16 +69,18 @@ static void usage()
...
@@ -70,16 +69,18 @@ static void usage()
my_print_variables
(
my_long_options
);
my_print_variables
(
my_long_options
);
}
}
int
main
(
int
argc
,
char
**
argv
){
int
main
(
int
argc
,
char
**
argv
){
NDB_INIT
(
argv
[
0
]);
NDB_INIT
(
argv
[
0
]);
load_defaults
(
"my"
,
load_default_groups
,
&
argc
,
&
argv
);
load_defaults
(
"my"
,
load_default_groups
,
&
argc
,
&
argv
);
const
char
*
_hostName
=
NULL
;
const
char
*
_hostName
=
NULL
;
int
ho_error
;
#ifndef DBUG_OFF
#ifndef DBUG_OFF
opt_debug
=
"d:t:O,/tmp/ndb_waiter.trace"
;
opt_debug
=
"d:t:O,/tmp/ndb_waiter.trace"
;
#endif
#endif
if
((
ho_error
=
handle_options
(
&
argc
,
&
argv
,
my_long_options
,
ndb_std_get_one_option
)))
if
(
handle_options
(
&
argc
,
&
argv
,
my_long_options
,
ndb_std_get_one_option
))
return
NDBT_ProgramExit
(
NDBT_WRONGARGS
);
return
NDBT_ProgramExit
(
NDBT_WRONGARGS
);
_hostName
=
argv
[
0
];
_hostName
=
argv
[
0
];
...
@@ -105,7 +106,7 @@ int main(int argc, char** argv){
...
@@ -105,7 +106,7 @@ int main(int argc, char** argv){
wait_status
=
NDB_MGM_NODE_STATUS_STARTED
;
wait_status
=
NDB_MGM_NODE_STATUS_STARTED
;
}
}
if
(
waitClusterStatus
(
_hostName
,
wait_status
,
_timeout
*
10
)
!=
0
)
if
(
waitClusterStatus
(
_hostName
,
wait_status
)
!=
0
)
return
NDBT_ProgramExit
(
NDBT_FAILED
);
return
NDBT_ProgramExit
(
NDBT_FAILED
);
return
NDBT_ProgramExit
(
NDBT_OK
);
return
NDBT_ProgramExit
(
NDBT_OK
);
}
}
...
@@ -118,8 +119,6 @@ int main(int argc, char** argv){
...
@@ -118,8 +119,6 @@ int main(int argc, char** argv){
NdbMgmHandle
handle
=
NULL
;
NdbMgmHandle
handle
=
NULL
;
Vector
<
ndb_mgm_node_state
>
ndbNodes
;
Vector
<
ndb_mgm_node_state
>
ndbNodes
;
Vector
<
ndb_mgm_node_state
>
mgmNodes
;
Vector
<
ndb_mgm_node_state
>
apiNodes
;
int
int
getStatus
(){
getStatus
(){
...
@@ -128,8 +127,6 @@ getStatus(){
...
@@ -128,8 +127,6 @@ getStatus(){
struct
ndb_mgm_node_state
*
node
;
struct
ndb_mgm_node_state
*
node
;
ndbNodes
.
clear
();
ndbNodes
.
clear
();
mgmNodes
.
clear
();
apiNodes
.
clear
();
while
(
retries
<
10
){
while
(
retries
<
10
){
status
=
ndb_mgm_get_status
(
handle
);
status
=
ndb_mgm_get_status
(
handle
);
...
@@ -153,18 +150,16 @@ getStatus(){
...
@@ -153,18 +150,16 @@ getStatus(){
ndbNodes
.
push_back
(
*
node
);
ndbNodes
.
push_back
(
*
node
);
break
;
break
;
case
NDB_MGM_NODE_TYPE_MGM
:
case
NDB_MGM_NODE_TYPE_MGM
:
mgmNodes
.
push_back
(
*
node
);
/* Don't care about MGM nodes */
break
;
break
;
case
NDB_MGM_NODE_TYPE_API
:
case
NDB_MGM_NODE_TYPE_API
:
apiNodes
.
push_back
(
*
node
);
/* Don't care about API nodes */
break
;
break
;
default:
default:
if
(
node
->
node_status
==
NDB_MGM_NODE_STATUS_UNKNOWN
||
if
(
node
->
node_status
==
NDB_MGM_NODE_STATUS_UNKNOWN
||
node
->
node_status
==
NDB_MGM_NODE_STATUS_NO_CONTACT
){
node
->
node_status
==
NDB_MGM_NODE_STATUS_NO_CONTACT
){
retries
++
;
retries
++
;
ndbNodes
.
clear
();
ndbNodes
.
clear
();
mgmNodes
.
clear
();
apiNodes
.
clear
();
free
(
status
);
free
(
status
);
status
=
NULL
;
status
=
NULL
;
count
=
0
;
count
=
0
;
...
@@ -184,23 +179,21 @@ getStatus(){
...
@@ -184,23 +179,21 @@ getStatus(){
return
0
;
return
0
;
}
}
g_err
<<
"getStatus failed"
<<
endl
;
return
-
1
;
return
-
1
;
}
}
int
static
int
waitClusterStatus
(
const
char
*
_addr
,
waitClusterStatus
(
const
char
*
_addr
,
ndb_mgm_node_status
_status
,
ndb_mgm_node_status
_status
)
unsigned
int
_timeout
)
{
{
int
_startphase
=
-
1
;
int
_startphase
=
-
1
;
int
_nodes
[
MAX_NDB_NODES
];
/* Ignore SIGPIPE */
int
_num_nodes
=
0
;
signal
(
SIGPIPE
,
SIG_IGN
)
;
handle
=
ndb_mgm_create_handle
();
handle
=
ndb_mgm_create_handle
();
if
(
handle
==
NULL
){
if
(
handle
==
NULL
){
g_err
<<
"
handle == NULL
"
<<
endl
;
g_err
<<
"
Could not create ndb_mgm handle
"
<<
endl
;
return
-
1
;
return
-
1
;
}
}
g_info
<<
"Connecting to mgmsrv at "
<<
_addr
<<
endl
;
g_info
<<
"Connecting to mgmsrv at "
<<
_addr
<<
endl
;
...
@@ -216,19 +209,11 @@ waitClusterStatus(const char* _addr,
...
@@ -216,19 +209,11 @@ waitClusterStatus(const char* _addr,
return
-
1
;
return
-
1
;
}
}
if
(
getStatus
()
!=
0
)
int
attempts
=
0
;
return
-
1
;
int
resetAttempts
=
0
;
const
int
MAX_RESET_ATTEMPTS
=
10
;
// Collect all nodes into nodes
for
(
size_t
i
=
0
;
i
<
ndbNodes
.
size
();
i
++
){
_nodes
[
i
]
=
ndbNodes
[
i
].
node_id
;
_num_nodes
++
;
}
unsigned
int
attempts
=
0
;
unsigned
int
resetAttempts
=
0
;
const
unsigned
int
MAX_RESET_ATTEMPTS
=
10
;
bool
allInState
=
false
;
bool
allInState
=
false
;
int
timeout_ms
=
_timeout
*
10
;
/* In number of 100 milliseconds */
while
(
allInState
==
false
){
while
(
allInState
==
false
){
if
(
_timeout
>
0
&&
attempts
>
_timeout
){
if
(
_timeout
>
0
&&
attempts
>
_timeout
){
/**
/**
...
@@ -269,62 +254,34 @@ waitClusterStatus(const char* _addr,
...
@@ -269,62 +254,34 @@ waitClusterStatus(const char* _addr,
<<
resetAttempts
<<
endl
;
<<
resetAttempts
<<
endl
;
attempts
=
0
;
attempts
=
0
;
resetAttempts
++
;
resetAttempts
++
;
}
}
allInState
=
true
;
if
(
getStatus
()
!=
0
){
if
(
getStatus
()
!=
0
){
g_err
<<
"getStatus != 0"
<<
endl
;
return
-
1
;
return
-
1
;
}
}
// ndbout << "waitNodeState; _num_nodes = " << _num_nodes << endl;
/* Assume all nodes are in state(if there is any) */
// for (int i = 0; i < _num_nodes; i++)
allInState
=
(
ndbNodes
.
size
()
>
0
);
// ndbout << " node["<<i<<"] =" <<_nodes[i] << endl;
for
(
int
i
=
0
;
i
<
_num_nodes
;
i
++
){
ndb_mgm_node_state
*
ndbNode
=
NULL
;
for
(
size_t
n
=
0
;
n
<
ndbNodes
.
size
();
n
++
){
if
(
ndbNodes
[
n
].
node_id
==
_nodes
[
i
])
ndbNode
=
&
ndbNodes
[
n
];
}
if
(
ndbNode
==
NULL
){
allInState
=
false
;
continue
;
}
g_info
<<
"State node "
<<
ndbNode
->
node_id
<<
" "
/* Loop through all nodes and check their state */
<<
ndb_mgm_get_node_status_string
(
ndbNode
->
node_status
)
<<
endl
;
for
(
size_t
n
=
0
;
n
<
ndbNodes
.
size
();
n
++
)
{
ndb_mgm_node_state
*
ndbNode
=
&
ndbNodes
[
n
];
assert
(
ndbNode
!=
NULL
);
assert
(
ndbNode
!=
NULL
);
if
(
_status
==
NDB_MGM_NODE_STATUS_STARTING
&&
g_info
<<
"Node "
<<
ndbNode
->
node_id
<<
": "
((
ndbNode
->
node_status
==
NDB_MGM_NODE_STATUS_STARTING
&&
<<
ndb_mgm_get_node_status_string
(
ndbNode
->
node_status
)
<<
endl
;
ndbNode
->
start_phase
>=
_startphase
)
||
(
ndbNode
->
node_status
==
NDB_MGM_NODE_STATUS_STARTED
)))
continue
;
if
(
_status
==
NDB_MGM_NODE_STATUS_STARTING
){
g_info
<<
"status = "
<<
ndb_mgm_get_node_status_string
(
ndbNode
->
node_status
)
<<
", start_phase="
<<
ndbNode
->
start_phase
<<
endl
;
if
(
ndbNode
->
node_status
!=
_status
)
{
if
(
ndbNode
->
node_status
<
_status
)
allInState
=
false
;
else
g_info
<<
"node_status("
<<
(
unsigned
)
ndbNode
->
node_status
<<
") != _status("
<<
(
unsigned
)
_status
<<
")"
<<
endl
;
}
else
if
(
ndbNode
->
start_phase
<
_startphase
)
allInState
=
false
;
}
else
{
if
(
ndbNode
->
node_status
!=
_status
)
if
(
ndbNode
->
node_status
!=
_status
)
allInState
=
false
;
allInState
=
false
;
}
}
}
if
(
!
allInState
)
{
g_info
<<
"Waiting for cluster enter state "
g_info
<<
"Waiting for cluster enter state "
<<
ndb_mgm_get_node_status_string
(
_status
)
<<
endl
;
<<
ndb_mgm_get_node_status_string
(
_status
)
<<
endl
;
NdbSleep_MilliSleep
(
100
);
NdbSleep_MilliSleep
(
100
);
}
attempts
++
;
attempts
++
;
}
}
return
0
;
return
0
;
...
...
vio/viossl.c
View file @
670e938e
...
@@ -172,20 +172,15 @@ void vio_ssl_delete(Vio *vio)
...
@@ -172,20 +172,15 @@ void vio_ssl_delete(Vio *vio)
vio_delete
(
vio
);
vio_delete
(
vio
);
}
}
int
sslaccept
(
struct
st_VioSSLFd
*
ptr
,
Vio
*
vio
,
long
timeout
)
{
DBUG_ENTER
(
"sslaccept"
);
DBUG_RETURN
(
sslconnect
(
ptr
,
vio
,
timeout
));
}
int
sslconnect
(
struct
st_VioSSLFd
*
ptr
,
Vio
*
vio
,
long
timeout
)
static
int
ssl_do
(
struct
st_VioSSLFd
*
ptr
,
Vio
*
vio
,
long
timeout
,
int
(
*
connect_accept_func
)(
SSL
*
))
{
{
SSL
*
ssl
;
SSL
*
ssl
;
my_bool
unused
;
my_bool
unused
;
my_bool
was_blocking
;
my_bool
was_blocking
;
DBUG_ENTER
(
"ssl
connect
"
);
DBUG_ENTER
(
"ssl
_do
"
);
DBUG_PRINT
(
"enter"
,
(
"ptr: 0x%lx, sd: %d ctx: 0x%lx"
,
DBUG_PRINT
(
"enter"
,
(
"ptr: 0x%lx, sd: %d ctx: 0x%lx"
,
(
long
)
ptr
,
vio
->
sd
,
(
long
)
ptr
->
ssl_context
));
(
long
)
ptr
,
vio
->
sd
,
(
long
)
ptr
->
ssl_context
));
...
@@ -204,13 +199,9 @@ int sslconnect(struct st_VioSSLFd *ptr, Vio *vio, long timeout)
...
@@ -204,13 +199,9 @@ int sslconnect(struct st_VioSSLFd *ptr, Vio *vio, long timeout)
SSL_SESSION_set_timeout
(
SSL_get_session
(
ssl
),
timeout
);
SSL_SESSION_set_timeout
(
SSL_get_session
(
ssl
),
timeout
);
SSL_set_fd
(
ssl
,
vio
->
sd
);
SSL_set_fd
(
ssl
,
vio
->
sd
);
/*
if
(
connect_accept_func
(
ssl
)
<
1
)
SSL_do_handshake will select between SSL_connect
or SSL_accept depending on server or client side
*/
if
(
SSL_do_handshake
(
ssl
)
<
1
)
{
{
DBUG_PRINT
(
"error"
,
(
"SSL_
do_handshake
failure"
));
DBUG_PRINT
(
"error"
,
(
"SSL_
connect/accept
failure"
));
report_errors
(
ssl
);
report_errors
(
ssl
);
SSL_free
(
ssl
);
SSL_free
(
ssl
);
vio_blocking
(
vio
,
was_blocking
,
&
unused
);
vio_blocking
(
vio
,
was_blocking
,
&
unused
);
...
@@ -259,6 +250,20 @@ int sslconnect(struct st_VioSSLFd *ptr, Vio *vio, long timeout)
...
@@ -259,6 +250,20 @@ int sslconnect(struct st_VioSSLFd *ptr, Vio *vio, long timeout)
}
}
int
sslaccept
(
struct
st_VioSSLFd
*
ptr
,
Vio
*
vio
,
long
timeout
)
{
DBUG_ENTER
(
"sslaccept"
);
DBUG_RETURN
(
ssl_do
(
ptr
,
vio
,
timeout
,
SSL_accept
));
}
int
sslconnect
(
struct
st_VioSSLFd
*
ptr
,
Vio
*
vio
,
long
timeout
)
{
DBUG_ENTER
(
"sslconnect"
);
DBUG_RETURN
(
ssl_do
(
ptr
,
vio
,
timeout
,
SSL_connect
));
}
int
vio_ssl_blocking
(
Vio
*
vio
__attribute__
((
unused
)),
int
vio_ssl_blocking
(
Vio
*
vio
__attribute__
((
unused
)),
my_bool
set_blocking_mode
,
my_bool
set_blocking_mode
,
my_bool
*
old_mode
)
my_bool
*
old_mode
)
...
@@ -269,4 +274,6 @@ int vio_ssl_blocking(Vio *vio __attribute__((unused)),
...
@@ -269,4 +274,6 @@ int vio_ssl_blocking(Vio *vio __attribute__((unused)),
return
(
set_blocking_mode
?
0
:
1
);
return
(
set_blocking_mode
?
0
:
1
);
}
}
#endif
/* HAVE_OPENSSL */
#endif
/* HAVE_OPENSSL */
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