Return-Path: Delivered-To: apmail-apr-cvs-archive@apr.apache.org Received: (qmail 77128 invoked by uid 500); 2 May 2001 13:33:38 -0000 Mailing-List: contact cvs-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: dev@apr.apache.org Delivered-To: mailing list cvs@apr.apache.org Received: (qmail 77001 invoked by uid 500); 2 May 2001 13:33:36 -0000 Delivered-To: apmail-apr-util-cvs@apache.org Date: 2 May 2001 13:33:36 -0000 Message-ID: <20010502133336.76959.qmail@apache.org> From: wrowe@apache.org To: apr-util-cvs@apache.org Subject: cvs commit: apr-util/dbm/sdbm sdbm.c wrowe 01/05/02 06:33:36 Modified: dbm/sdbm sdbm.c Log: Back out the locking patch (rev 1.14) for reconsideration Revision Changes Path 1.17 +35 -96 apr-util/dbm/sdbm/sdbm.c Index: sdbm.c =================================================================== RCS file: /home/cvs/apr-util/dbm/sdbm/sdbm.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- sdbm.c 2001/05/01 05:37:05 1.16 +++ sdbm.c 2001/05/02 13:33:35 1.17 @@ -116,8 +116,7 @@ apr_sdbm_t *db = data; (void) apr_file_close(db->dirf); - if (!(db->flags & SDBM_SHARED)) - (void) sdbm_unlock(db); + (void) sdbm_unlock(db); (void) apr_file_close(db->pagf); free(db); @@ -147,17 +146,8 @@ db->flags = SDBM_RDONLY; } - /* - * adjust user flags so that SHARELOCK isn't used within - * APR (if it's ever implemented) since we will perform - * that locking here. - */ - if (flags & APR_SHARELOCK) { - flags &= ~APR_SHARELOCK; - db->flags |= SDBM_SHARED; - } - flags |= APR_BINARY | APR_READ; + /* * open the files in sequence, and stat the dirfile. * If we fail anywhere, undo everything, return NULL. @@ -176,13 +166,6 @@ goto error; /* - * if we are opened in SHARED mode, unlock ourself - */ - if (db->flags & SDBM_SHARED) - if ((status = sdbm_unlock(db)) != APR_SUCCESS) - goto error; - - /* * need the dirfile size to establish max bit number. */ if ((status = apr_file_info_get(&finfo, APR_FINFO_SIZE, db->dirf)) @@ -239,21 +222,13 @@ if (db == NULL || bad(key)) return APR_EINVAL; - if (db->flags & SDBM_SHARED) - if ((status = sdbm_lock(db, 0)) != APR_SUCCESS) - return ioerr(db, status); - if ((status = getpage(db, exhash(key))) == APR_SUCCESS) { *val = getpair(db->pagbuf, key); - /* ### do we want a not-found status result? */ + /* ### do we want a not-found result? */ + return APR_SUCCESS; } - else - ioerr(db, status); - - if (db->flags & SDBM_SHARED) - if ((status = sdbm_unlock(db)) != APR_SUCCESS) - ioerr(db, status); + ioerr(db, status); return status; } @@ -265,7 +240,8 @@ if ((status = apr_file_seek(db->pagf, APR_SET, &off)) != APR_SUCCESS || (status = apr_file_write_full(db->pagf, buf, PBLKSIZ, NULL)) != APR_SUCCESS) { - return ioerr(db, status); + ioerr(db, status); + return status; } return APR_SUCCESS; @@ -280,28 +256,22 @@ if (apr_sdbm_rdonly(db)) return APR_EINVAL; - if (db->flags & SDBM_SHARED) - if ((status = sdbm_lock(db, 1)) != APR_SUCCESS) - return ioerr(db, status); - if ((status = getpage(db, exhash(key))) == APR_SUCCESS) { - /* - * remove the key and update the page file - */ if (!delpair(db->pagbuf, key)) /* ### should we define some APRUTIL codes? */ - status = APR_EGENERAL; - else - status = write_page(db, db->pagbuf, db->pagbno); - } - else - ioerr(db, status); + return APR_EGENERAL; - if (db->flags & SDBM_SHARED) - if ((status = sdbm_unlock(db)) != APR_SUCCESS) - return ioerr(db, status); + /* + * update the page file + */ + if ((status = write_page(db, db->pagbuf, db->pagbno)) != APR_SUCCESS) + return status; - return status; + return APR_SUCCESS; + } + + ioerr(db, status); + return APR_EACCES; } apr_status_t apr_sdbm_store(apr_sdbm_t *db, apr_sdbm_datum_t key, @@ -323,10 +293,6 @@ if (need < 0 || need > PAIRMAX) return APR_EINVAL; - if (db->flags & SDBM_SHARED) - if ((status = sdbm_lock(db, 1)) != APR_SUCCESS) - return ioerr(db, status); - if ((status = getpage(db, (hash = exhash(key)))) == APR_SUCCESS) { /* @@ -335,32 +301,27 @@ */ if (flags == APR_SDBM_REPLACE) (void) delpair(db->pagbuf, key); - else if (!(flags & APR_SDBM_INSERTDUP) && duppair(db->pagbuf, key)) { - status = ioerr(db, APR_EEXIST); - goto error; - } + else if (!(flags & APR_SDBM_INSERTDUP) && duppair(db->pagbuf, key)) + return APR_EEXIST; /* * if we do not have enough room, we have to split. */ if (!fitpair(db->pagbuf, need)) - if ((status = makroom(db, hash, need)) != APR_SUCCESS) { - ioerr(db, status); - goto error; - } + if ((status = makroom(db, hash, need)) != APR_SUCCESS) + return status; /* * we have enough room or split is successful. insert the key, * and update the page file. */ (void) putpair(db->pagbuf, key, val); - status = write_page(db, db->pagbuf, db->pagbno); - } - -error: - if (db->flags & SDBM_SHARED) - if ((status = sdbm_unlock(db)) != APR_SUCCESS) - ioerr(db, status); + if ((status = write_page(db, db->pagbuf, db->pagbno)) != APR_SUCCESS) + return status; + return APR_SUCCESS; + } + + ioerr(db, status); return status; } @@ -472,48 +433,26 @@ */ apr_status_t apr_sdbm_firstkey(apr_sdbm_t *db, apr_sdbm_datum_t *key) { - apr_status_t status; - - if (db->flags & SDBM_SHARED) - if ((status = sdbm_lock(db, 0)) != APR_SUCCESS) - return ioerr(db, status); - /* * start at page 0 */ + apr_status_t status; if ((status = read_from(db->pagf, db->pagbuf, OFF_PAG(0), PBLKSIZ)) != APR_SUCCESS) { ioerr(db, status); - } - else { - db->pagbno = 0; - db->blkptr = 0; - db->keyptr = 0; - status = getnext(key, db); + return status; } - if (db->flags & SDBM_SHARED) - if ((status = sdbm_unlock(db)) != APR_SUCCESS) - ioerr(db, status); + db->pagbno = 0; + db->blkptr = 0; + db->keyptr = 0; - return status; + return getnext(key, db); } apr_status_t apr_sdbm_nextkey(apr_sdbm_t *db, apr_sdbm_datum_t *key) { - apr_status_t status; - - if (db->flags & SDBM_SHARED) - if ((status = sdbm_lock(db, 0)) != APR_SUCCESS) - return ioerr(db, status); - - status = getnext(key, db); - - if (db->flags & SDBM_SHARED) - if ((status = sdbm_unlock(db)) != APR_SUCCESS) - ioerr(db, status); - - return status; + return getnext(key, db); } /*