httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@apache.org
Subject cvs commit: httpd-2.0/modules/dav/fs dbm.c
Date Wed, 24 Jan 2001 10:24:05 GMT
gstein      01/01/24 02:24:04

  Modified:    .        STATUS
               include  apr_dbm.h
               dbm      apr_dbm.c
               modules/dav/fs dbm.c
  Log:
  - change the prototype for apr_dbm_geterror()  [and update dav/fs/dbm.c]
  - fix up some error handling in apr_dbm.c
  - use "dbm" consistently for the apr_dbm_t parameter
  
  Revision  Changes    Path
  1.23      +1 -4      apr-util/STATUS
  
  Index: STATUS
  ===================================================================
  RCS file: /home/cvs/apr-util/STATUS,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -u -r1.22 -r1.23
  --- STATUS	2001/01/24 09:10:05	1.22
  +++ STATUS	2001/01/24 10:24:00	1.23
  @@ -1,5 +1,5 @@
   APRUTIL LIBRARY STATUS:						-*-text-*-
  -Last modified at [$Date: 2001/01/24 09:10:05 $]
  +Last modified at [$Date: 2001/01/24 10:24:00 $]
   
   Release:
       2.0a9   : released December 12, 2000
  @@ -11,9 +11,6 @@
         [Will voulenteers - is on it]
   
   RELEASE NON-SHOWSTOPPERS BUT WOULD BE REAL NICE TO WRAP THESE UP:
  -
  -    * fix apr_dbm_geterror() prototype
  -      Status: OtherBill +1, Greg +1
   
   
   Other bugs that need fixing:
  
  
  
  1.8       +15 -6     apr-util/include/apr_dbm.h
  
  Index: apr_dbm.h
  ===================================================================
  RCS file: /home/cvs/apr-util/include/apr_dbm.h,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -u -r1.7 -r1.8
  --- apr_dbm.h	2001/01/24 09:10:09	1.7
  +++ apr_dbm.h	2001/01/24 10:24:01	1.8
  @@ -106,12 +106,13 @@
    */
   APU_DECLARE(apr_status_t) apr_dbm_open(apr_dbm_t **dbm, const char *name, 
                                          int mode, apr_pool_t *cntxt);
  +
   /**
    * Close a dbm file previously opened by apr_dbm_open
    * @param dbm The database to close
  - * @deffunc void apr_dbm_close(apr_dbm_t *db)
  + * @deffunc void apr_dbm_close(apr_dbm_t *dbm)
    */
  -APU_DECLARE(void) apr_dbm_close(apr_dbm_t *db);
  +APU_DECLARE(void) apr_dbm_close(apr_dbm_t *dbm);
   
   /**
    * Fetch a dbm record value by key
  @@ -137,6 +138,7 @@
    * @param dbm The database 
    * @param key The key datum of the record to delete
    * @deffunc apr_status_t apr_dbm_delete(apr_dbm_t *dbm, apr_datum_t key)
  + * @tip It is not an error to delete a non-existent record.
    */
   APU_DECLARE(apr_status_t) apr_dbm_delete(apr_dbm_t *dbm, apr_datum_t key);
   
  @@ -172,11 +174,18 @@
    */
   APU_DECLARE(void) apr_dbm_freedatum(apr_dbm_t *dbm, apr_datum_t data);
   
  -/* XXX: Need to change errcode to be handled canonically, and modify
  - * the prototype to follow apr_dso_error etc.
  - * @deffunc void apr_dbm_geterror(apr_dbm_t *dbm, int *errcode, const char **errmsg)
  +/**
  + * Report more information when an apr_dbm function fails.
  + * @param dbm The database
  + * @param errcode A DBM-specific value for the error (for logging). If this
  + *                isn't needed, it may be NULL.
  + * @param errbuf Location to store the error text
  + * @param errbufsize The size of the provided buffer
  + * @return The errbuf parameter, for convenience.
  + * @deffunc const char * apr_dbm_geterror(apr_dbm_t *dbm, int *errcode, char *errbuf, apr_size_t
errbufsize)
    */
  -APU_DECLARE(void) apr_dbm_geterror(apr_dbm_t *dbm, int *errcode, const char **errmsg);
  +APU_DECLARE(char *) apr_dbm_geterror(apr_dbm_t *dbm, int *errcode,
  +                                     char *errbuf, apr_size_t errbufsize);
   
   /**
    * If the specified file/path were passed to apr_dbm_open(), return the
  
  
  
  1.14      +59 -64    apr-util/dbm/apr_dbm.c
  
  Index: apr_dbm.c
  ===================================================================
  RCS file: /home/cvs/apr-util/dbm/apr_dbm.c,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -u -r1.13 -r1.14
  --- apr_dbm.c	2001/01/24 09:10:11	1.13
  +++ apr_dbm.c	2001/01/24 10:24:02	1.14
  @@ -104,7 +104,7 @@
   {
       if (gerr == -1) {
           /* ### need to fix this */
  -        return APR_EINVAL;
  +        return APR_EGENERAL;
       }
   
       return APR_SUCCESS;
  @@ -137,43 +137,45 @@
       return APR_SUCCESS;
   }
   
  -#define REG_CLEANUP(db, pdatum) \
  +#define REG_CLEANUP(dbm, pdatum) \
       if ((pdatum)->dptr) \
  -        apr_register_cleanup((db)->pool, (pdatum)->dptr, \
  +        apr_register_cleanup((dbm)->pool, (pdatum)->dptr, \
                                datum_cleanup, apr_null_cleanup); \
       else
   
   #else /* NEEDS_CLEANUP */
   
  -#define REG_CLEANUP(db, pdatum) if (0) ; else   /* stop "no effect" warning */
  +#define REG_CLEANUP(dbm, pdatum) if (0) ; else   /* stop "no effect" warning */
   
   #endif /* NEEDS_CLEANUP */
   
  -static apr_status_t set_error(apr_dbm_t *db)
  +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 */
  +
   #if APU_USE_SDBM
   
  -    if ((db->errcode = sdbm_error(db->file)) == 0) {
  -        db->errmsg = NULL;
  +    if ((dbm->errcode = sdbm_error(dbm->file)) == 0) {
  +        dbm->errmsg = NULL;
       }
       else {
  -        db->errmsg = "I/O error occurred.";
  -        rv = APR_EINVAL;        /* ### need something better */
  +        dbm->errmsg = "I/O error occurred.";
  +        rv = APR_EGENERAL;        /* ### need something better */
       }
   
       /* captured it. clear it now. */
  -    sdbm_clearerr(db->file);
  +    sdbm_clearerr(dbm->file);
   
   #elif APU_USE_GDBM
   
  -    if ((db->errcode = gdbm_errno) == GDBM_NO_ERROR) {
  -        db->errmsg = NULL;
  +    if ((dbm->errcode = gdbm_errno) == GDBM_NO_ERROR) {
  +        dbm->errmsg = NULL;
       }
       else {
  -        db->errmsg = gdbm_strerror(gdbm_errno);
  -        rv = APR_EINVAL;        /* ### need something better */
  +        dbm->errmsg = gdbm_strerror(gdbm_errno);
  +        rv = APR_EGENERAL;        /* ### need something better */
       }
   
       /* captured it. clear it now. */
  @@ -231,109 +233,102 @@
       return APR_SUCCESS;
   }
   
  -APU_DECLARE(void) apr_dbm_close(apr_dbm_t *db)
  +APU_DECLARE(void) apr_dbm_close(apr_dbm_t *dbm)
   {
  -    APR_DBM_CLOSE(db->file);
  +    APR_DBM_CLOSE(dbm->file);
   }
   
  -APU_DECLARE(apr_status_t) apr_dbm_fetch(apr_dbm_t *db, apr_datum_t key,
  +APU_DECLARE(apr_status_t) apr_dbm_fetch(apr_dbm_t *dbm, apr_datum_t key,
                                           apr_datum_t *pvalue)
   {
  -    *(real_datum_t *) pvalue = APR_DBM_FETCH(db->file, A2R_DATUM(key));
  +    *(real_datum_t *) pvalue = APR_DBM_FETCH(dbm->file, A2R_DATUM(key));
   
  -    REG_CLEANUP(db, pvalue);
  +    REG_CLEANUP(dbm, pvalue);
   
  -    /* store the error info into DB, and return a status code. Also, note
  +    /* store the error info into DBM, and return a status code. Also, note
          that *pvalue should have been cleared on error. */
  -    return set_error(db);
  +    return set_error(dbm, APR_SUCCESS);
   }
   
  -APU_DECLARE(apr_status_t) apr_dbm_store(apr_dbm_t *db, apr_datum_t key,
  +APU_DECLARE(apr_status_t) apr_dbm_store(apr_dbm_t *dbm, apr_datum_t key,
                                           apr_datum_t value)
   {
       apr_status_t rv;
  -
  -    rv = APR_DBM_STORE(db->file, A2R_DATUM(key), A2R_DATUM(value));
  -
  -    /* ### is this the right handling of set_error() and rv? */
   
  -    /* store the error info into DB, and return a status code. Also, note
  -       that *pvalue should have been cleared on error. */
  -    (void) set_error(db);
  +    rv = APR_DBM_STORE(dbm->file, A2R_DATUM(key), A2R_DATUM(value));
   
  -    return rv;
  +    /* store any error info into DBM, and return a status code. */
  +    return set_error(dbm, rv);
   }
   
  -APU_DECLARE(apr_status_t) apr_dbm_delete(apr_dbm_t *db, apr_datum_t key)
  +APU_DECLARE(apr_status_t) apr_dbm_delete(apr_dbm_t *dbm, apr_datum_t key)
   {
       apr_status_t rv;
   
  -    rv = APR_DBM_DELETE(db->file, A2R_DATUM(key));
  +    rv = APR_DBM_DELETE(dbm->file, A2R_DATUM(key));
   
  -    /* ### is this the right handling of set_error() and rv? */
  -
  -    /* store the error info into DB, and return a status code. Also, note
  -       that *pvalue should have been cleared on error. */
  -    (void) set_error(db);
  -
  -    return rv;
  +    /* store any error info into DBM, and return a status code. */
  +    return set_error(dbm, rv);
   }
   
  -APU_DECLARE(int) apr_dbm_exists(apr_dbm_t *db, apr_datum_t key)
  +APU_DECLARE(int) apr_dbm_exists(apr_dbm_t *dbm, apr_datum_t key)
   {
       int exists;
   
   #if APU_USE_SDBM
       {
  -	sdbm_datum value = sdbm_fetch(db->file, A2R_DATUM(key));
  -	sdbm_clearerr(db->file);	/* don't need the error */
  +	sdbm_datum value = sdbm_fetch(dbm->file, A2R_DATUM(key));
  +	sdbm_clearerr(dbm->file);	/* don't need the error */
   	exists = value.dptr != NULL;
       }
   #elif APU_USE_GDBM
  -    exists = gdbm_exists(db->file, A2R_DATUM(key)) != 0;
  +    exists = gdbm_exists(dbm->file, A2R_DATUM(key)) != 0;
   #endif
       return exists;
   }
   
  -APU_DECLARE(apr_status_t) apr_dbm_firstkey(apr_dbm_t *db, apr_datum_t *pkey)
  +APU_DECLARE(apr_status_t) apr_dbm_firstkey(apr_dbm_t *dbm, apr_datum_t *pkey)
   {
  -    *(real_datum_t *) pkey = APR_DBM_FIRSTKEY(db->file);
  +    *(real_datum_t *) pkey = APR_DBM_FIRSTKEY(dbm->file);
   
  -    REG_CLEANUP(db, pkey);
  +    REG_CLEANUP(dbm, pkey);
   
  -    /* store the error info into DB, and return a status code. Also, note
  -       that *pvalue should have been cleared on error. */
  -    return set_error(db);
  +    /* store any error info into DBM, and return a status code. */
  +    return set_error(dbm, APR_SUCCESS);
   }
   
  -APU_DECLARE(apr_status_t) apr_dbm_nextkey(apr_dbm_t *db, apr_datum_t *pkey)
  +APU_DECLARE(apr_status_t) apr_dbm_nextkey(apr_dbm_t *dbm, apr_datum_t *pkey)
   {
  -    *(real_datum_t *) pkey = APR_DBM_NEXTKEY(db->file, A2R_DATUM(*pkey));
  +    *(real_datum_t *) pkey = APR_DBM_NEXTKEY(dbm->file, A2R_DATUM(*pkey));
   
  -    REG_CLEANUP(db, pkey);
  +    REG_CLEANUP(dbm, pkey);
   
  -    /* store the error info into DB, and return a status code. Also, note
  -       that *pvalue should have been cleared on error. */
  -    return set_error(db);
  +    /* store any error info into DBM, and return a status code. */
  +    return set_error(dbm, APR_SUCCESS);
   }
   
  -APU_DECLARE(void) apr_dbm_freedatum(apr_dbm_t *db, apr_datum_t data)
  +APU_DECLARE(void) apr_dbm_freedatum(apr_dbm_t *dbm, apr_datum_t data)
   {
   #ifdef NEEDS_CLEANUP
  -    (void) apr_run_cleanup(db->pool, data.dptr, datum_cleanup);
  +    (void) apr_run_cleanup(dbm->pool, data.dptr, datum_cleanup);
   #else
       APR_DBM_FREEDPTR(data.dptr);
   #endif
   }
   
  -/* XXX: This is wrong... need to return a canonical errcode as part
  - * of this package, and follow the apr_dso_error prototype.
  - */
  -APU_DECLARE(void) apr_dbm_geterror(apr_dbm_t *db, int *errcode, 
  -                                   const char **errmsg)
  +APU_DECLARE(char *) apr_dbm_geterror(apr_dbm_t *dbm, int *errcode,
  +                                     char *errbuf, apr_size_t errbufsize)
   {
  -    *errcode = db->errcode;
  -    *errmsg = db->errmsg;
  +    if (errcode != NULL)
  +        *errcode = dbm->errcode;
  +
  +    /* assert: errbufsize > 0 */
  +
  +    if (dbm->errmsg == NULL)
  +        *errbuf = '\0';
  +    else
  +        (void) apr_cpystrn(errbuf, dbm->errmsg, errbufsize);
  +    return errbuf;
   }
   
   APU_DECLARE(void) apr_dbm_get_usednames(apr_pool_t *p,
  
  
  
  1.14      +3 -1      httpd-2.0/modules/dav/fs/dbm.c
  
  Index: dbm.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/dav/fs/dbm.c,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -u -r1.13 -r1.14
  --- dbm.c	2001/01/24 09:10:15	1.13
  +++ dbm.c	2001/01/24 10:24:03	1.14
  @@ -97,6 +97,7 @@
       int errcode;
       const char *errstr;
       dav_error *err;
  +    char errbuf[200];
   
       if (status == APR_SUCCESS)
           return NULL;
  @@ -109,7 +110,8 @@
           errstr = "Could not open property database.";
       }
       else {
  -        apr_dbm_geterror(db->file, &errcode, &errstr);
  +        (void) apr_dbm_geterror(db->file, &errcode, errbuf, sizeof(errbuf));
  +        errstr = apr_pstrdup(p, errbuf);
       }
   
       err = dav_new_error(p, HTTP_INTERNAL_SERVER_ERROR, errcode, errstr);
  
  
  

Mime
View raw message