- replace cdb_trunc with a complete version of the code i had been
authorNathan Bryant <loanshark@uncensored.citadel.org>
Sun, 10 Feb 2002 22:36:41 +0000 (22:36 +0000)
committerNathan Bryant <loanshark@uncensored.citadel.org>
Sun, 10 Feb 2002 22:36:41 +0000 (22:36 +0000)
   working on; fallback code for db < 3.3.x needed
 - change 'can't connect to host.port' to 'can't connect to host:port'

citadel/ChangeLog
citadel/clientsocket.c
citadel/database_sleepycat.c
citadel/ipc_c_tcp.c

index 477748581402cc541b748afc2113a1a3f4fabed3..9ec5cf61e7db11d30cccf54b056a1a6e207f05fa 100644 (file)
@@ -1,4 +1,9 @@
  $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>
@@ -3318,4 +3323,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import 
-
index b1ad7f05e38ff13111a08cdfb642d5d2d1631189..0c6d401c2f70e60166b9947d7bd9e7744dce397b 100644 (file)
@@ -85,7 +85,7 @@ int sock_connect(char *host, char *service, char *protocol)
        }
 
        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);
        }
index 9f84a427a541f88a29b20acf48846c4b328c0d27..2cca9a37e178b20839212f96b2d2a38bb4214fba 100644 (file)
@@ -665,26 +665,6 @@ struct cdbdata *cdb_next_item(int cdb)
 
 
 
-/*
- * 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...
  */
@@ -723,3 +703,55 @@ void cdb_end_transaction(void) {
   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);
+       }
+    }
+}
index aba311f888dec944de9271379e43fb8ca62eafde..f646a66f48b8dfaf6dc27c92ef5a19ed54c76996 100644 (file)
@@ -134,7 +134,7 @@ static int connectsock(char *host, char *service, char *protocol, int defaultPor
        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);
        }