$Log$
+ Revision 590.107 2002/02/10 22:36:41 nbryant
+ - replace cdb_trunc with a complete version of the code i had been
+ working on; fallback code for db < 3.3.x needed
+ - change 'can't connect to host.port' to 'can't connect to host:port'
+
Revision 590.106 2002/02/08 22:39:08 ajc
* If there's already a Subject line in memory, display it below the usual
headers when the user hits <E>
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
-
}
if (connect(s, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
- lprintf(3, "can't connect to %s.%s: %s\n",
+ lprintf(3, "can't connect to %s:%s: %s\n",
host, service, strerror(errno));
return(-1);
}
-/*
- * Truncate (delete every record)
- */
-void cdb_trunc(int cdb) {
- int ret = 0;
- u_int32_t records_deleted;
-
- cdb_begin_transaction();
-
- lprintf(9, "truncate\n");
- ret = dbp[cdb]->truncate(dbp[cdb], MYTID, &records_deleted, 0);
- if (ret) {
- lprintf(1, "cdb_trunc: db_truncate: %s\n", db_strerror(ret));
- abort();
- }
-
- cdb_end_transaction();
-}
-
-
/*
* Transaction-based stuff. I'm writing this as I bake cookies...
*/
MYTID = NULL;
}
+/*
+ * Truncate (delete every record)
+ */
+void cdb_trunc(int cdb)
+{
+ DB_TXN *tid;
+ int ret;
+ u_int32_t count;
+
+ if (MYTID != NULL)
+ {
+ ret = dbp[cdb]->truncate(dbp[cdb], /* db */
+ MYTID, /* transaction ID */
+ &count, /* #rows that were deleted */
+ 0); /* flags */
+ if (ret)
+ {
+ lprintf(1, "cdb_truncate(%d): %s\n", cdb,
+ db_strerror(ret));
+ abort();
+ }
+ }
+ else
+ {
+ bailIfCursor(MYCURSORS, "attempt to write during r/o cursor");
+
+ retry:
+ txbegin(&tid);
+
+ if ((ret = dbp[cdb]->truncate(dbp[cdb], /* db */
+ tid, /* transaction ID */
+ &count, /* #rows deleted */
+ 0))) /* flags */
+ {
+ if (ret == DB_LOCK_DEADLOCK)
+ {
+ txabort(tid);
+ goto retry;
+ }
+ else
+ {
+ lprintf(1, "cdb_truncate(%d): %s\n", cdb,
+ db_strerror(ret));
+ abort();
+ }
+ }
+ else
+ {
+ txcommit(tid);
+ }
+ }
+}
alarm(30);
if (connect(s, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
- err_printf("can't connect to %s.%s: %s\n",
+ err_printf("can't connect to %s:%s: %s\n",
host, service, strerror(errno));
logoff(3);
}