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
8c455b3a
Commit
8c455b3a
authored
May 24, 2012
by
Mukund Sivaraman
Browse files
[1704] Add a select() to the parent reader in case the child messes up
parent
31b153df
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lib/util/tests/interprocess_sync_file_unittest.cc
View file @
8c455b3a
...
...
@@ -57,8 +57,22 @@ TEST(InterprocessSyncFileTest, TestLock) {
// Parent reads from pipe
close
(
fds
[
1
]);
// Read status
read
(
fds
[
0
],
&
locked
,
sizeof
(
locked
));
fd_set
rfds
;
FD_ZERO
(
&
rfds
);
FD_SET
(
fds
[
0
],
&
rfds
);
struct
timeval
tv
;
tv
.
tv_sec
=
5
;
tv
.
tv_usec
=
0
;
int
nfds
=
select
(
fds
[
0
]
+
1
,
&
rfds
,
NULL
,
NULL
,
&
tv
);
EXPECT_EQ
(
1
,
nfds
);
if
(
nfds
==
1
)
{
// Read status
read
(
fds
[
0
],
&
locked
,
sizeof
(
locked
));
}
close
(
fds
[
0
]);
EXPECT_EQ
(
1
,
locked
);
...
...
@@ -111,8 +125,22 @@ TEST(InterprocessSyncFileTest, TestMultipleFilesForked) {
// Parent reads from pipe
close
(
fds
[
1
]);
// Read status
read
(
fds
[
0
],
&
locked
,
sizeof
(
locked
));
fd_set
rfds
;
FD_ZERO
(
&
rfds
);
FD_SET
(
fds
[
0
],
&
rfds
);
struct
timeval
tv
;
tv
.
tv_sec
=
5
;
tv
.
tv_usec
=
0
;
int
nfds
=
select
(
fds
[
0
]
+
1
,
&
rfds
,
NULL
,
NULL
,
&
tv
);
EXPECT_EQ
(
1
,
nfds
);
if
(
nfds
==
1
)
{
// Read status
read
(
fds
[
0
],
&
locked
,
sizeof
(
locked
));
}
close
(
fds
[
0
]);
EXPECT_EQ
(
0
,
locked
);
...
...
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