Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cta
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
dCache
cta
Commits
a5fa83e1
Commit
a5fa83e1
authored
11 years ago
by
Steven Murray
Browse files
Options
Downloads
Patches
Plain Diff
Improved connectWithTimeout() but improvements are still needed
parent
c7e1fddd
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
castor/io/io.cpp
+24
-9
24 additions, 9 deletions
castor/io/io.cpp
with
24 additions
and
9 deletions
castor/io/io.cpp
+
24
−
9
View file @
a5fa83e1
...
...
@@ -825,15 +825,30 @@ int castor::io::connectWithTimeout(
throw
(
castor
::
exception
::
TimeOut
,
castor
::
exception
::
Exception
)
{
std
::
ostringstream
portStream
;
portStream
<<
port
;
struct
addrinfo
*
result
;
getAddrInfo
(
hostName
.
c_str
(),
portStream
.
str
().
c_str
(),
NULL
,
&
result
);
return
connectWithTimeout
(
result
->
ai_family
,
result
->
ai_socktype
,
result
->
ai_protocol
,
result
->
ai_addr
,
result
->
ai_addrlen
,
timeout
);
struct
addrinfo
hints
;
memset
(
&
hints
,
'\0'
,
sizeof
(
hints
));
hints
.
ai_family
=
AF_INET
;
hints
.
ai_socktype
=
SOCK_STREAM
;
struct
addrinfo
*
results
=
NULL
;
getAddrInfo
(
hostName
.
c_str
(),
portStream
.
str
().
c_str
(),
&
hints
,
&
results
);
if
(
NULL
==
results
)
{
castor
::
exception
::
Internal
ex
;
ex
.
getMessage
()
<<
"Failed to connect to port "
<<
port
<<
" of host "
<<
hostName
<<
": The linked list of results from getAddrInfo() is NULL"
;
throw
ex
;
}
// The following TEMPORARY code will leak memory if connectWithTimeout()
// throws an exception - This code therefore needs to be fixed.
const
int
rc
=
connectWithTimeout
(
results
[
0
].
ai_family
,
results
[
0
].
ai_socktype
,
results
[
0
].
ai_protocol
,
results
[
0
].
ai_addr
,
results
[
0
].
ai_addrlen
,
timeout
);
freeaddrinfo
(
results
);
return
rc
;
}
//------------------------------------------------------------------------------
...
...
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