[PATCH] Fix for database locking crashes (was Re:
bogofilter/bogoutil concurrency crash?)
relson at osagesoftware.com
Mon Apr 7 08:30:26 EDT 2003
At 12:30 AM 4/7/03, Jim Correia wrote:
>On Monday, April 7, 2003, at 01:12 AM, David Relson wrote:
>>The sequence "db_close(handle,??); handle = NULL; goto open_err" is
>>inefficient. open_err: calls dbh_free(handle) and returns NULL. As you
>>point out, the call to dbh_free() is not needed because db_close() has
>>already called dbh_free(). The code after the call to db_close() should
>>be "return NULL" (which is simpler).
>Fair enough. (In my own code I usually have centralized cleanup and a
>single return at the bottom of the function. In this case I was trying to
>adhere to the existing code style, but I can see how yours is a better fit.)
>>Also, you added a "goto open_error". That exits the "waiting for the
>>lock" loop, which is _not_ what we want.
>Thanks for catching this. (In my editor indent and tab are both set at 4
>so the entire for block was flush with the brace, and my bug was masked by
>the caller also looping on the lock failure.)
>>The attached patch has the critical "handle = NULL" and added test for
>>handle != NULL before using it. Give it a try and let me know how well
>>it works (compared to your patch).
>make check still passes and the bug is likewise corrected.
Glad to get the positive report. The code changes have been committed to
CVS and a new bogofilter will be built today and put on SourceForge.
More information about the Bogofilter-dev