Skip to content
GitLab
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
10b434be
Commit
10b434be
authored
May 24, 2012
by
Mukund Sivaraman
Browse files
[1704] Minimize code
parent
db2fa0cd
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/util/interprocess_sync_file.cc
View file @
10b434be
...
...
@@ -78,7 +78,7 @@ do_lock(int fd, int cmd, short l_type)
const
int
status
=
fcntl
(
fd
,
cmd
,
&
lock
);
return
(
(
status
==
0
)
?
true
:
false
)
;
return
(
status
==
0
);
}
bool
...
...
src/lib/util/tests/interprocess_sync_file_unittest.cc
View file @
10b434be
...
...
@@ -40,8 +40,6 @@ TEST_F(InterprocessSyncFileTest, TestLock) {
// done from the same process for the granted range. The lock
// attempt must fail to pass our check.
bool
was_locked
(
false
);
pipe
(
fds
);
if
(
fork
()
==
0
)
{
...
...
@@ -64,18 +62,13 @@ TEST_F(InterprocessSyncFileTest, TestLock) {
// Parent reads from pipe
close
(
fds
[
1
]);
// Read status
and set flag
// Read status
read
(
fds
[
0
],
&
locked
,
sizeof
(
locked
));
if
(
locked
==
1
)
{
was_locked
=
true
;
}
else
{
was_locked
=
false
;
}
close
(
fds
[
0
]);
EXPECT_EQ
(
1
,
locked
);
}
EXPECT_TRUE
(
was_locked
);
EXPECT_TRUE
(
locker
.
unlock
());
}
...
...
@@ -101,8 +94,6 @@ TEST_F(InterprocessSyncFileTest, TestMultipleFilesForked) {
int
fds
[
2
];
bool
was_not_locked
(
true
);
pipe
(
fds
);
if
(
fork
()
==
0
)
{
...
...
@@ -125,18 +116,13 @@ TEST_F(InterprocessSyncFileTest, TestMultipleFilesForked) {
// Parent reads from pipe
close
(
fds
[
1
]);
// Read status
and set flag
// Read status
read
(
fds
[
0
],
&
locked
,
sizeof
(
locked
));
if
(
locked
==
0
)
{
was_not_locked
=
true
;
}
else
{
was_not_locked
=
false
;
}
close
(
fds
[
0
]);
EXPECT_EQ
(
0
,
locked
);
}
EXPECT_TRUE
(
was_not_locked
);
EXPECT_TRUE
(
locker
.
unlock
());
}
...
...
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