-
Notifications
You must be signed in to change notification settings - Fork 164
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
Rework SQLCancel logistics to avoid possible races. #567
base: master
Are you sure you want to change the base?
Conversation
This smells like potential dead lock to me. In theory in Unix SQLCancel can be called inside a signal handler. |
Good point. In that case, I suppose the way to go would be to set some flag on the DBC itself and check it reasonably often from other functions (perhaps by extending the macros around entry and exit); pretty much anything beyond that (even a |
* Split most of its logic into a new _SQLCancel; have SQLCancel itself merely set a flag indicating that an _SQLCancel call is in order. * Automatically check that flag from ODBC_EXIT(_), ODBC_RETURN(_), and a new odbc_int_handler (which _SQLAllocEnv registers), by way of a new ODBC_CHECK_CANCEL macro. * Check for cancellation on function entry too, bailing only when potentially seeking more results from a freshly canceled query; to that end, introduce ODBC_ENTER_HSTMT_OR_BAIL (and a helper ODBC_ENTER_HSTMT_EX). * In _SQLCancel, rely on having the statement's mutex held and add HY008 (Operation was cancelled) after clearing other errors. Signed-off-by: Aaron M. Ucko <[email protected]>
3d6f5f7
to
f580b2a
Compare
I've substituted a rework along those lines that crucially also throws in an interrupt handler, and retitled this PR accordingly; the long commit description is
|
This last change looks overkilling. It reminds me of the hero movies in the 80-ish when the hero tried to pull out a bullet using a knife bigger than my forearm and trying not to hurt himself. |
I hear you, and had initially looked into finding ways to make immediate cancellation safe. Alas, there are severe limits on what code potentially called from a signal handler can safely do. ISO is of course particularly strict; Windows is marginally better but still notably forbids any I/O. POSIX is more reasonable, but forbids any mutex operations, even Incidentally, I see from reviewing that documentation that the flag should have type |
Some working on cancellation, adding new tests... and finding new bugs! |
Split from #555.