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
57c34083
Commit
57c34083
authored
Jun 30, 2004
by
tomas@poseidon.ndb.mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
see respective file
parent
a99f5c42
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
176 additions
and
159 deletions
+176
-159
ndb/src/common/mgmcommon/ConfigInfo.cpp
ndb/src/common/mgmcommon/ConfigInfo.cpp
+20
-24
ndb/src/common/mgmcommon/LocalConfig.cpp
ndb/src/common/mgmcommon/LocalConfig.cpp
+11
-12
ndb/src/common/transporter/SHM_Transporter.cpp
ndb/src/common/transporter/SHM_Transporter.cpp
+126
-5
ndb/src/common/transporter/SHM_Transporter.hpp
ndb/src/common/transporter/SHM_Transporter.hpp
+3
-0
ndb/src/common/transporter/SHM_Transporter.unix.cpp
ndb/src/common/transporter/SHM_Transporter.unix.cpp
+15
-108
ndb/src/kernel/vm/Configuration.cpp
ndb/src/kernel/vm/Configuration.cpp
+1
-10
No files found.
ndb/src/common/mgmcommon/ConfigInfo.cpp
View file @
57c34083
...
...
@@ -182,8 +182,8 @@ const DepricationTransform f_deprication[] = {
,{
"TCP"
,
"SendBufferSize"
,
"SendBufferMemory"
,
0
,
16384
}
,{
"TCP"
,
"MaxReceiveSize"
,
"ReceiveBufferMemory"
,
0
,
16384
}
,{
"SHM"
,
"ProcessId1"
,
"NodeId1"
,
0
,
1
}
,{
"SHM"
,
"ProcessId2"
,
"NodeId2"
,
0
,
1
}
//
,{ "SHM", "ProcessId1", "NodeId1", 0, 1}
//
,{ "SHM", "ProcessId2", "NodeId2", 0, 1}
,{
"SCI"
,
"ProcessId1"
,
"NodeId1"
,
0
,
1
}
,{
"SCI"
,
"ProcessId2"
,
"NodeId2"
,
0
,
1
}
,{
"OSE"
,
"ProcessId1"
,
"NodeId1"
,
0
,
1
}
...
...
@@ -246,7 +246,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
KEY_INTERNAL
,
"HostName"
,
"COMPUTER"
,
"Hostname of computer (e.g.
alzato
.com)"
,
"Hostname of computer (e.g.
mysql
.com)"
,
ConfigInfo
::
USED
,
false
,
ConfigInfo
::
STRING
,
...
...
@@ -330,18 +330,6 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
0
,
0x7FFFFFFF
},
{
CFG_SYS_PORT_BASE
,
"PortBase"
,
"SYSTEM"
,
"Base port for system"
,
ConfigInfo
::
USED
,
false
,
ConfigInfo
::
INT
,
NDB_BASE_PORT
+
2
,
0
,
0x7FFFFFFF
},
/***************************************************************************
* DB
***************************************************************************/
...
...
@@ -2238,7 +2226,7 @@ const int ConfigInfo::m_NoOfParams = sizeof(m_ParamInfo) / sizeof(ParamInfo);
/****************************************************************************
* Ctor
****************************************************************************/
inline
void
require
(
bool
v
)
{
if
(
!
v
)
abort
();}
static
void
require
(
bool
v
)
{
if
(
!
v
)
abort
();}
ConfigInfo
::
ConfigInfo
()
{
Properties
*
section
;
...
...
@@ -2670,6 +2658,9 @@ transformSystem(InitConfigFileParser::Context & ctx, const char * data){
ctx
.
fname
,
ctx
.
m_sectionLineno
);
return
false
;
}
ndbout
<<
"transformSystem "
<<
name
<<
endl
;
snprintf
(
ctx
.
pname
,
sizeof
(
ctx
.
pname
),
"SYSTEM_%s"
,
name
);
return
true
;
...
...
@@ -2960,25 +2951,30 @@ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){
Uint32
port
=
0
;
if
(
!
node
->
get
(
"ServerPort"
,
&
port
)
&&
!
ctx
.
m_userProperties
.
get
(
"ServerPort_"
,
id1
,
&
port
))
{
hostname
.
append
(
"_ServerPortAdder"
);
Uint32
adder
=
0
;
ctx
.
m_userProperties
.
get
(
hostname
.
c_str
(),
&
adder
);
ctx
.
m_userProperties
.
put
(
hostname
.
c_str
(),
adder
+
1
,
true
);
Uint32
base
=
0
;
{
BaseString
server_port_adder
(
hostname
);
server_port_adder
.
append
(
"_ServerPortAdder"
);
ctx
.
m_userProperties
.
get
(
server_port_adder
.
c_str
(),
&
adder
);
ctx
.
m_userProperties
.
put
(
server_port_adder
.
c_str
(),
adder
+
1
,
true
);
}
Uint32
base
=
0
;
if
(
!
(
ctx
.
m_userDefaults
&&
ctx
.
m_userDefaults
->
get
(
"PortNumber"
,
&
base
))
&&
!
ctx
.
m_systemDefaults
->
get
(
"PortNumber"
,
&
base
)){
ctx
.
reportError
(
"Cannot retrieve base port number"
);
return
false
;
}
port
=
base
+
adder
;
ctx
.
m_userProperties
.
put
(
"ServerPort_"
,
id1
,
port
);
}
if
(
ctx
.
m_currentSection
->
contains
(
"PortNumber"
))
{
ndbout
<<
"PortNumber should no longer be specificied per connection, please remove from config. Will be changed to "
<<
port
<<
endl
;
}
ctx
.
m_currentSection
->
put
(
"PortNumber"
,
port
);
ctx
.
m_currentSection
->
put
(
"PortNumber"
,
port
,
true
);
}
else
ctx
.
m_currentSection
->
put
(
"PortNumber"
,
port
);
return
true
;
}
...
...
ndb/src/common/mgmcommon/LocalConfig.cpp
View file @
57c34083
...
...
@@ -192,7 +192,7 @@ LocalConfig::parseNodeId(const char * buf){
bool
LocalConfig
::
parseHostName
(
const
char
*
buf
){
char
tempString
[
10
0
];
char
tempString
[
10
24
];
int
port
;
for
(
int
i
=
0
;
hostNameTokens
[
i
]
!=
0
;
i
++
)
{
if
(
sscanf
(
buf
,
hostNameTokens
[
i
],
tempString
,
&
port
)
==
2
)
{
...
...
@@ -209,7 +209,7 @@ LocalConfig::parseHostName(const char * buf){
bool
LocalConfig
::
parseFileName
(
const
char
*
buf
){
char
tempString
[
10
0
];
char
tempString
[
10
24
];
for
(
int
i
=
0
;
fileNameTokens
[
i
]
!=
0
;
i
++
)
{
if
(
sscanf
(
buf
,
fileNameTokens
[
i
],
tempString
)
==
1
)
{
MgmtSrvrId
*
mgmtSrvrId
=
new
MgmtSrvrId
();
...
...
@@ -224,10 +224,9 @@ LocalConfig::parseFileName(const char * buf){
bool
LocalConfig
::
parseString
(
const
char
*
connectString
,
bool
onlyNodeId
,
char
*
line
){
bool
return_value
=
true
;
char
*
for_strtok
;
char
*
copy
=
strdup
(
connectString
);
NdbAutoPtr
<
char
>
tmp_aptr
(
copy
);
bool
b_nodeId
=
false
;
bool
found_other
=
false
;
...
...
@@ -248,18 +247,18 @@ LocalConfig::parseString(const char * connectString, bool onlyNodeId, char *line
if
(
found_other
=
parseFileName
(
tok
))
continue
;
snprintf
(
line
,
150
,
"Unexpected entry:
\"
%s
\"
"
,
tok
);
return_value
=
false
;
break
;
if
(
line
)
snprintf
(
line
,
150
,
"Unexpected entry:
\"
%s
\"
"
,
tok
)
;
return
false
;
}
if
(
return_value
&&
!
onlyNodeId
&&
!
found_other
)
{
return_value
=
false
;
snprintf
(
line
,
150
,
"Missing host/file name extry in
\"
%s
\"
"
,
connectString
);
if
(
!
onlyNodeId
&&
!
found_other
)
{
if
(
line
)
snprintf
(
line
,
150
,
"Missing host/file name extry in
\"
%s
\"
"
,
connectString
);
return
false
;
}
free
(
copy
);
return
return_value
;
return
true
;
}
bool
LocalConfig
::
readFile
(
const
char
*
filename
,
bool
&
fopenError
,
bool
onlyNodeId
)
...
...
ndb/src/common/transporter/SHM_Transporter.cpp
View file @
57c34083
...
...
@@ -23,11 +23,8 @@
#include <NdbSleep.h>
#include <NdbOut.hpp>
#ifndef NDB_WIN32
#include <sys/ipc.h>
#include <sys/shm.h>
#endif
#include <InputStream.hpp>
#include <OutputStream.hpp>
SHM_Transporter
::
SHM_Transporter
(
TransporterRegistry
&
t_reg
,
const
char
*
lHostName
,
...
...
@@ -222,3 +219,127 @@ SHM_Transporter::prepareSend(const SignalHeader * const signalHeader,
return SEND_DISCONNECTED;
}
#endif
bool
SHM_Transporter
::
connect_server_impl
(
NDB_SOCKET_TYPE
sockfd
)
{
SocketOutputStream
s_output
(
sockfd
);
SocketInputStream
s_input
(
sockfd
);
char
buf
[
256
];
// Create
if
(
!
_shmSegCreated
){
if
(
!
ndb_shm_create
())
{
report_error
(
TE_SHM_UNABLE_TO_CREATE_SEGMENT
);
NDB_CLOSE_SOCKET
(
sockfd
);
return
false
;
}
_shmSegCreated
=
true
;
}
// Attach
if
(
!
_attached
){
if
(
!
ndb_shm_attach
())
{
report_error
(
TE_SHM_UNABLE_TO_ATTACH_SEGMENT
);
NDB_CLOSE_SOCKET
(
sockfd
);
return
false
;
}
_attached
=
true
;
}
// Send ok to client
s_output
.
println
(
"shm server 1 ok"
);
// Wait for ok from client
if
(
s_input
.
gets
(
buf
,
256
)
==
0
)
{
NDB_CLOSE_SOCKET
(
sockfd
);
return
false
;
}
int
r
=
connect_common
(
sockfd
);
if
(
r
)
{
// Send ok to client
s_output
.
println
(
"shm server 2 ok"
);
// Wait for ok from client
if
(
s_input
.
gets
(
buf
,
256
)
==
0
)
{
NDB_CLOSE_SOCKET
(
sockfd
);
return
false
;
}
}
NDB_CLOSE_SOCKET
(
sockfd
);
return
r
;
}
bool
SHM_Transporter
::
connect_client_impl
(
NDB_SOCKET_TYPE
sockfd
)
{
SocketInputStream
s_input
(
sockfd
);
SocketOutputStream
s_output
(
sockfd
);
char
buf
[
256
];
// Wait for server to create and attach
if
(
s_input
.
gets
(
buf
,
256
)
==
0
)
{
NDB_CLOSE_SOCKET
(
sockfd
);
return
false
;
}
// Create
if
(
!
_shmSegCreated
){
if
(
!
ndb_shm_get
())
{
NDB_CLOSE_SOCKET
(
sockfd
);
return
false
;
}
_shmSegCreated
=
true
;
}
// Attach
if
(
!
_attached
){
if
(
!
ndb_shm_attach
())
{
report_error
(
TE_SHM_UNABLE_TO_ATTACH_SEGMENT
);
NDB_CLOSE_SOCKET
(
sockfd
);
return
false
;
}
_attached
=
true
;
}
// Send ok to server
s_output
.
println
(
"shm client 1 ok"
);
int
r
=
connect_common
(
sockfd
);
if
(
r
)
{
// Wait for ok from server
if
(
s_input
.
gets
(
buf
,
256
)
==
0
)
{
NDB_CLOSE_SOCKET
(
sockfd
);
return
false
;
}
// Send ok to server
s_output
.
println
(
"shm client 2 ok"
);
}
NDB_CLOSE_SOCKET
(
sockfd
);
return
r
;
}
bool
SHM_Transporter
::
connect_common
(
NDB_SOCKET_TYPE
sockfd
)
{
if
(
!
checkConnected
())
return
false
;
if
(
!
setupBuffersDone
)
{
setupBuffers
();
setupBuffersDone
=
true
;
}
if
(
setupBuffersDone
)
{
NdbSleep_MilliSleep
(
m_timeOutMillis
);
if
(
*
serverStatusFlag
==
1
&&
*
clientStatusFlag
==
1
)
return
true
;
}
return
false
;
}
ndb/src/common/transporter/SHM_Transporter.hpp
View file @
57c34083
...
...
@@ -108,6 +108,9 @@ protected:
bool
connect_common
(
NDB_SOCKET_TYPE
sockfd
);
bool
ndb_shm_create
();
bool
ndb_shm_get
();
bool
ndb_shm_attach
();
/**
* Check if there are two processes attached to the segment (a connection)
...
...
ndb/src/common/transporter/SHM_Transporter.unix.cpp
View file @
57c34083
...
...
@@ -23,132 +23,40 @@
#include <NdbSleep.h>
#include <NdbOut.hpp>
#include <InputStream.hpp>
#include <OutputStream.hpp>
#include <sys/ipc.h>
#include <sys/shm.h>
bool
SHM_Transporter
::
connect_server_impl
(
NDB_SOCKET_TYPE
sockfd
)
SHM_Transporter
::
ndb_shm_create
(
)
{
SocketOutputStream
s_output
(
sockfd
);
SocketInputStream
s_input
(
sockfd
);
if
(
!
_shmSegCreated
){
shmId
=
shmget
(
shmKey
,
shmSize
,
IPC_CREAT
|
960
);
if
(
shmId
==
-
1
){
perror
(
"shmget: "
);
report_error
(
TE_SHM_UNABLE_TO_CREATE_SEGMENT
);
NdbSleep_MilliSleep
(
m_timeOutMillis
);
NDB_CLOSE_SOCKET
(
sockfd
);
return
false
;
}
_shmSegCreated
=
true
;
}
s_output
.
println
(
"shm server 1 ok"
);
char
buf
[
256
];
if
(
s_input
.
gets
(
buf
,
256
)
==
0
)
{
NDB_CLOSE_SOCKET
(
sockfd
);
shmId
=
shmget
(
shmKey
,
shmSize
,
IPC_CREAT
|
960
);
if
(
shmId
==
-
1
)
{
perror
(
"shmget: "
);
return
false
;
}
int
r
=
connect_common
(
sockfd
);
if
(
r
)
{
s_output
.
println
(
"shm server 2 ok"
);
if
(
s_input
.
gets
(
buf
,
256
)
==
0
)
{
NDB_CLOSE_SOCKET
(
sockfd
);
return
false
;
}
}
NDB_CLOSE_SOCKET
(
sockfd
);
return
r
;
return
true
;
}
bool
SHM_Transporter
::
connect_client_impl
(
NDB_SOCKET_TYPE
sockfd
)
SHM_Transporter
::
ndb_shm_get
(
)
{
SocketInputStream
s_input
(
sockfd
);
SocketOutputStream
s_output
(
sockfd
);
char
buf
[
256
];
if
(
s_input
.
gets
(
buf
,
256
)
==
0
)
{
NDB_CLOSE_SOCKET
(
sockfd
);
shmId
=
shmget
(
shmKey
,
shmSize
,
0
);
if
(
shmId
==
-
1
)
{
perror
(
"shmget: "
);
return
false
;
}
if
(
!
_shmSegCreated
){
shmId
=
shmget
(
shmKey
,
shmSize
,
0
);
if
(
shmId
==
-
1
){
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
;
return
true
;
}
bool
SHM_Transporter
::
connect_common
(
NDB_SOCKET_TYPE
sockfd
)
SHM_Transporter
::
ndb_shm_attach
(
)
{
if
(
!
_attached
){
shmBuf
=
(
char
*
)
shmat
(
shmId
,
0
,
0
);
if
(
shmBuf
==
0
){
report_error
(
TE_SHM_UNABLE_TO_ATTACH_SEGMENT
);
NdbSleep_MilliSleep
(
m_timeOutMillis
);
return
false
;
}
_attached
=
true
;
}
struct
shmid_ds
info
;
const
int
res
=
shmctl
(
shmId
,
IPC_STAT
,
&
info
);
if
(
res
==
-
1
){
report_error
(
TE_SHM_IPC_STAT
);
NdbSleep_MilliSleep
(
m_timeOutMillis
);
shmBuf
=
(
char
*
)
shmat
(
shmId
,
0
,
0
);
if
(
shmBuf
==
0
)
{
perror
(
"shmat: "
);
return
false
;
}
if
(
info
.
shm_nattch
==
2
&&
!
setupBuffersDone
)
{
setupBuffers
();
setupBuffersDone
=
true
;
}
if
(
setupBuffersDone
)
{
NdbSleep_MilliSleep
(
m_timeOutMillis
);
if
(
*
serverStatusFlag
==
1
&&
*
clientStatusFlag
==
1
)
return
true
;
}
if
(
info
.
shm_nattch
>
2
){
report_error
(
TE_SHM_DISCONNECT
);
NdbSleep_MilliSleep
(
m_timeOutMillis
);
return
false
;
}
NdbSleep_MilliSleep
(
m_timeOutMillis
);
return
false
;
return
true
;
}
bool
...
...
@@ -190,4 +98,3 @@ SHM_Transporter::disconnectImpl(){
}
setupBuffersDone
=
false
;
}
ndb/src/kernel/vm/Configuration.cpp
View file @
57c34083
...
...
@@ -106,17 +106,8 @@ Configuration::init(int argc, const char** argv){
_initialStart
=
true
;
// Check connectstring
if
(
_connect_str
){
if
(
_connect_str
[
0
]
==
'-'
||
strstr
(
_connect_str
,
"host"
)
==
0
||
strstr
(
_connect_str
,
"nodeid"
)
==
0
)
{
ndbout
<<
"Illegal/empty connectString: "
<<
_connect_str
<<
endl
;
arg_printusage
(
args
,
num_args
,
argv
[
0
],
desc
);
return
false
;
}
if
(
_connect_str
)
_connectString
=
strdup
(
_connect_str
);
}
// Check deamon flag
if
(
_deamon
)
...
...
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