Issue Details (XML | Word | Printable)

Key: CORE-4795
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Alexander Peshkov
Reporter: Mark Rotteveel
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Firebird Core

fbclient executes callback function twice on two different threads

Created: 16/May/15 12:28 PM   Updated: 23/Sep/15 11:34 AM
Component/s: API / Client Library
Affects Version/s: 3.0 Beta 2
Fix Version/s: 3.0 Beta 2

Environment: Windows 8.1 64 bit, Firebird 3.0.0.31839_x64 fbclient.dll against Firebird 3.0.0.31839_x64 server


 Description  « Hide
The firebird 3.0.0.31839 fbclient invokes the callback function twice for each triggered event and for cancellation. For example the Jaybird TestFBEventManager.testWaitForEventWithOccurrence() shows the following (when code is added to show the thread identity):

Queue invoked from Thread: Thread[Thread-2,5,main]
Callback invoked from Thread: Thread[Thread-3,5,main]
Queue invoked from Thread: Thread[Thread-3,5,main]
Callback invoked from Thread: Thread[Thread-4,5,main]
Callback invoked from Thread: Thread[Thread-5,5,main]
Queue invoked from Thread: Thread[Thread-5,5,main]
Cancel invoked from Thread: Thread[Thread-2,5,main]
Callback invoked from Thread: Thread[Thread-6,5,main]
Callback invoked from Thread: Thread[Thread-2,5,main]

As you can see the initial queue gets one callback (as expected), but the second queue receives two callbacks, and the cancel also receives two callbacks.

The same code with the 2.5.4 fbclient shows:

Queue invoked from Thread: Thread[Thread-2,5,main]
Callback invoked from Thread: Thread[Thread-3,5,main]
Queue invoked from Thread: Thread[Thread-3,5,main]
Callback invoked from Thread: Thread[Thread-4,5,main]
Queue invoked from Thread: Thread[Thread-4,5,main]
Cancel invoked from Thread: Thread[Thread-2,5,main]
Callback invoked from Thread: Thread[Thread-2,5,main]


 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Mark Rotteveel added a comment - 16/May/15 01:42 PM
If I add the eventId and length argument of the callback:

Queue invoked from Thread: Thread[Thread-2,5,main]
Callback invoked for id 1 with length 18 from Thread: Thread[Thread-3,5,main]
Queue invoked from Thread: Thread[Thread-3,5,main]
Callback invoked for id 2 with length 0 from Thread: Thread[Thread-4,5,main]
Callback invoked for id 2 with length 18 from Thread: Thread[Thread-5,5,main]
Queue invoked from Thread: Thread[Thread-5,5,main]
Cancel invoked from Thread: Thread[Thread-2,5,main]
Callback invoked for id 3 with length 0 from Thread: Thread[Thread-6,5,main]
Callback invoked for id 3 with length 0 from Thread: Thread[Thread-2,5,main]

Mark Rotteveel added a comment - 16/May/15 02:32 PM - edited
Ignore my comment I previously posted here. I am still investigating the exact cause of the access violation.

Alexander Peshkov added a comment - 18/May/15 04:54 PM
Mark I've reproduced extra callback when event is posted. Please try now. In C++ test I can't reproduce extra callbacks wheb canceling event.
BTW, if you write callback function according to what recommended in ib6.0 beta1 sample, that extra call does not cause problems.

Mark Rotteveel added a comment - 06/Jun/15 09:34 AM
In tests with Firebird-3.0.0.31855-0_x64 the spurious callbacks no longer occur. For Jaybird 2.2 the spurious callback was a real problem. The callback with length 0 was taken as a signal of event cancellation and to handle the cleanup of the event blocks.

Alexander Peshkov added a comment - 26/Jun/15 01:41 PM
Mark can I resolve this issue?

Mark Rotteveel added a comment - 26/Jun/15 01:48 PM
Yes, this problem no longer occurs.