Mir

Merge lp:~albaguirre/mir/cross-process-sync-retry-poll into lp:mir

Proposed by Alberto Aguirre
Status: Merged
Approved by: Alberto Aguirre
Approved revision: no longer in the source branch.
Merged at revision: 3156
Proposed branch: lp:~albaguirre/mir/cross-process-sync-retry-poll
Merge into: lp:mir
Diff against target: 66 lines (+30/-19)
1 file modified
tests/mir_test/cross_process_sync.cpp (+30/-19)
To merge this branch: bzr merge lp:~albaguirre/mir/cross-process-sync-retry-poll
Reviewer Review Type Date Requested Status
Alan Griffiths Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+279057@code.launchpad.net

Commit message

tests: CrossProcessSync: retry poll after EINTR

Description of the change

tests: CrossProcessSync: retry poll after EINTR

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/mir_test/cross_process_sync.cpp'
2--- tests/mir_test/cross_process_sync.cpp 2015-06-25 03:00:08 +0000
3+++ tests/mir_test/cross_process_sync.cpp 2015-12-01 00:04:05 +0000
4@@ -79,15 +79,20 @@
5 pollfd poll_fd[1] = { { fds[write_fd], POLLOUT, empty_revents } };
6 int rc = -1;
7
8- if ((rc = ::poll(poll_fd, 1, duration.count())) < 0)
9- {
10- BOOST_THROW_EXCEPTION(std::system_error(errno,
11- std::system_category(),
12- "Error while polling pipe to become writable"));
13- }
14- else if (rc == 0)
15- {
16- throw std::runtime_error("Poll on writefd for pipe timed out");
17+ while ((rc = ::poll(poll_fd, 1, duration.count())) <= 0)
18+ {
19+ if (errno == EINTR)
20+ {
21+ continue;
22+ }
23+ if (rc == 0)
24+ {
25+ BOOST_THROW_EXCEPTION(std::runtime_error("Poll on writefd for pipe timed out"));
26+ }
27+ else
28+ {
29+ BOOST_THROW_EXCEPTION(std::system_error(errno, std::system_category(), "Error while polling pipe to become writable"));
30+ }
31 }
32
33 int value = 1;
34@@ -110,16 +115,22 @@
35 pollfd poll_fd[1] = { { fds[read_fd], POLLIN, empty_revents } };
36 int rc = -1;
37
38- if ((rc = ::poll(poll_fd, 1, duration.count())) < 0)
39- {
40- BOOST_THROW_EXCEPTION(std::system_error(errno,
41- std::system_category(),
42- "Error while polling pipe to become readable"));
43- }
44- else if (rc == 0)
45- {
46- BOOST_THROW_EXCEPTION(std::runtime_error("Poll on readfd for pipe timed out"));
47- }
48+ while ((rc = ::poll(poll_fd, 1, duration.count())) <= 0)
49+ {
50+ if (errno == EINTR)
51+ {
52+ continue;
53+ }
54+ if (rc == 0)
55+ {
56+ BOOST_THROW_EXCEPTION(std::runtime_error("Poll on readfd for pipe timed out"));
57+ }
58+ else
59+ {
60+ BOOST_THROW_EXCEPTION(std::system_error(errno, std::system_category(), "Error while polling pipe to become readable"));
61+ }
62+ }
63+
64
65 int value;
66 if (sizeof(value) != read(fds[read_fd], std::addressof(value), sizeof(value)))

Subscribers

People subscribed via source and target branches