~alan-griffiths/mir/fix-1332011

« back to all changes in this revision

Viewing changes to src/client/mir_wait_handle.cpp

  • Committer: Tarmac
  • Author(s): Alan Griffiths
  • Date: 2014-06-16 11:16:52 UTC
  • mfrom: (1691.1.3 mir5)
  • Revision ID: tarmac-20140616111652-ewiiv9x93rv2z34i
client: MirWaitHandle was being abused to wait for results without setting corresponding expectations of results.

Approved by Alexandros Frantzis, Kevin DuBois, Cemil Azizoglu, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
{
51
51
    std::unique_lock<std::mutex> lock(guard);
52
52
 
53
 
    // TODO this condition ought to be "received == expecting" but some
54
 
    // TODO client code seems to not call expect_result() and tests break.
55
 
    wait_condition.wait(lock,
56
 
        [&]{ return (expecting || received) && (received >= expecting); });
 
53
    wait_condition.wait(lock, [&]{ return received == expecting; });
57
54
 
58
55
    received = 0;
59
56
    expecting = 0;
73
70
 
74
71
    wait_condition.wait(lock, [&]{ return received != 0; });
75
72
 
76
 
    received--;
77
 
    if (expecting > 0)
78
 
        expecting--;
 
73
    --received;
 
74
    --expecting;
79
75
}
80
76