Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fbclient executes callback function twice on two different threads [CORE4795] #5093

Closed
firebird-automations opened this issue May 16, 2015 · 9 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @mrotteveel

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]

Commits: 9bf96dd FirebirdSQL/fbt-repository@4abff04

@firebird-automations
Copy link
Collaborator Author

Commented by: @mrotteveel

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]

@firebird-automations
Copy link
Collaborator Author

Commented by: @mrotteveel

Ignore my comment I previously posted here. I am still investigating the exact cause of the access violation.

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

assignee: Alexander Peshkov [ alexpeshkoff ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @AlexPeshkoff

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.

@firebird-automations
Copy link
Collaborator Author

Commented by: @mrotteveel

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.

@firebird-automations
Copy link
Collaborator Author

Commented by: @AlexPeshkoff

Mark can I resolve this issue?

@firebird-automations
Copy link
Collaborator Author

Commented by: @mrotteveel

Yes, this problem no longer occurs.

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 3.0 Beta 2 [ 10586 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants