You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by sf...@apache.org on 2018/02/25 16:43:14 UTC
svn commit: r1825313 - in /apr/apr-util/branches/1.7.x: ./ CHANGES
dbm/apr_dbm_gdbm.c
Author: sf
Date: Sun Feb 25 16:43:14 2018
New Revision: 1825313
URL: http://svn.apache.org/viewvc?rev=1825313&view=rev
Log:
Fix error handling in gdbm
Only check for gdbm_errno if the return value of the called gdbm_*
function says so. This fixes apr-util with gdbm 1.14, which does not
seem to always reset gdbm_errno.
Also make the gdbm driver return error codes starting with
APR_OS_START_USEERR instead of always returning APR_EGENERAL. This is
what the berkleydb driver already does.
Also ensure that dsize is 0 if dptr == NULL.
(backport of r1825311 in apr trunk)
Modified:
apr/apr-util/branches/1.7.x/ (props changed)
apr/apr-util/branches/1.7.x/CHANGES
apr/apr-util/branches/1.7.x/dbm/apr_dbm_gdbm.c
Propchange: apr/apr-util/branches/1.7.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 25 16:43:14 2018
@@ -1,4 +1,4 @@
-/apr/apr/trunk:781403,781409,784519,784592,789965,794508,917837-917838,982408-982409,998533,1086937,1127053,1127648,1128838,1129433,1133587,1207704,1210524,1211987,1214516,1308087,1308131,1308318,1327636,1340286,1346865,1357761,1357772,1357780,1357966,1357968,1357979,1358295,1358480,1361811,1362241,1362248,1362252,1362255,1363076,1369681,1370626,1371811,1371817,1371919,1371923,1382174,1389154,1389169,1390461,1390477,1402870,1402897,1402903,1402907,1406088,1422413,1425356,1426442,1426448,1438960,1449308,1449314,1460185,1460243-1460244,1462219,1462224,1484271,1493715,1495887,1495889,1496407,1516261,1523479,1529554,1531009,1541054,1543399,1544846,1618843,1619438,1625247,1626561,1648830,1711657,1722547,1728958,1728963,1747941,1751567,1751806,1751898,1752008,1763665,1763667,1763669,1763672-1763673,1763842-1763843,1765378,1772414,1778153,1781391,1782042,1782045,1788335,1789947,1809394,1811470,1820080
+/apr/apr/trunk:781403,781409,784519,784592,789965,794508,917837-917838,982408-982409,998533,1086937,1127053,1127648,1128838,1129433,1133587,1207704,1210524,1211987,1214516,1308087,1308131,1308318,1327636,1340286,1346865,1357761,1357772,1357780,1357966,1357968,1357979,1358295,1358480,1361811,1362241,1362248,1362252,1362255,1363076,1369681,1370626,1371811,1371817,1371919,1371923,1382174,1389154,1389169,1390461,1390477,1402870,1402897,1402903,1402907,1406088,1422413,1425356,1426442,1426448,1438960,1449308,1449314,1460185,1460243-1460244,1462219,1462224,1484271,1493715,1495887,1495889,1496407,1516261,1523479,1529554,1531009,1541054,1543399,1544846,1618843,1619438,1625247,1626561,1648830,1711657,1722547,1728958,1728963,1747941,1751567,1751806,1751898,1752008,1763665,1763667,1763669,1763672-1763673,1763842-1763843,1765378,1772414,1778153,1781391,1782042,1782045,1788335,1789947,1809394,1811470,1820080,1825311
/apr/apr-util/branches/1.3.x:896410,1154885
/apr/apr-util/branches/1.4.x:1126217,1211211,1211219,1211223,1211330
/apr/apr-util/branches/1.5.x:1757430
Modified: apr/apr-util/branches/1.7.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/CHANGES?rev=1825313&r1=1825312&r2=1825313&view=diff
==============================================================================
--- apr/apr-util/branches/1.7.x/CHANGES [utf-8] (original)
+++ apr/apr-util/branches/1.7.x/CHANGES [utf-8] Sun Feb 25 16:43:14 2018
@@ -1,7 +1,10 @@
-*- coding: utf-8 -*-
Changes with APR-util 1.6.2
-
+ *) apr_dbm_gdbm: Fix handling of error codes. This makes gdbm 1.14 work.
+ apr_dbm_gdbm will now also return error codes starting with
+ APR_OS_START_USEERR, as apr_dbm_berkleydb does, instead of always
+ returning APR_EGENERAL. [Stefan Fritsch]
Changes with APR-util 1.6.1
Modified: apr/apr-util/branches/1.7.x/dbm/apr_dbm_gdbm.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/dbm/apr_dbm_gdbm.c?rev=1825313&r1=1825312&r2=1825313&view=diff
==============================================================================
--- apr/apr-util/branches/1.7.x/dbm/apr_dbm_gdbm.c (original)
+++ apr/apr-util/branches/1.7.x/dbm/apr_dbm_gdbm.c Sun Feb 25 16:43:14 2018
@@ -36,8 +36,20 @@
static apr_status_t g2s(int gerr)
{
if (gerr == -1) {
- /* ### need to fix this */
- return APR_EGENERAL;
+ if (gdbm_errno == GDBM_NO_ERROR)
+ return APR_SUCCESS;
+ return APR_OS_START_USEERR + gdbm_errno;
+ }
+
+ return APR_SUCCESS;
+}
+
+static apr_status_t gdat2s(datum d)
+{
+ if (d.dptr == NULL) {
+ if (gdbm_errno == GDBM_NO_ERROR || gdbm_errno == GDBM_ITEM_NOT_FOUND)
+ return APR_SUCCESS;
+ return APR_OS_START_USEERR + gdbm_errno;
}
return APR_SUCCESS;
@@ -53,22 +65,14 @@ static apr_status_t datum_cleanup(void *
static apr_status_t set_error(apr_dbm_t *dbm, apr_status_t dbm_said)
{
- apr_status_t rv = APR_SUCCESS;
-
- /* ### ignore whatever the DBM said (dbm_said); ask it explicitly */
+ dbm->errcode = dbm_said;
- if ((dbm->errcode = gdbm_errno) == GDBM_NO_ERROR) {
+ if (dbm_said == APR_SUCCESS)
dbm->errmsg = NULL;
- }
- else {
- dbm->errmsg = gdbm_strerror(gdbm_errno);
- rv = APR_EGENERAL; /* ### need something better */
- }
-
- /* captured it. clear it now. */
- gdbm_errno = GDBM_NO_ERROR;
+ else
+ dbm->errmsg = gdbm_strerror(dbm_said - APR_OS_START_USEERR);
- return rv;
+ return dbm_said;
}
/* --------------------------------------------------------------------------
@@ -107,7 +111,7 @@ static apr_status_t vt_gdbm_open(apr_dbm
NULL);
if (file == NULL)
- return APR_EGENERAL; /* ### need a better error */
+ return APR_OS_START_USEERR + gdbm_errno;
/* we have an open database... return it */
*pdb = apr_pcalloc(pool, sizeof(**pdb));
@@ -141,10 +145,12 @@ static apr_status_t vt_gdbm_fetch(apr_db
if (pvalue->dptr)
apr_pool_cleanup_register(dbm->pool, pvalue->dptr, datum_cleanup,
apr_pool_cleanup_null);
+ else
+ pvalue->dsize = 0;
/* store the error info into DBM, and return a status code. Also, note
that *pvalue should have been cleared on error. */
- return set_error(dbm, APR_SUCCESS);
+ return set_error(dbm, gdat2s(rd));
}
static apr_status_t vt_gdbm_store(apr_dbm_t *dbm, apr_datum_t key,
@@ -201,9 +207,11 @@ static apr_status_t vt_gdbm_firstkey(apr
if (pkey->dptr)
apr_pool_cleanup_register(dbm->pool, pkey->dptr, datum_cleanup,
apr_pool_cleanup_null);
+ else
+ pkey->dsize = 0;
/* store any error info into DBM, and return a status code. */
- return set_error(dbm, APR_SUCCESS);
+ return set_error(dbm, gdat2s(rd));
}
static apr_status_t vt_gdbm_nextkey(apr_dbm_t *dbm, apr_datum_t *pkey)
@@ -221,9 +229,11 @@ static apr_status_t vt_gdbm_nextkey(apr_
if (pkey->dptr)
apr_pool_cleanup_register(dbm->pool, pkey->dptr, datum_cleanup,
apr_pool_cleanup_null);
+ else
+ pkey->dsize = 0;
/* store any error info into DBM, and return a status code. */
- return set_error(dbm, APR_SUCCESS);
+ return set_error(dbm, gdat2s(rd));
}
static void vt_gdbm_freedatum(apr_dbm_t *dbm, apr_datum_t data)