Bug 57900 - GDBM backend: error returned on fetch and delete for non-existing key
Summary: GDBM backend: error returned on fetch and delete for non-existing key
Status: NEW
Alias: None
Product: APR
Classification: Unclassified
Component: APR-util (show other bugs)
Version: 1.5.2
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache Portable Runtime bugs mailinglist
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-07 16:09 UTC by Diego Santa Cruz
Modified: 2015-05-07 16:09 UTC (History)
0 users



Attachments
Patch to fix the key not found issue with GDBM (568 bytes, text/plain)
2015-05-07 16:09 UTC, Diego Santa Cruz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Diego Santa Cruz 2015-05-07 16:09:17 UTC
Created attachment 32722 [details]
Patch to fix the key not found issue with GDBM

The GDBM backend returns an error on apr_dbm_fetch() and apr_dbm_delete() when the key does not exist.

This is different from the DB, SDBM and NDBM backends which return no error when the key does not exist.

A consequence of this is that code which checks the error code on these calls starts to fail when apr-util is built with GDBM (but not Berkeley), like httpd's dav_fs locking (see bug #42977).

The GDBM documentation states that gdbm_errno is set to GDBM_ITEM_NOT_FOUND for fetch and delete when the key is not found, but set_error() in apr_dbm_gdbm.c does not special case this.

I experienced this with apr-util 1.5.2 but the code has not changed in the 1.5.x branch (just checked) nor in apr's trunk.

I attach a patch which fixes the problem (tested with mod_dav_fs in Apache httpd 2.4.6).