Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
17e4e76a
Commit
17e4e76a
authored
Feb 05, 2015
by
Marcin Siodelski
Browse files
[3669] Added some more commentary in various places.
parent
aa7dc61e
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/lib/dhcpsrv/memfile_lease_mgr.cc
View file @
17e4e76a
...
...
@@ -809,9 +809,9 @@ void Memfile_LeaseMgr::lfcExecute(boost::shared_ptr<LeaseFileType>& lease_file)
// This string will hold a reason for the failure to rote the lease files.
std
::
string
error_string
=
"(no details)"
;
// Check if the copy of the lease file exists already. If it does, it
// is an indication that another LFC instance may be in progress
, in
//
which
case we don't want to rotate the current
lease file to avoid
// overriding the contents of the existing file.
// is an indication that another LFC instance may be in progress
or
//
may be stalled. In that
case we don't want to rotate the current
//
lease file to avoid
overriding the contents of the existing file.
CSVFile
lease_file_copy
(
appendSuffix
(
lease_file
->
getFilename
(),
FILE_INPUT
));
if
(
!
lease_file_copy
.
exists
())
{
// Close the current file so as we can move it to the copy file.
...
...
@@ -849,8 +849,8 @@ void Memfile_LeaseMgr::lfcExecute(boost::shared_ptr<LeaseFileType>& lease_file)
error_string
=
ex
.
what
();
}
}
// Once
we have rotated files as needed, start the new kea-lfc process
//
to perform a cleanup
.
// Once
the files have been rotated, or untouched if another LFC had
//
not finished, a new process is started
.
if
(
do_lfc
)
{
lfc_setup_
->
execute
();
...
...
src/lib/dhcpsrv/memfile_lease_mgr.h
View file @
17e4e76a
...
...
@@ -339,12 +339,12 @@ public:
/// This enumeration is used by a method which appends the appropriate
/// suffix to the lease file name.
enum
LFCFileType
{
FILE_CURRENT
,
FILE_INPUT
,
FILE_PREVIOUS
,
FILE_OUTPUT
,
FILE_FINISH
,
FILE_PID
FILE_CURRENT
,
///< %Lease File
FILE_INPUT
,
///< %Lease File Copy
FILE_PREVIOUS
,
///< Previous %Lease File
FILE_OUTPUT
,
///< LFC Output File
FILE_FINISH
,
///< LFC Finish File
FILE_PID
///< PID File
};
/// @brief Appends appropriate suffix to the file name.
...
...
src/lib/dhcpsrv/tests/lease_file_io.h
View file @
17e4e76a
// Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2014
-2015
Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
...
...
src/lib/util/process_spawn.cc
View file @
17e4e76a
...
...
@@ -48,11 +48,11 @@ public:
/// @brief Spawn the new process.
///
/// This method forks the current process and execues the specified
/// This method forks the current process and execu
t
es the specified
/// binary with arguments within the child process.
///
/// The child process will return EXIT_FAILURE if the method was unable
/// to start the exu
c
table, e.g. as a result of insufficient permissions
/// to start the ex
ec
utable, e.g. as a result of insufficient permissions
/// or when the executable does not exist. If the process ends successfully
/// the EXIT_SUCCESS is returned.
///
...
...
@@ -131,7 +131,7 @@ ProcessSpawnImpl::ProcessSpawnImpl(const std::string& executable,
const
ProcessArgs
&
args
)
:
signals_
(
new
SignalSet
(
SIGCHLD
)),
process_status_
(),
executable_
(
executable
),
args_
(
new
char
*
[
args
.
size
()
+
2
])
{
// Set the handler which is invoked immediatel
l
y when the signal
// Set the handler which is invoked immediately when the signal
// is received.
signals_
->
setOnReceiptHandler
(
boost
::
bind
(
&
ProcessSpawnImpl
::
waitForProcess
,
this
,
_1
));
...
...
@@ -199,7 +199,7 @@ bool
ProcessSpawnImpl
::
isRunning
(
const
pid_t
pid
)
const
{
if
(
process_status_
.
find
(
pid
)
==
process_status_
.
end
())
{
isc_throw
(
BadValue
,
"the process with the pid '"
<<
pid
<<
"' hasn't been spawned and it status cann
n
ot be"
<<
"' hasn't been spawned and it status cannot be"
" returned"
);
}
return
((
pid
!=
0
)
&&
(
kill
(
pid
,
0
)
==
0
));
...
...
src/lib/util/tests/process_spawn_app.sh
View file @
17e4e76a
...
...
@@ -14,6 +14,24 @@
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
# This script is used for testing the ProcessSpawn utility class. This
# class is used to fork and execute a new process. It also allows for
# checking the exit code returned when the process terminates.
# The unit tests execute this script via ProcessSpawn class with
# different command line parameters to test the class functionality.
#
# In particular, they check if the class correctly records the exit code
# returned. The exit code returned is controlled by the caller. It is
# possible to explictily specify the exit code to be returned using
# the command line options. It is also possible to specify that the
# exit code is "unique" for the process, so as the test can check
# that two distinct processes spawned by the same ProcessSpawn
# object may return different status code. The command line of this
# script also allows for forcing the process to sleep so as the
# test has much enough time to verify that the convenience methods
# checking the state of the process, i.e. process running or not.
exit_code
=
while
[
!
-z
"
${
1
}
"
]
...
...
@@ -29,6 +47,10 @@ do
shift
exit_code
=
${
1
}
;;
-s
)
shift
sleep
${
1
}
;;
*
)
exit
123
;;
...
...
@@ -36,6 +58,8 @@ do
shift
done
# The exit code of 32 is returned when no args specified or
# when only the -s arg has been specified.
if
[
-z
"
${
exit_code
}
"
]
;
then
exit
32
;
fi
...
...
src/lib/util/tests/process_spawn_unittest.cc
View file @
17e4e76a
...
...
@@ -150,4 +150,23 @@ TEST(ProcessSpawn, getCommandLine) {
}
}
// This test verifies that it is possible to check if the process is
// running.
TEST
(
ProcessSpawn
,
isRunning
)
{
// Run the process which sleeps for 10 seconds, so as we have
// enough time to check if it is running.
std
::
vector
<
std
::
string
>
args
;
args
.
push_back
(
"-s"
);
args
.
push_back
(
"10"
);
ProcessSpawn
process
(
getApp
(),
args
);
pid_t
pid
=
0
;
ASSERT_NO_THROW
(
pid
=
process
.
spawn
());
EXPECT_TRUE
(
process
.
isRunning
(
pid
));
// Kill the process.
ASSERT_EQ
(
0
,
kill
(
pid
,
SIGKILL
));
// And make sure if died.
ASSERT_TRUE
(
waitForProcess
(
process
,
pid
,
2
));
}
}
// end of anonymous namespace
Write
Preview
Supports
Markdown
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