OVgetartinfo API change (and ovdb issues)
Russ Allbery
rra at stanford.edu
Thu Feb 28 21:23:17 UTC 2002
I'm going ahead and committing the OVgetartinfo API change as previously
discussed, which required a bit of surgery to ovdb. I *think* that these
changes are correct, but I wasn't able to test them, so here are the ovdb
changes for other eyes to look over.
All the tradindexed tests pass, and I'm *fairly* sure the ovdb changes are
okay, so I'll go ahead and commit and we can fix quickly if it actually
breaks something.
Index: frontends/ovdb_server.c
===================================================================
RCS file: /dist1/cvs/isc/inn/inn/frontends/ovdb_server.c,v
retrieving revision 1.10
diff -u -r1.10 ovdb_server.c
--- frontends/ovdb_server.c 2001/06/29 23:15:24 1.10
+++ frontends/ovdb_server.c 2002/02/28 21:21:10
@@ -356,13 +356,11 @@
int len;
/*syslog(LOG_DEBUG, "OVDB: rs: do_artinfo: '%s' %d", group, cmd->artlo);*/
- if(ovdb_getartinfo(group, cmd->artlo, &data, &len, &token)) {
- reply = NEW(char, (sizeof(struct rs_artinfo) + len));
+ if(ovdb_getartinfo(group, cmd->artlo, &token)) {
+ reply = NEW(char, (sizeof(struct rs_artinfo)));
reply->status = CMD_ARTINFO;
- reply->len = len;
reply->token = token;
- memcpy((char *)reply + sizeof(struct rs_artinfo), data, len);
- r->buflen = sizeof(struct rs_artinfo) + len;
+ r->buflen = sizeof(struct rs_artinfo);
} else {
reply = NEW(struct rs_artinfo, 1);
reply->status = CMD_ARTINFO | RPLY_ERROR;
cvs server: Diffing storage/ovdb
Index: storage/ovdb/ovdb-private.h
===================================================================
RCS file: /dist1/cvs/isc/inn/inn/storage/ovdb/ovdb-private.h,v
retrieving revision 1.8
diff -u -r1.8 ovdb-private.h
--- storage/ovdb/ovdb-private.h 2002/01/03 15:39:07 1.8
+++ storage/ovdb/ovdb-private.h 2002/02/28 21:21:11
@@ -160,8 +160,6 @@
struct rs_artinfo {
uint32_t status;
TOKEN token;
- int len;
- /* char data */
};
Index: storage/ovdb/ovdb.c
===================================================================
RCS file: /dist1/cvs/isc/inn/inn/storage/ovdb/ovdb.c,v
retrieving revision 1.36
diff -u -r1.36 ovdb.c
--- storage/ovdb/ovdb.c 2002/01/03 15:39:07 1.36
+++ storage/ovdb/ovdb.c 2002/02/28 21:21:14
@@ -3,6 +3,8 @@
* ovdb 2.00 beta4
* Overview storage using BerkeleyDB 2.x/3.x
*
+ * 2002-02-28 : Update getartinfo for the overview API change in 2.4. This
+ * breaks compatibility with INN 2.3.x....
* 2000-12-12 : Add support for BerkeleyDB DB_SYSTEM_MEM option, controlled
* : by ovdb.conf 'useshm' and 'shmkey'
* 2000-11-27 : Update for DB 3.2.x compatibility
@@ -157,7 +159,7 @@
void ovdb_closesearch(void *handle) { }
-BOOL ovdb_getartinfo(char *group, ARTNUM artnum, char **data, int *len, TOKEN *token)
+BOOL ovdb_getartinfo(char *group, ARTNUM artnum, TOKEN *token)
{ return FALSE; }
BOOL ovdb_expiregroup(char *group, int *lo, struct history *h)
@@ -2101,7 +2103,7 @@
}
}
-BOOL ovdb_getartinfo(char *group, ARTNUM artnum, char **data, int *len, TOKEN *token)
+BOOL ovdb_getartinfo(char *group, ARTNUM artnum, TOKEN *token)
{
int ret, cdb;
group_id_t cgid;
@@ -2115,7 +2117,6 @@
if(clientmode) {
struct rs_cmd rs;
struct rs_artinfo repl;
- static char *databuf;
static int buflen = 0;
rs.what = CMD_ARTINFO;
@@ -2128,23 +2129,10 @@
if(repl.status != CMD_ARTINFO)
return FALSE;
- if(repl.len > buflen) {
- if(buflen == 0) {
- buflen = repl.len + 512;
- databuf = NEW(char, buflen);
- } else {
- buflen = repl.len + 512;
- RENEW(databuf, char, buflen);
- }
- }
- crecv(databuf, repl.len);
if(token)
*token = repl.token;
- if(len)
- *len = repl.len;
- if(data)
- *data = databuf;
+
return TRUE;
}
@@ -2183,13 +2171,11 @@
key.data = &dk;
key.size = sizeof dk;
- if(!data && !len) {
- /* caller doesn't need data, so we don't have to retrieve it all */
- val.flags = DB_DBT_PARTIAL;
+ /* caller doesn't need data, so we don't have to retrieve it all */
+ val.flags = DB_DBT_PARTIAL;
- if(token)
- val.dlen = sizeof(struct ovdata);
- }
+ if(token)
+ val.dlen = sizeof(struct ovdata);
switch(ret = db->get(db, NULL, &key, &val, 0)) {
case 0:
@@ -2216,16 +2202,10 @@
break;
}
- if( ( (len || data) && val.size <= sizeof(struct ovdata) )
- || (token && val.size < sizeof(struct ovdata) ) ) {
+ if(token && val.size < sizeof(struct ovdata)) {
syslog(L_ERROR, "OVDB: getartinfo: data too short");
return FALSE;
}
-
- if(len)
- *len = val.size - sizeof(struct ovdata);
- if(data)
- *data = (char *)val.data + sizeof(struct ovdata);
if(token) {
memcpy(&ovd, val.data, sizeof(struct ovdata));
Index: storage/ovdb/ovdb.h
===================================================================
RCS file: /dist1/cvs/isc/inn/inn/storage/ovdb/ovdb.h,v
retrieving revision 1.3
diff -u -r1.3 ovdb.h
--- storage/ovdb/ovdb.h 2001/07/11 07:35:21 1.3
+++ storage/ovdb/ovdb.h 2002/02/28 21:21:14
@@ -14,7 +14,7 @@
void *ovdb_opensearch(char *group, int low, int high);
BOOL ovdb_search(void *handle, ARTNUM *artnum, char **data, int *len, TOKEN *token, time_t *arrived);
void ovdb_closesearch(void *handle);
-BOOL ovdb_getartinfo(char *group, ARTNUM artnum, char **data, int *len, TOKEN *token);
+BOOL ovdb_getartinfo(char *group, ARTNUM artnum, TOKEN *token);
BOOL ovdb_expiregroup(char *group, int *lo, struct history *h);
BOOL ovdb_ctl(OVCTLTYPE type, void *val);
void ovdb_close(void);
--
Russ Allbery (rra at stanford.edu) <http://www.eyrie.org/~eagle/>
More information about the inn-workers
mailing list