8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 03:23:04 +01:00

Fixed CORE-4794: isc_cancel_events returns error invalid events id (handle) (code: 335545021) if event is (no longer) queued

This commit is contained in:
alexpeshkoff 2015-05-18 16:01:52 +00:00
parent eb53fc3b1f
commit 867ef82872

View File

@ -1718,8 +1718,21 @@ ISC_STATUS API_ROUTINE isc_cancel_events(ISC_STATUS* userStatus, FB_API_HANDLE*
try try
{ {
RefPtr<YAttachment> attachment(translateHandle(attachments, handle)); RefPtr<YAttachment> attachment(translateHandle(attachments, handle));
// This cast appears awful, but as long as handles are 32-bit entities it's OK. RefPtr<YEvents> event;
RefPtr<YEvents> event(translateHandle(events, (FB_API_HANDLE*) id)); try
{
// This cast appears awful, but as long as handles are 32-bit entities it's OK.
event = translateHandle(events, (FB_API_HANDLE*) id);
}
catch(const Firebird::status_exception& ex)
{
if (ex.value()[1] == isc_bad_events_handle)
{
// Ignore invalid handle/ID in cancelation call for backward compatibility
return status[1];
}
throw;
}
if (event->attachment != attachment) if (event->attachment != attachment)
Arg::Gds(isc_bad_events_handle).raise(); Arg::Gds(isc_bad_events_handle).raise();
@ -2823,8 +2836,6 @@ ISC_STATUS API_ROUTINE isc_wait_for_event(ISC_STATUS* userStatus, FB_API_HANDLE*
{ {
RefPtr<YAttachment> attachment(translateHandle(attachments, dbHandle)); RefPtr<YAttachment> attachment(translateHandle(attachments, dbHandle));
///nullCheck(id, isc_bad_events_handle);
events = attachment->queEvents(&statusWrapper, callback, length, eventsData); events = attachment->queEvents(&statusWrapper, callback, length, eventsData);
if (status.getState() & Firebird::IStatus::STATE_ERRORS) if (status.getState() & Firebird::IStatus::STATE_ERRORS)
@ -2916,8 +2927,6 @@ ISC_STATUS API_ROUTINE isc_que_events(ISC_STATUS* userStatus, FB_API_HANDLE* dbH
{ {
RefPtr<YAttachment> attachment(translateHandle(attachments, dbHandle)); RefPtr<YAttachment> attachment(translateHandle(attachments, dbHandle));
///nullCheck(idFB_FINAL , isc_bad_events_handle);
RefPtr<QueCallback> callback(new QueCallback(ast, arg)); RefPtr<QueCallback> callback(new QueCallback(ast, arg));
events = attachment->queEvents(&statusWrapper, callback, length, eventsData); events = attachment->queEvents(&statusWrapper, callback, length, eventsData);
callback->setEvents(events); // should be called in case of NULL events too callback->setEvents(events); // should be called in case of NULL events too