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
a99f5c42
Commit
a99f5c42
authored
Jun 29, 2004
by
tomas@poseidon.ndb.mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed compile of shm transporter
parent
dddcc371
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
135 additions
and
110 deletions
+135
-110
ndb/include/mgmapi/mgmapi_config_parameters.h
ndb/include/mgmapi/mgmapi_config_parameters.h
+1
-1
ndb/include/transporter/TransporterDefinitions.hpp
ndb/include/transporter/TransporterDefinitions.hpp
+1
-0
ndb/src/common/mgmcommon/ConfigInfo.cpp
ndb/src/common/mgmcommon/ConfigInfo.cpp
+15
-2
ndb/src/common/mgmcommon/IPCConfig.cpp
ndb/src/common/mgmcommon/IPCConfig.cpp
+14
-9
ndb/src/common/mgmcommon/NdbConfig.c
ndb/src/common/mgmcommon/NdbConfig.c
+2
-1
ndb/src/common/transporter/SHM_Transporter.cpp
ndb/src/common/transporter/SHM_Transporter.cpp
+10
-21
ndb/src/common/transporter/SHM_Transporter.hpp
ndb/src/common/transporter/SHM_Transporter.hpp
+12
-15
ndb/src/common/transporter/SHM_Transporter.unix.cpp
ndb/src/common/transporter/SHM_Transporter.unix.cpp
+69
-54
ndb/src/common/transporter/TransporterRegistry.cpp
ndb/src/common/transporter/TransporterRegistry.cpp
+8
-4
ndb/src/mgmsrv/Services.cpp
ndb/src/mgmsrv/Services.cpp
+3
-3
No files found.
ndb/include/mgmapi/mgmapi_config_parameters.h
View file @
a99f5c42
...
...
@@ -88,11 +88,11 @@
#define CFG_CONNECTION_CHECKSUM 403
#define CFG_CONNECTION_NODE_1_SYSTEM 404
#define CFG_CONNECTION_NODE_2_SYSTEM 405
#define CFG_CONNECTION_SERVER_PORT 406
#define CFG_TCP_HOSTNAME_1 450
#define CFG_TCP_HOSTNAME_2 451
#define CFG_TCP_SERVER 452
#define CFG_TCP_SERVER_PORT 453
#define CFG_TCP_SEND_BUFFER_SIZE 454
#define CFG_TCP_RECEIVE_BUFFER_SIZE 455
#define CFG_TCP_PROXY 456
...
...
ndb/include/transporter/TransporterDefinitions.hpp
View file @
a99f5c42
...
...
@@ -69,6 +69,7 @@ struct TCP_TransporterConfiguration {
* SHM Transporter Configuration
*/
struct
SHM_TransporterConfiguration
{
Uint32
port
;
NodeId
remoteNodeId
;
NodeId
localNodeId
;
bool
compression
;
...
...
ndb/src/common/mgmcommon/ConfigInfo.cpp
View file @
a99f5c42
...
...
@@ -104,6 +104,7 @@ ConfigInfo::m_SectionRules[] = {
{
"OSE"
,
fixHostname
,
"HostName2"
},
{
"TCP"
,
fixPortNumber
,
0
},
// has to come after fixHostName
{
"SHM"
,
fixPortNumber
,
0
},
// has to come after fixHostName
//{ "SHM", fixShmKey, 0 },
/**
...
...
@@ -1559,14 +1560,14 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
0x7FFFFFFF
},
{
CFG_
TCP
_SERVER_PORT
,
CFG_
CONNECTION
_SERVER_PORT
,
"PortNumber"
,
"TCP"
,
"Port used for this transporter"
,
ConfigInfo
::
USED
,
false
,
ConfigInfo
::
INT
,
NDB_BASE_PORT
+
2
,
MANDATORY
,
0
,
0x7FFFFFFF
},
...
...
@@ -1695,6 +1696,18 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
0
,
0x7FFFFFFF
},
{
CFG_CONNECTION_SERVER_PORT
,
"PortNumber"
,
"SHM"
,
"Port used for this transporter"
,
ConfigInfo
::
USED
,
false
,
ConfigInfo
::
INT
,
MANDATORY
,
0
,
0x7FFFFFFF
},
{
KEY_INTERNAL
,
"ProcessId1"
,
...
...
ndb/src/common/mgmcommon/IPCConfig.cpp
View file @
a99f5c42
...
...
@@ -365,6 +365,16 @@ IPCConfig::configureTransporters(Uint32 nodeId,
Uint32
type
=
~
0
;
if
(
iter
.
get
(
CFG_TYPE_OF_SECTION
,
&
type
))
continue
;
Uint32
tmp_server_port
=
0
;
if
(
iter
.
get
(
CFG_CONNECTION_SERVER_PORT
,
&
tmp_server_port
))
break
;
if
(
nodeId
<=
nodeId1
&&
nodeId
<=
nodeId2
)
{
if
(
server_port
&&
server_port
!=
tmp_server_port
)
{
ndbout
<<
"internal error in config setup of server ports line= "
<<
__LINE__
<<
endl
;
exit
(
-
1
);
}
server_port
=
tmp_server_port
;
}
switch
(
type
){
case
CONNECTION_TYPE_SHM
:{
SHM_TransporterConfiguration
conf
;
...
...
@@ -378,6 +388,8 @@ IPCConfig::configureTransporters(Uint32 nodeId,
if
(
iter
.
get
(
CFG_SHM_KEY
,
&
conf
.
shmKey
))
break
;
if
(
iter
.
get
(
CFG_SHM_BUFFER_MEM
,
&
conf
.
shmSize
))
break
;
conf
.
port
=
tmp_server_port
;
if
(
!
tr
.
createTransporter
(
&
conf
)){
ndbout
<<
"Failed to create SHM Transporter from: "
<<
conf
.
localNodeId
<<
" to: "
<<
conf
.
remoteNodeId
<<
endl
;
...
...
@@ -429,10 +441,11 @@ IPCConfig::configureTransporters(Uint32 nodeId,
if
(
iter
.
get
(
CFG_TCP_HOSTNAME_1
,
&
host1
))
break
;
if
(
iter
.
get
(
CFG_TCP_HOSTNAME_2
,
&
host2
))
break
;
if
(
iter
.
get
(
CFG_TCP_SERVER_PORT
,
&
conf
.
port
))
break
;
if
(
iter
.
get
(
CFG_TCP_SEND_BUFFER_SIZE
,
&
conf
.
sendBufferSize
))
break
;
if
(
iter
.
get
(
CFG_TCP_RECEIVE_BUFFER_SIZE
,
&
conf
.
maxReceiveSize
))
break
;
conf
.
port
=
tmp_server_port
;
const
char
*
proxy
;
if
(
!
iter
.
get
(
CFG_TCP_PROXY
,
&
proxy
))
{
if
(
strlen
(
proxy
)
>
0
&&
nodeId2
==
nodeId
)
{
...
...
@@ -441,14 +454,6 @@ IPCConfig::configureTransporters(Uint32 nodeId,
}
}
if
(
nodeId
<=
nodeId1
&&
nodeId
<=
nodeId2
)
{
if
(
server_port
&&
server_port
!=
conf
.
port
)
{
ndbout
<<
"internal error in config setup of server ports line= "
<<
__LINE__
<<
endl
;
exit
(
-
1
);
}
server_port
=
conf
.
port
;
}
conf
.
localNodeId
=
nodeId
;
conf
.
remoteNodeId
=
remoteNodeId
;
conf
.
localHostName
=
(
nodeId
==
nodeId1
?
host1
:
host2
);
...
...
ndb/src/common/mgmcommon/NdbConfig.c
View file @
a99f5c42
...
...
@@ -24,12 +24,13 @@ NdbConfig_AllocHomePath(int _len)
const
char
*
path
=
NdbEnv_GetEnv
(
"NDB_HOME"
,
0
,
0
);
int
len
=
_len
;
int
path_len
=
0
;
char
*
buf
;
if
(
path
)
path_len
=
strlen
(
path
);
len
+=
path_len
;
char
*
buf
=
malloc
(
len
);
buf
=
malloc
(
len
);
if
(
path_len
>
0
)
snprintf
(
buf
,
len
,
"%s%c"
,
path
,
DIR_SEPARATOR
);
else
...
...
ndb/src/common/transporter/SHM_Transporter.cpp
View file @
a99f5c42
...
...
@@ -29,20 +29,19 @@
#endif
SHM_Transporter
::
SHM_Transporter
(
NodeId
lNodeId
,
SHM_Transporter
::
SHM_Transporter
(
TransporterRegistry
&
t_reg
,
const
char
*
lHostName
,
const
char
*
rHostName
,
int
r_port
,
NodeId
lNodeId
,
NodeId
rNodeId
,
key_t
_shmKey
,
Uint32
_shmSize
,
bool
compression
,
bool
checksum
,
bool
signalId
)
:
Transporter
(
lNodeId
,
rNodeId
,
0
,
compression
,
checksum
,
signalId
),
isServer
(
lNodeId
<
rNodeId
),
bool
signalId
,
key_t
_shmKey
,
Uint32
_shmSize
)
:
Transporter
(
t_reg
,
lHostName
,
rHostName
,
r_port
,
lNodeId
,
rNodeId
,
0
,
compression
,
checksum
,
signalId
),
shmKey
(
_shmKey
),
shmSize
(
_shmSize
)
{
...
...
@@ -68,16 +67,6 @@ SHM_Transporter::initTransporter(){
return
true
;
}
bool
SHM_Transporter
::
connectImpl
(
Uint32
timeOutMillis
){
bool
res
;
if
(
isServer
)
res
=
connectServer
(
timeOutMillis
);
else
res
=
connectClient
(
timeOutMillis
);
return
res
;
}
void
SHM_Transporter
::
setupBuffers
(){
Uint32
sharedSize
=
0
;
...
...
ndb/src/common/transporter/SHM_Transporter.hpp
View file @
a99f5c42
...
...
@@ -32,13 +32,17 @@ typedef Uint32 key_t;
class
SHM_Transporter
:
public
Transporter
{
friend
class
TransporterRegistry
;
public:
SHM_Transporter
(
NodeId
lNodeId
,
SHM_Transporter
(
TransporterRegistry
&
,
const
char
*
lHostName
,
const
char
*
rHostName
,
int
r_port
,
NodeId
lNodeId
,
NodeId
rNodeId
,
key_t
shmKey
,
Uint32
shmSize
,
bool
compression
,
bool
checksum
,
bool
signalId
);
bool
signalId
,
key_t
shmKey
,
Uint32
shmSize
);
/**
* SHM destructor
...
...
@@ -74,14 +78,6 @@ protected:
*/
void
disconnectImpl
();
/**
* Invokes the connectServer or connectClient.
* @param timeOutMillis - the timeout the connect thread waits before
* retrying.
* @return True if connectImpl successful, otherwise false.
*/
bool
connectImpl
(
Uint32
timeOutMillis
);
/**
* Blocking
*
...
...
@@ -94,7 +90,7 @@ protected:
* i.e., both agrees that the other one has setup the segment.
* Otherwise false.
*/
bool
connectServer
(
Uint32
timeOutMillis
);
virtual
bool
connect_server_impl
(
NDB_SOCKET_TYPE
sockfd
);
/**
* Blocking
...
...
@@ -108,7 +104,9 @@ protected:
* i.e., both agrees that the other one has setup the segment.
* Otherwise false.
*/
bool
connectClient
(
Uint32
timeOutMillis
);
virtual
bool
connect_client_impl
(
NDB_SOCKET_TYPE
sockfd
);
bool
connect_common
(
NDB_SOCKET_TYPE
sockfd
);
/**
...
...
@@ -127,7 +125,6 @@ private:
bool
_shmSegCreated
;
bool
_attached
;
const
bool
isServer
;
key_t
shmKey
;
volatile
Uint32
*
serverStatusFlag
;
volatile
Uint32
*
clientStatusFlag
;
...
...
ndb/src/common/transporter/SHM_Transporter.unix.cpp
View file @
a99f5c42
...
...
@@ -23,83 +23,98 @@
#include <NdbSleep.h>
#include <NdbOut.hpp>
#include <InputStream.hpp>
#include <OutputStream.hpp>
#include <sys/ipc.h>
#include <sys/shm.h>
bool
SHM_Transporter
::
connectServer
(
Uint32
timeOutMillis
){
SHM_Transporter
::
connect_server_impl
(
NDB_SOCKET_TYPE
sockfd
)
{
SocketOutputStream
s_output
(
sockfd
);
SocketInputStream
s_input
(
sockfd
);
if
(
!
_shmSegCreated
){
shmId
=
shmget
(
shmKey
,
shmSize
,
IPC_CREAT
|
960
);
if
(
shmId
==
-
1
){
perror
(
"shmget: "
);
reportThreadError
(
remoteNodeId
,
TE_SHM_UNABLE_TO_CREATE_SEGMENT
);
NdbSleep_MilliSleep
(
timeOutMillis
);
report_error
(
TE_SHM_UNABLE_TO_CREATE_SEGMENT
);
NdbSleep_MilliSleep
(
m_timeOutMillis
);
NDB_CLOSE_SOCKET
(
sockfd
);
return
false
;
}
_shmSegCreated
=
true
;
}
if
(
!
_attached
){
shmBuf
=
(
char
*
)
shmat
(
shmId
,
0
,
0
);
if
(
shmBuf
==
0
){
perror
(
"shmat: "
);
reportThreadError
(
remoteNodeId
,
TE_SHM_UNABLE_TO_ATTACH_SEGMENT
);
NdbSleep_MilliSleep
(
timeOutMillis
);
return
false
;
}
_attached
=
true
;
}
struct
shmid_ds
info
;
const
int
res
=
shmctl
(
shmId
,
IPC_STAT
,
&
info
);
if
(
res
==
-
1
){
perror
(
"shmctl: "
);
reportThreadError
(
remoteNodeId
,
TE_SHM_IPC_STAT
);
NdbSleep_MilliSleep
(
timeOutMillis
);
s_output
.
println
(
"shm server 1 ok"
);
char
buf
[
256
];
if
(
s_input
.
gets
(
buf
,
256
)
==
0
)
{
NDB_CLOSE_SOCKET
(
sockfd
);
return
false
;
}
if
(
info
.
shm_nattch
==
2
&&
!
setupBuffersDone
)
{
setupBuffers
();
setupBuffersDone
=
true
;
}
if
(
setupBuffersDone
)
{
NdbSleep_MilliSleep
(
timeOutMillis
);
if
(
*
serverStatusFlag
==
1
&&
*
clientStatusFlag
==
1
)
return
true
;
}
int
r
=
connect_common
(
sockfd
);
if
(
info
.
shm_nattch
>
2
){
reportThreadError
(
remoteNodeId
,
TE_SHM_DISCONNECT
);
NdbSleep_MilliSleep
(
timeOutMillis
);
return
false
;
if
(
r
)
{
s_output
.
println
(
"shm server 2 ok"
);
if
(
s_input
.
gets
(
buf
,
256
)
==
0
)
{
NDB_CLOSE_SOCKET
(
sockfd
);
return
false
;
}
}
N
dbSleep_MilliSleep
(
timeOutMillis
);
return
false
;
N
DB_CLOSE_SOCKET
(
sockfd
);
return
r
;
}
bool
SHM_Transporter
::
connectClient
(
Uint32
timeOutMillis
){
if
(
!
_shmSegCreated
){
SHM_Transporter
::
connect_client_impl
(
NDB_SOCKET_TYPE
sockfd
)
{
SocketInputStream
s_input
(
sockfd
);
SocketOutputStream
s_output
(
sockfd
);
char
buf
[
256
];
if
(
s_input
.
gets
(
buf
,
256
)
==
0
)
{
NDB_CLOSE_SOCKET
(
sockfd
);
return
false
;
}
if
(
!
_shmSegCreated
){
shmId
=
shmget
(
shmKey
,
shmSize
,
0
);
if
(
shmId
==
-
1
){
NdbSleep_MilliSleep
(
timeOutMillis
);
NdbSleep_MilliSleep
(
m_timeOutMillis
);
NDB_CLOSE_SOCKET
(
sockfd
);
return
false
;
}
_shmSegCreated
=
true
;
}
s_output
.
println
(
"shm client 1 ok"
);
int
r
=
connect_common
(
sockfd
);
if
(
r
)
{
if
(
s_input
.
gets
(
buf
,
256
)
==
0
)
{
NDB_CLOSE_SOCKET
(
sockfd
);
return
false
;
}
s_output
.
println
(
"shm client 2 ok"
);
}
NDB_CLOSE_SOCKET
(
sockfd
);
return
r
;
}
bool
SHM_Transporter
::
connect_common
(
NDB_SOCKET_TYPE
sockfd
)
{
if
(
!
_attached
){
shmBuf
=
(
char
*
)
shmat
(
shmId
,
0
,
0
);
if
(
shmBuf
==
0
){
report
ThreadError
(
remoteNodeId
,
TE_SHM_UNABLE_TO_ATTACH_SEGMENT
);
NdbSleep_MilliSleep
(
timeOutMillis
);
report
_error
(
TE_SHM_UNABLE_TO_ATTACH_SEGMENT
);
NdbSleep_MilliSleep
(
m_
timeOutMillis
);
return
false
;
}
_attached
=
true
;
...
...
@@ -109,8 +124,8 @@ SHM_Transporter::connectClient(Uint32 timeOutMillis){
const
int
res
=
shmctl
(
shmId
,
IPC_STAT
,
&
info
);
if
(
res
==
-
1
){
report
ThreadError
(
remoteNodeId
,
TE_SHM_IPC_STAT
);
NdbSleep_MilliSleep
(
timeOutMillis
);
report
_error
(
TE_SHM_IPC_STAT
);
NdbSleep_MilliSleep
(
m_
timeOutMillis
);
return
false
;
}
...
...
@@ -121,18 +136,18 @@ SHM_Transporter::connectClient(Uint32 timeOutMillis){
}
if
(
setupBuffersDone
)
{
NdbSleep_MilliSleep
(
timeOutMillis
);
NdbSleep_MilliSleep
(
m_
timeOutMillis
);
if
(
*
serverStatusFlag
==
1
&&
*
clientStatusFlag
==
1
)
return
true
;
}
if
(
info
.
shm_nattch
>
2
){
report
ThreadError
(
remoteNodeId
,
TE_SHM_DISCONNECT
);
NdbSleep_MilliSleep
(
timeOutMillis
);
report
_error
(
TE_SHM_DISCONNECT
);
NdbSleep_MilliSleep
(
m_
timeOutMillis
);
return
false
;
}
NdbSleep_MilliSleep
(
timeOutMillis
);
NdbSleep_MilliSleep
(
m_
timeOutMillis
);
return
false
;
}
...
...
@@ -141,12 +156,12 @@ SHM_Transporter::checkConnected(){
struct
shmid_ds
info
;
const
int
res
=
shmctl
(
shmId
,
IPC_STAT
,
&
info
);
if
(
res
==
-
1
){
report
Error
(
callbackObj
,
remoteNodeId
,
TE_SHM_IPC_STAT
);
report
_error
(
TE_SHM_IPC_STAT
);
return
false
;
}
if
(
info
.
shm_nattch
!=
2
){
report
Error
(
callbackObj
,
remoteNodeId
,
TE_SHM_DISCONNECT
);
report
_error
(
TE_SHM_DISCONNECT
);
return
false
;
}
return
true
;
...
...
@@ -168,7 +183,7 @@ SHM_Transporter::disconnectImpl(){
if
(
isServer
&&
_shmSegCreated
){
const
int
res
=
shmctl
(
shmId
,
IPC_RMID
,
0
);
if
(
res
==
-
1
){
report
Error
(
callbackObj
,
remoteNodeId
,
TE_SHM_UNABLE_TO_REMOVE_SEGMENT
);
report
_error
(
TE_SHM_UNABLE_TO_REMOVE_SEGMENT
);
return
;
}
_shmSegCreated
=
false
;
...
...
ndb/src/common/transporter/TransporterRegistry.cpp
View file @
a99f5c42
...
...
@@ -352,13 +352,17 @@ TransporterRegistry::createTransporter(SHM_TransporterConfiguration *config) {
if
(
theTransporters
[
config
->
remoteNodeId
]
!=
NULL
)
return
false
;
SHM_Transporter
*
t
=
new
SHM_Transporter
(
config
->
localNodeId
,
SHM_Transporter
*
t
=
new
SHM_Transporter
(
*
this
,
"localhost"
,
"localhost"
,
config
->
port
,
localNodeId
,
config
->
remoteNodeId
,
config
->
shmKey
,
config
->
shmSize
,
config
->
compression
,
config
->
checksum
,
config
->
signalId
config
->
signalId
,
config
->
shmKey
,
config
->
shmSize
);
if
(
t
==
NULL
)
return
false
;
...
...
ndb/src/mgmsrv/Services.cpp
View file @
a99f5c42
...
...
@@ -390,11 +390,11 @@ MgmApiSession::get_nodeid(Parser_t::Context &,
}
struct
sockaddr
addr
;
socklen_t
addrlen
;
socklen_t
addrlen
=
sizeof
(
addr
)
;
int
r
;
if
(
r
=
get
sock
name
(
m_socket
,
&
addr
,
&
addrlen
))
{
if
(
r
=
get
peer
name
(
m_socket
,
&
addr
,
&
addrlen
))
{
m_output
->
println
(
cmd
);
m_output
->
println
(
"result: get
sock
name(%d) failed, err= %d"
,
m_socket
,
r
);
m_output
->
println
(
"result: get
peer
name(%d) failed, err= %d"
,
m_socket
,
r
);
m_output
->
println
(
""
);
return
;
}
...
...
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