Reviewing merge request #5: Fix a deadlock.

From the commit message:

commit 1eb7c3df2f0bce3f842e121586fe350c941a937d
Author: Benjamin Berg <benjamin@sipsolutions.net>
Date: Tue Jul 5 16:00:43 2011 +0200

Do not keep the pending_queue locked while dispatching an item.

This fixes a possible deadlock. The case where this can happen is:
1. Application recieves a method call/signal
2. Method call/Signal is dispatched
3. From the dispatch handler, a method call is done
4. Another message came in in the meantime, which needs to be queued

In step for the queue is still locked by the dispatcher, and a deadlock
occurs. The fix is to release the queue.

The patch will only iterate over all messages once, to give the application
a chance to work on other things if a lot of messages are comming in.

Commits that would be merged:

Version 4
  • Version 1
  • Version 2
  • Version 3
  • Version 4
  • 1f6f3e6
  • 9ac62dc
  • Do not keep the pending_queue locked while dispatching an item.

Showing 1f6f3e6-9ac62dc

Comments

Pushed new version 1

Pushed new version 2

→ State changed from Open to Rejected

please reopen with new patch if problem still exists. To many differences meanwhile

The patch still applies cleanly.

Do you mean I am supposed to check whether this bug has been fixed in some other way?

Pushed new version 3

→ State changed from Rejected to Open

I just “updated” the request and since then it is displayed correctly again.
It would be nice to get this in, Google Chrome for example has workarounds for exactly this issue.

I added a remote branch with your merged changes:

https://gitorious.org/dbus-cplusplus/mainline/trees/merge-requests/5

But if I run my “Test1/TestApp” functional test I get a “NOK” for async calls. So I couldn’t put this into mainline without further discussion.

The test describes one of my async use cases. Please look into the test and explain why you think my test is not correct or why your code fixes another problem.

Hm, what seems to happen is that the sleep in the mainloop is executed. ie. the message sneaks in between the test whether the queue is empty and the sleep in the mainloop.

If you increase the timeout in the test, then it starts working.

ie. see:
// Only check for events, if there is nothing in the queue.
// XXX: It would be better to just prevent the poll from sleeping
// in this case.

Not sure how to correctly fix this right now. We somehow need to prevent the mainloop from sleeping if a new message has arrived in the meantime.

Pushed new version 4

OK. New version. The trouble was, that there was already a fix for the problem pushed earlier (see comment). However, I think my fix is better, as it does not copy the pending queue, but instead realeases the lock when possible.

Add a new comment:

Login or create an account to post a comment

How to apply this merge request to your repository