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
f0b9543d
Commit
f0b9543d
authored
10 years ago
by
Steven Murray
Browse files
Options
Downloads
Patches
Plain Diff
Added idempotentKill() method to ProcessForker to prevent endless kill loops
parent
e01ac43a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
castor/tape/tapeserver/daemon/CatalogueTransferSession.cpp
+34
-15
34 additions, 15 deletions
castor/tape/tapeserver/daemon/CatalogueTransferSession.cpp
castor/tape/tapeserver/daemon/CatalogueTransferSession.hpp
+9
-0
9 additions, 0 deletions
castor/tape/tapeserver/daemon/CatalogueTransferSession.hpp
with
43 additions
and
15 deletions
castor/tape/tapeserver/daemon/CatalogueTransferSession.cpp
+
34
−
15
View file @
f0b9543d
...
...
@@ -142,18 +142,37 @@ bool castor::tape::tapeserver::daemon::CatalogueTransferSession::
"Killing data-transfer session because transfer job is too late"
,
params
);
if
(
kill
(
m_pid
,
SIGKILL
))
{
const
std
::
string
errnoStr
=
castor
::
utils
::
errnoToString
(
errno
);
params
.
push_back
(
log
::
Param
(
"message"
,
errnoStr
));
m_log
(
LOG_ERR
,
"Failed to kill data-transfer session"
,
params
);
}
else
{
try
{
idempotentKill
(
m_pid
,
SIGKILL
);
m_state
=
WAIT_TIMEOUT_KILL
;
}
catch
(
castor
::
exception
::
Exception
&
ex
)
{
params
.
push_back
(
log
::
Param
(
"message"
,
ex
.
getMessage
()));
m_log
(
LOG_ERR
,
"Failed to kill data-transfer session"
,
params
);
}
}
return
true
;
// Continue the main event loop
}
//------------------------------------------------------------------------------
// idempotentKill
//------------------------------------------------------------------------------
void
castor
::
tape
::
tapeserver
::
daemon
::
CatalogueTransferSession
::
idempotentKill
(
const
pid_t
pid
,
const
int
signal
)
{
// Try to kill the process
const
int
killRc
=
kill
(
m_pid
,
signal
);
// If the kill failed for a reason other than the fact the process was already
// dead
if
(
killRc
&&
ESRCH
!=
errno
)
{
const
std
::
string
errnoStr
=
castor
::
utils
::
errnoToString
(
errno
);
castor
::
exception
::
Exception
ex
;
ex
.
getMessage
()
<<
"Failed to kill process"
": pid="
<<
pid
<<
" signal="
<<
signal
<<
": "
<<
errnoStr
;
throw
ex
;
}
}
//------------------------------------------------------------------------------
// handleTickWhilstWaitMounted
//------------------------------------------------------------------------------
...
...
@@ -173,12 +192,12 @@ bool castor::tape::tapeserver::daemon::CatalogueTransferSession::
"Killing data-transfer session because tape mount is taking too long"
,
params
);
if
(
kill
(
m_pid
,
SIGKILL
))
{
const
std
::
string
errnoStr
=
castor
::
utils
::
errnoToString
(
errno
);
params
.
push_back
(
log
::
Param
(
"message"
,
errnoStr
));
m_log
(
LOG_ERR
,
"Failed to kill data-transfer session"
,
params
);
}
else
{
try
{
idempotentKill
(
m_pid
,
SIGKILL
);
m_state
=
WAIT_TIMEOUT_KILL
;
}
catch
(
castor
::
exception
::
Exception
&
ex
)
{
params
.
push_back
(
log
::
Param
(
"message"
,
ex
.
getMessage
()));
m_log
(
LOG_ERR
,
"Failed to kill data-transfer session"
,
params
);
}
}
...
...
@@ -204,12 +223,12 @@ bool castor::tape::tapeserver::daemon::CatalogueTransferSession::
"Killing data-transfer session because data blocks are not being moved"
,
params
);
if
(
kill
(
m_pid
,
SIGKILL
))
{
const
std
::
string
errnoStr
=
castor
::
utils
::
errnoToString
(
errno
);
params
.
push_back
(
log
::
Param
(
"message"
,
errnoStr
));
m_log
(
LOG_ERR
,
"Failed to kill data-transfer session"
,
params
);
}
else
{
try
{
idempotentKill
(
m_pid
,
SIGKILL
);
m_state
=
WAIT_TIMEOUT_KILL
;
}
catch
(
castor
::
exception
::
Exception
&
ex
)
{
params
.
push_back
(
log
::
Param
(
"message"
,
ex
.
getMessage
()));
m_log
(
LOG_ERR
,
"Failed to kill data-transfer session"
,
params
);
}
}
...
...
This diff is collapsed.
Click to expand it.
castor/tape/tapeserver/daemon/CatalogueTransferSession.hpp
+
9
−
0
View file @
f0b9543d
...
...
@@ -381,6 +381,15 @@ private:
*/
bool
handleTickWhilstWaitJob
();
/**
* Tries to kill the specified process using the specified signal. This
* method calls the system call kill() but differs in its overall
* functionality in that it is idempotent. If the underlying kill() fails due
* to the fact the process is already dead (errno = ESRCH), then this method
* return successfully.
*/
void
idempotentKill
(
const
pid_t
pid
,
const
int
signal
);
/**
* Handles a tick in time whilst in the TRANSFERSTATE_WAIT_MOUNTED state. Time
* driven actions such as alarms should be implemented here.
...
...
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