Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RadioObservatory
LOFAR
Commits
b19ac6fe
Commit
b19ac6fe
authored
18 years ago
by
Chris Broekema
Browse files
Options
Downloads
Patches
Plain Diff
BugID: 1011
Add send and recv buffer to constructor and call initBuffers when the socket is created.
parent
bacc5b6c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
LCS/Transport/src/TH_Socket.cc
+28
-14
28 additions, 14 deletions
LCS/Transport/src/TH_Socket.cc
with
28 additions
and
14 deletions
LCS/Transport/src/TH_Socket.cc
+
28
−
14
View file @
b19ac6fe
...
@@ -43,7 +43,9 @@ TH_Socket::TH_Socket (const string& service,
...
@@ -43,7 +43,9 @@ TH_Socket::TH_Socket (const string& service,
bool
sync
,
bool
sync
,
int32
protocol
,
int32
protocol
,
int32
backlog
,
int32
backlog
,
const
bool
openSocketNow
)
:
const
bool
openSocketNow
,
const
int
recvBufferSize
,
const
int
sendBufferSize
)
:
itsIsServer
(
true
),
itsIsServer
(
true
),
itsServerSocket
(
0
),
itsServerSocket
(
0
),
itsDataSocket
(
0
),
itsDataSocket
(
0
),
...
@@ -54,10 +56,12 @@ TH_Socket::TH_Socket (const string& service,
...
@@ -54,10 +56,12 @@ TH_Socket::TH_Socket (const string& service,
itsProtocol
(
protocol
),
itsProtocol
(
protocol
),
itsBacklog
(
backlog
),
itsBacklog
(
backlog
),
itsIsBlocking
(
sync
),
itsIsBlocking
(
sync
),
itsLastCmd
(
CmdNone
)
itsLastCmd
(
CmdNone
),
itsRecvBufferSize
(
recvBufferSize
),
itsSendBufferSize
(
sendBufferSize
)
{
{
LOG_TRACE_FLOW
(
"TH_Socket<server>"
);
LOG_TRACE_FLOW
(
"TH_Socket<server>"
);
if
(
openSocketNow
)
{
if
(
openSocketNow
)
{
ASSERTSTR
(
openSocket
(),
"Could not open server socket"
);
ASSERTSTR
(
openSocket
(),
"Could not open server socket"
);
}
}
...
@@ -71,7 +75,9 @@ TH_Socket::TH_Socket (const string& hostName,
...
@@ -71,7 +75,9 @@ TH_Socket::TH_Socket (const string& hostName,
const
string
&
service
,
const
string
&
service
,
bool
sync
,
bool
sync
,
int32
protocol
,
int32
protocol
,
const
bool
openSocketNow
)
:
const
bool
openSocketNow
,
const
int
recvBufferSize
,
const
int
sendBufferSize
)
:
itsIsServer
(
false
),
itsIsServer
(
false
),
itsServerSocket
(
0
),
itsServerSocket
(
0
),
itsDataSocket
(
0
),
itsDataSocket
(
0
),
...
@@ -82,7 +88,9 @@ TH_Socket::TH_Socket (const string& hostName,
...
@@ -82,7 +88,9 @@ TH_Socket::TH_Socket (const string& hostName,
itsProtocol
(
protocol
),
itsProtocol
(
protocol
),
itsBacklog
(
0
),
itsBacklog
(
0
),
itsIsBlocking
(
sync
),
itsIsBlocking
(
sync
),
itsLastCmd
(
CmdNone
)
itsLastCmd
(
CmdNone
),
itsRecvBufferSize
(
recvBufferSize
),
itsSendBufferSize
(
sendBufferSize
)
{
{
LOG_TRACE_FLOW
(
"TH_Socket<client>"
);
LOG_TRACE_FLOW
(
"TH_Socket<client>"
);
...
@@ -320,6 +328,8 @@ void TH_Socket::waitForSent(void*, int, int)
...
@@ -320,6 +328,8 @@ void TH_Socket::waitForSent(void*, int, int)
//
//
bool
TH_Socket
::
init
()
bool
TH_Socket
::
init
()
{
{
bool
result
;
LOG_TRACE_RTTI
(
"TH_Socket::init()"
);
LOG_TRACE_RTTI
(
"TH_Socket::init()"
);
if
(
!
openSocket
())
{
if
(
!
openSocket
())
{
...
@@ -334,10 +344,12 @@ bool TH_Socket::init()
...
@@ -334,10 +344,12 @@ bool TH_Socket::init()
itsLastCmd
=
CmdNone
;
itsLastCmd
=
CmdNone
;
if
(
itsIsServer
)
{
if
(
itsIsServer
)
{
return
(
connectToClient
());
result
=
connectToClient
();
}
else
{
result
=
connectToServer
();
}
}
initBuffers
(
itsRecvBufferSize
,
itsSendBufferSize
);
return
(
connectToServer
())
;
return
result
;
}
}
...
@@ -345,12 +357,13 @@ bool TH_Socket::initBuffers(int recvBufferSize, int sendBufferSize) {
...
@@ -345,12 +357,13 @@ bool TH_Socket::initBuffers(int recvBufferSize, int sendBufferSize) {
// set the size of the kernel level socket buffer
// set the size of the kernel level socket buffer
// use -1 in the constructor (default) to leave it untouched.
// use -1 in the constructor (default) to leave it untouched.
#ifndef HAVE_BGL // BG/L doesn't implement setsockopt
int
socketFD
;
int
socketFD
;
if
(
itsIsServer
)
socketFD
=
itsServerSocket
->
getSid
();
if
(
itsIsServer
&&
itsServerSocket
!=
NULL
)
socketFD
=
itsServerSocket
->
getSid
();
else
socketFD
=
itsDataSocket
->
getSid
();
else
socketFD
=
itsDataSocket
->
getSid
();
if
(
recvBufferSize
!=
-
1
)
{
if
(
recvBufferSize
!=
-
1
)
{
#if defined __linux__
&& !defined HAVE_BGL
#if defined __linux__
int
name
[]
=
{
CTL_NET
,
NET_CORE
,
NET_CORE_RMEM_MAX
};
int
name
[]
=
{
CTL_NET
,
NET_CORE
,
NET_CORE_RMEM_MAX
};
int
value
;
int
value
;
size_t
valueSize
=
sizeof
(
value
);
size_t
valueSize
=
sizeof
(
value
);
...
@@ -362,16 +375,16 @@ bool TH_Socket::initBuffers(int recvBufferSize, int sendBufferSize) {
...
@@ -362,16 +375,16 @@ bool TH_Socket::initBuffers(int recvBufferSize, int sendBufferSize) {
LOG_WARN
(
"TH_Socket: could not increase max socket receive buffer"
);
LOG_WARN
(
"TH_Socket: could not increase max socket receive buffer"
);
}
}
}
}
#endif
// now set the buffer for our socket
// now set the buffer for our socket
if
(
setsockopt
(
socketFD
,
SOL_SOCKET
,
SO_RCVBUF
,
&
recvBufferSize
,
sizeof
(
recvBufferSize
))
<
0
)
if
(
setsockopt
(
socketFD
,
SOL_SOCKET
,
SO_RCVBUF
,
&
recvBufferSize
,
sizeof
(
recvBufferSize
))
<
0
)
{
{
LOG_WARN
(
"TH_Socket: receive buffer size could not be set, default size will be used."
);
LOG_WARN
(
"TH_Socket: receive buffer size could not be set, default size will be used."
);
}
}
#endif
}
}
if
(
sendBufferSize
!=
-
1
)
{
if
(
sendBufferSize
!=
-
1
)
{
#if defined __linux__
&& !defined HAVE_BGL
#if defined __linux__
int
name
[]
=
{
CTL_NET
,
NET_CORE
,
NET_CORE_WMEM_MAX
};
int
name
[]
=
{
CTL_NET
,
NET_CORE
,
NET_CORE_WMEM_MAX
};
int
value
;
int
value
;
size_t
valueSize
=
sizeof
(
value
);
size_t
valueSize
=
sizeof
(
value
);
...
@@ -383,13 +396,14 @@ bool TH_Socket::initBuffers(int recvBufferSize, int sendBufferSize) {
...
@@ -383,13 +396,14 @@ bool TH_Socket::initBuffers(int recvBufferSize, int sendBufferSize) {
LOG_WARN
(
"TH_Socket: could not increase max socket send buffer"
);
LOG_WARN
(
"TH_Socket: could not increase max socket send buffer"
);
}
}
}
}
#endif
if
(
setsockopt
(
socketFD
,
SOL_SOCKET
,
SO_SNDBUF
,
&
sendBufferSize
,
sizeof
(
sendBufferSize
))
<
0
)
if
(
setsockopt
(
socketFD
,
SOL_SOCKET
,
SO_SNDBUF
,
&
sendBufferSize
,
sizeof
(
sendBufferSize
))
<
0
)
{
{
LOG_WARN
(
"TH_Socket: send buffer size could not be set, default size will be used."
);
LOG_WARN
(
"TH_Socket: send buffer size could not be set, default size will be used."
);
}
}
#endif
}
}
#endif
/* HAVE_BGL */
return
true
;
return
true
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment