another one...
Heath Kehoe
heath.kehoe at intermec.com
Mon Jun 12 21:17:03 UTC 2000
OK, here's another bugfix for ovdb. Hopefully this will be the
last one of these for a while. This needs to go into both CURRENT
and BETA.
ovdb.c: Modified groupnum() interface; fix ovdb_add() to return FALSE
for certain groupnum() errors
Plus a small doc update.
Thanks,
-heath
*** ../inn-BETA-20000612/doc/man/ovdb_upgrade.8 Mon Jun 12 04:04:42 2000
--- ./doc/man/ovdb_upgrade.8 Fri Jun 9 16:01:38 2000
***************
*** 1,5 ****
.\" Automatically generated by Pod::Man version 1.02
! .\" Fri Jun 9 00:11:23 2000
.\"
.\" Standard preamble:
.\" ======================================================================
--- 1,5 ----
.\" Automatically generated by Pod::Man version 1.02
! .\" Fri Jun 9 16:01:02 2000
.\"
.\" Standard preamble:
.\" ======================================================================
***************
*** 168,174 ****
\&\f(CW\*(C`./configure \-\-with\-berkeleydb=/usr/local/BerkeleyDB.3.x [... other options]\*(C'\fR
.Ip "4" 4
.IX Item "4"
! Shut down \s-1INN\s0 (e.g., with \f(CW\*(C`rc.news stop\*(C'\fR)
.Ip "5" 4
.IX Item "5"
Do a \f(CW\*(C`make update\*(C'\fR to build \s-1INN\s0 with the new BerkeleyDB version and install
--- 168,175 ----
\&\f(CW\*(C`./configure \-\-with\-berkeleydb=/usr/local/BerkeleyDB.3.x [... other options]\*(C'\fR
.Ip "4" 4
.IX Item "4"
! Shut down \s-1INN\s0 (e.g., with \f(CW\*(C`rc.news stop\*(C'\fR). Be sure to kill all nnrpds as
! well.
.Ip "5" 4
.IX Item "5"
Do a \f(CW\*(C`make update\*(C'\fR to build \s-1INN\s0 with the new BerkeleyDB version and install
*** ../inn-BETA-20000612/doc/pod/ovdb_upgrade.pod Mon Jun 12 04:04:46 2000
--- ./doc/pod/ovdb_upgrade.pod Fri Jun 9 15:59:34 2000
***************
*** 35,41 ****
=item 4
! Shut down INN (e.g., with C<rc.news stop>)
=item 5
--- 35,42 ----
=item 4
! Shut down INN (e.g., with C<rc.news stop>). Be sure to kill all nnrpds as
! well.
=item 5
*** ../inn-BETA-20000612/storage/ovdb/ovdb.c Mon Jun 12 04:05:35 2000
--- ./storage/ovdb/ovdb.c Mon Jun 12 16:02:07 2000
***************
*** 2,7 ****
--- 2,9 ----
* ovdb.c
* Overview storage using BerkeleyDB 2.x/3.x
*
+ * 2000-06-10 : Modified groupnum() interface; fix ovdb_add() to return FALSE
+ * for certain groupnum() errors
* 2000-06-08 : Added BerkeleyDB 3.1.x compatibility
* 2000-04-09 : Tweak some default parameters; store aliased group info
* 2000-03-29 : Add DB_RMW flag to the 'get' of get-modify-put sequences
***************
*** 406,416 ****
static DB *get_db_bynum(int which)
{
if(oneatatime) {
if(which != current_db && current_db != -1)
close_db_file(current_db);
! open_db_file(which);
current_db = which;
}
return(dbs[which]);
--- 408,421 ----
static DB *get_db_bynum(int which)
{
+ int ret;
if(oneatatime) {
if(which != current_db && current_db != -1)
close_db_file(current_db);
! if(ret = open_db_file(which))
! syslog(L_ERROR, "OVDB: open_db_file failed: %s", db_strerror(ret));
!
current_db = which;
}
return(dbs[which]);
***************
*** 423,437 ****
return get_db_bynum(which_db(group));
}
! /* returns group ID for given group */
! static group_id_t groupnum(char *group)
{
int ret;
DBT key, val;
- group_id_t gno;
if(group == NULL) /* just in case */
! return 0;
memset(&key, 0, sizeof key);
memset(&val, 0, sizeof val);
--- 428,441 ----
return get_db_bynum(which_db(group));
}
! /* returns group ID for given group in gno */
! static int groupnum(char *group, group_id_t *gno)
{
int ret;
DBT key, val;
if(group == NULL) /* just in case */
! return DB_NOTFOUND;
memset(&key, 0, sizeof key);
memset(&val, 0, sizeof val);
***************
*** 438,459 ****
key.data = group;
key.size = strlen(group);
! val.data = &gno; /* the get call will write directly into gno */
! val.ulen = sizeof gno;
val.flags = DB_DBT_USERMEM;
if(ret = groupsbyname->get(groupsbyname, NULL, &key, &val, 0)) {
if(ret != DB_NOTFOUND)
syslog(L_ERROR, "OVDB: groupnum: get: %s", db_strerror(ret));
! return 0;
}
! if(val.size != sizeof gno) {
syslog(L_ERROR, "OVDB: groupnum: wrong size for groupnum val (%d, %s)", val.size, group);
! return 0;
}
! return gno;
}
static void delete_all_records(group_id_t gno)
--- 442,463 ----
key.data = group;
key.size = strlen(group);
! val.data = gno;
! val.ulen = sizeof(group_id_t);
val.flags = DB_DBT_USERMEM;
if(ret = groupsbyname->get(groupsbyname, NULL, &key, &val, 0)) {
if(ret != DB_NOTFOUND)
syslog(L_ERROR, "OVDB: groupnum: get: %s", db_strerror(ret));
! return ret;
}
! if(val.size != sizeof(group_id_t)) {
syslog(L_ERROR, "OVDB: groupnum: wrong size for groupnum val (%d, %s)", val.size, group);
! return DB_NOTFOUND;
}
! return 0;
}
static void delete_all_records(group_id_t gno)
***************
*** 834,844 ****
BOOL ovdb_groupstats(char *group, int *lo, int *hi, int *count, int *flag)
{
int ret;
! group_id_t gno = groupnum(group);
DBT key, val;
struct groupstats gs;
! if(!gno)
return FALSE;
memset(&key, 0, sizeof key);
--- 838,848 ----
BOOL ovdb_groupstats(char *group, int *lo, int *hi, int *count, int *flag)
{
int ret;
! group_id_t gno;
DBT key, val;
struct groupstats gs;
! if(groupnum(group, &gno) != 0)
return FALSE;
memset(&key, 0, sizeof key);
***************
*** 886,895 ****
int ret, new = 0;
retry:
! gno = groupnum(group);
! if(!gno)
new = 1;
!
memset(&key, 0, sizeof key);
memset(&val, 0, sizeof val);
--- 890,903 ----
int ret, new = 0;
retry:
! switch(groupnum(group, &gno)) {
! case DB_NOTFOUND:
new = 1;
! case 0:
! break;
! default:
! return FALSE;
! }
memset(&key, 0, sizeof key);
memset(&val, 0, sizeof val);
***************
*** 1097,1106 ****
db = get_db(group);
if(!db)
return TRUE;
! gno = groupnum(group);
! if(!gno)
! return TRUE;
/* start the transaction */
retry:
--- 1105,1116 ----
db = get_db(group);
if(!db)
+ return FALSE;
+ ret = groupnum(group, &gno);
+ if(ret == DB_NOTFOUND)
return TRUE;
! if(ret != 0)
! return FALSE;
/* start the transaction */
retry:
***************
*** 1203,1210 ****
s = NEW(struct ovdbsearch, 1);
! gno = groupnum(group);
! if(!gno) {
DISPOSE(s);
return NULL;
}
--- 1213,1219 ----
s = NEW(struct ovdbsearch, 1);
! if(groupnum(group, &gno) != 0) {
DISPOSE(s);
return NULL;
}
***************
*** 1325,1337 ****
{
int ret;
DB *db = get_db(group);
! group_id_t gno = groupnum(group);
DBT key, val;
struct ovdata ovd;
struct datakey dk;
! if(!db || !gno)
return FALSE;
dk.groupnum = gno;
dk.artnum = htonl(artnum);
--- 1334,1348 ----
{
int ret;
DB *db = get_db(group);
! group_id_t gno;
DBT key, val;
struct ovdata ovd;
struct datakey dk;
! if(!db)
return FALSE;
+ if(groupnum(group, &gno) != 0)
+ return FALSE;
dk.groupnum = gno;
dk.artnum = htonl(artnum);
***************
*** 1401,1412 ****
return delete_old_stuff();
db = get_db(group);
! if(!db) {
! syslog(L_ERROR, "OVDB: get_db(%s) failed (errno=%m)", group);
return FALSE;
! }
! gno = groupnum(group);
! if(!gno)
return FALSE;
memset(&key, 0, sizeof key);
--- 1412,1420 ----
return delete_old_stuff();
db = get_db(group);
! if(!db)
return FALSE;
! if(groupnum(group, &gno) != 0)
return FALSE;
memset(&key, 0, sizeof key);
More information about the inn-patches
mailing list