You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cancelling an event that is not currently queued will return error 335545021 ("invalid events id (handle)"). This is a deviation from the behavior in Firebird 2.5.4 and earlier which allows this.
Sample code that reproduces this (Jaybird 3/JNA so it is close to the native API):
/******************/
JnaDatabase db = factory.connect(connectionInfo);
db.attach();
FbClientLibrary lib = db.getClientLibrary();
ISC_STATUS[] statusVector = new ISC_STATUS[20];
SimpleEventHandler eventHandler = new SimpleEventHandler();
final JnaEventHandle eventHandle = new JnaEventHandle("TEST_EVENT_A", eventHandler, db.getEncoding());
int size = lib.isc_event_block(eventHandle.getEventBuffer(), eventHandle.getResultBuffer(), (short) 1, eventHandle.getEventNameMemory());
eventHandle.setSize(size);
// Queue event
lib.isc_que_events(statusVector, db.getJnaHandle(), eventHandle.getJnaEventId(), (short) eventHandle.getSize(), eventHandle.getEventBuffer().getValue(), eventHandle.getCallback(), eventHandle.getResultBuffer().getValue());
System.out.printf("Status: %s %s%n", statusVector[0], statusVector[1]);
// Event will notify almost immediately for initial setup.
Thread.sleep(50);
// Cancel (no event queued right now)
lib.isc_cancel_events(statusVector, db.getJnaHandle(), eventHandle.getJnaEventId());
System.out.printf("Status: %s %s%n", statusVector[0], statusVector[1]);
/******************/
With the 2.5.4 fbclient.dll this prints:
Status: 1 0
Status: 1 0
With 3.0.0.31839:
Status: 1 0
Status: 1 335545021
The asynchronous nature of events makes it hard to guarantee that an event is still queued when you cancel it. As such cancelling a no longer queued event should not be considered an error (at most it should be a warning). This is also what 2.5.4 does (interface.cpp, GDS_CANCEL_EVENTS):
// If the event exists, tell the remote server to cancel it,
// and delete it from the list
Rvnt\* event = find\_event\(port, \*id\);
if \(event\) \{
send\_cancel\_event\(event\);
\}
It was rather suspicious solution to silently ignore wrong ID in isc_cancel_events(). One can pass hell knows what (starting with not initialized variable) as event id into cancelation routine and be happy that he does not que for some events any more. Letting user ignore error when due to async nature of events event already happened and should not be canceled seems to be slightly better choice, but let's be backward compatible with ISC API.
Submitted by: @mrotteveel
Is related to CORE4756
Related to CORE4756:
Cancelling an event that is not currently queued will return error 335545021 ("invalid events id (handle)"). This is a deviation from the behavior in Firebird 2.5.4 and earlier which allows this.
Sample code that reproduces this (Jaybird 3/JNA so it is close to the native API):
/******************/
JnaDatabase db = factory.connect(connectionInfo);
db.attach();
FbClientLibrary lib = db.getClientLibrary();
ISC_STATUS[] statusVector = new ISC_STATUS[20];
SimpleEventHandler eventHandler = new SimpleEventHandler();
final JnaEventHandle eventHandle = new JnaEventHandle("TEST_EVENT_A", eventHandler, db.getEncoding());
int size = lib.isc_event_block(eventHandle.getEventBuffer(), eventHandle.getResultBuffer(), (short) 1, eventHandle.getEventNameMemory());
eventHandle.setSize(size);
// Queue event
lib.isc_que_events(statusVector, db.getJnaHandle(), eventHandle.getJnaEventId(), (short) eventHandle.getSize(), eventHandle.getEventBuffer().getValue(), eventHandle.getCallback(), eventHandle.getResultBuffer().getValue());
System.out.printf("Status: %s %s%n", statusVector[0], statusVector[1]);
// Event will notify almost immediately for initial setup.
Thread.sleep(50);
// Cancel (no event queued right now)
lib.isc_cancel_events(statusVector, db.getJnaHandle(), eventHandle.getJnaEventId());
System.out.printf("Status: %s %s%n", statusVector[0], statusVector[1]);
/******************/
With the 2.5.4 fbclient.dll this prints:
Status: 1 0
Status: 1 0
With 3.0.0.31839:
Status: 1 0
Status: 1 335545021
The asynchronous nature of events makes it hard to guarantee that an event is still queued when you cancel it. As such cancelling a no longer queued event should not be considered an error (at most it should be a warning). This is also what 2.5.4 does (interface.cpp, GDS_CANCEL_EVENTS):
Commits: 867ef82 FirebirdSQL/fbt-repository@bcbea3f
The text was updated successfully, but these errors were encountered: