Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dCache
cta
Commits
519f5b03
Commit
519f5b03
authored
Aug 22, 2016
by
Steven Murray
Browse files
Improved the error messages of the castor::io calls to poll()
parent
f0d7aa95
Changes
1
Hide whitespace changes
Inline
Side-by-side
tapeserver/castor/io/io.cpp
View file @
519f5b03
...
...
@@ -340,6 +340,24 @@ int castor::io::acceptConnection(const int listenSocketFd,
}
break
;
default:
// poll() found a file descriptor awaiting attention
if
(
pollFd
.
revents
&
POLLERR
)
{
castor
::
exception
::
Exception
ex
;
ex
.
getMessage
()
<<
"Failed to accept connection"
": POLLERR - Error condition"
;
if
(
pollFd
.
revents
&
POLLHUP
)
{
ex
.
getMessage
()
<<
": POLLHUP - Connection closed by peer"
;
}
if
(
pollFd
.
revents
&
POLLNVAL
)
{
ex
.
getMessage
()
<<
": POLLNVAL - File descriptor not open"
;
}
ex
.
getMessage
()
<<
": pollFd.fd="
<<
pollFd
.
fd
<<
",pollFd.events="
<<
pollFd
.
events
<<
",pollFd.revents="
<<
pollFd
.
revents
;
throw
ex
;
}
// If it is not the expected connection request
if
(
!
(
pollFd
.
revents
&
POLLIN
))
{
castor
::
exception
::
Exception
ex
;
...
...
@@ -928,6 +946,7 @@ int castor::io::connectWithTimeout(
pollfd
pollFd
;
pollFd
.
fd
=
smartSock
.
get
();
pollFd
.
events
=
POLLIN
&
POLLOUT
;
pollFd
.
revents
=
0
;
// Wait for the connection to complete using poll() with a timeout
const
int
pollRc
=
poll
(
&
pollFd
,
1
,
1000
*
timeout
);
...
...
@@ -947,10 +966,30 @@ int castor::io::connectWithTimeout(
throw
ex
;
}
// Throw an exception if there was an error condition on the file descriptor
if
(
pollFd
.
revents
&
POLLERR
)
{
castor
::
exception
::
Exception
ex
;
ex
.
getMessage
()
<<
"Failed to accept connection"
": POLLERR - Error condition"
;
if
(
pollFd
.
revents
&
POLLHUP
)
{
ex
.
getMessage
()
<<
": POLLHUP - Connection closed by peer"
;
}
if
(
pollFd
.
revents
&
POLLNVAL
)
{
ex
.
getMessage
()
<<
": POLLNVAL - File descriptor not open"
;
}
ex
.
getMessage
()
<<
": pollFd.fd="
<<
pollFd
.
fd
<<
",pollFd.events="
<<
pollFd
.
events
<<
",pollFd.revents="
<<
pollFd
.
revents
;
throw
ex
;
}
// Throw an exception if no file descriptor was set
if
(
!
(
pollFd
.
revents
&
POLLIN
)
&&
!
(
pollFd
.
revents
&
POLLOUT
))
{
castor
::
exception
::
Exception
ex
(
ECANCELED
);
ex
.
getMessage
()
<<
"Failed to connect: poll() returned without an event"
ex
.
getMessage
()
<<
"Failed to connect"
": poll() returned without the POLLIN or POLLOUT set"
": pollFd.fd="
<<
pollFd
.
fd
<<
",pollFd.events="
<<
pollFd
.
events
<<
",pollFd.revents="
<<
pollFd
.
revents
;
throw
ex
;
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment