* New parameter to CtdlSaveMsgPointersInRoom() to suppress the reference count adjust...
authorArt Cancro <ajc@citadel.org>
Fri, 5 Mar 2010 21:19:07 +0000 (21:19 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 5 Mar 2010 21:19:07 +0000 (21:19 +0000)
citadel/citserver.c
citadel/modules/imap/imap_misc.c
citadel/modules/migrate/serv_migrate.c
citadel/modules/newuser/serv_newuser.c
citadel/modules/sieve/serv_sieve.c
citadel/msgbase.c
citadel/msgbase.h
citadel/utils/sendcommand.c

index f371d6bf5c3ad193dee6d571c09d0a0f99f5f204..603d3498243b8ee3a5b5b263e94b4c1ae3239925 100644 (file)
@@ -3,21 +3,21 @@
  *
  * Main source module for the Citadel server
  *
- * Copyright (c) 1987-2009 by the citadel.org team
+ * Copyright (c) 1987-2010 by the citadel.org team
  *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
  *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "sysdep.h"
@@ -29,7 +29,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
-
 #if TIME_WITH_SYS_TIME
 # include <sys/time.h>
 # include <time.h>
@@ -82,7 +81,6 @@
 
 #include "ctdl_module.h"
 
-
 char *unique_session_numbers;
 int ScheduledShutdown = 0;
 time_t server_startup_time;
index 496174a42b7ad9d083a17aac8a1368c26c260f01..dbd224ff705a73d125616ed6621660ee19fe1ed8 100644 (file)
@@ -1,23 +1,21 @@
 /*
  * $Id$
  *
+ * Copyright (c) 1987-2010 by the citadel.org team
  *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
  *
- * Copyright (c) 2001-2009 by the citadel.org team
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 
@@ -100,7 +98,7 @@ int imap_do_copy(const char *destination_folder) {
        }
 
        if (num_selected > 0) {
-               CtdlSaveMsgPointersInRoom(roomname, selected_msgs, num_selected, 1, NULL);
+               CtdlSaveMsgPointersInRoom(roomname, selected_msgs, num_selected, 1, NULL, 0);
        }
        free(selected_msgs);
 
index e570381f5f54bb95276edad48401831a72be8df1..cf8512916f0a6e8699380e33d3fb52ed4ff61487 100644 (file)
@@ -1,14 +1,14 @@
 /*
  * $Id$
  *
- * Copyright (c) 2000-2009 by the citadel.org development team
- *
  * This module dumps and/or loads the Citadel database in XML format.
  *
+ * Copyright (c) 1987-2010 by the citadel.org team
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -17,9 +17,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- * 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "sysdep.h"
@@ -797,7 +795,7 @@ void migr_xml_end(void *data, const char *el) {
                                }
                        }
                        if (msgcount > 0) {
-                               CtdlSaveMsgPointersInRoom(FRname, msglist, msgcount, 0, NULL);
+                               CtdlSaveMsgPointersInRoom(FRname, msglist, msgcount, 0, NULL, 1);
                        }
                        free(msglist);
                        msglist = NULL;
index afa5f47aee40f0a28cdd19d9e8db8443dea61142..431d433df6ad006f41b9bb996372103695b6ec36 100644 (file)
@@ -1,24 +1,24 @@
 /*
  * $Id$
  *
- * Automaticalyl copies the contents of a "New User Greetings" room to the
+ * Automatically copies the contents of a "New User Greetings" room to the
  * inbox of any new user upon account creation.
  *
- * Copyright (c) 1987-2009 by the citadel.org team
+ * Copyright (c) 1987-2010 by the citadel.org team
  *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
  *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 /*
@@ -101,7 +101,7 @@ void CopyNewUserGreetings(void) {
        }
 
        if (num_msgs > 0) {
-               CtdlSaveMsgPointersInRoom(mailboxname, msglist, num_msgs, 1, NULL);
+               CtdlSaveMsgPointersInRoom(mailboxname, msglist, num_msgs, 1, NULL, 0);
        }
 
        /* Now free the memory we used, and go away. */
index 9de59d91664071ddd922f7c856ac0ad44ebffa2c..88c72e9943556e8f759745fc9bfc8230123c40a3 100644 (file)
@@ -4,21 +4,21 @@
  * This module glues libSieve to the Citadel server in order to implement
  * the Sieve mailbox filtering language (RFC 3028).
  *
- * Copyright (c) 2007-2009 by the citadel.org team
+ * Copyright (c) 1987-2010 by the citadel.org team
  *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
  *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "sysdep.h"
@@ -193,7 +193,7 @@ int ctdl_fileinto(sieve2_context_t *s, void *my)
        /* Yes, we actually have to go there */
        CtdlUserGoto(NULL, 0, 0, NULL, NULL);
 
-       c = CtdlSaveMsgPointersInRoom(NULL, &cs->msgnum, 1, 0, NULL);
+       c = CtdlSaveMsgPointersInRoom(NULL, &cs->msgnum, 1, 0, NULL, 0);
 
        /* Go back to the room we came from */
        if (strcasecmp(original_room_name, CC->room.QRname)) {
index 429f17a8b4e6b56baef7f91a26f6f20fb17c8d94..98510111a8ff51f0d365914409b94594c236ad8a 100644 (file)
@@ -2,22 +2,22 @@
  * $Id$
  *
  * Implements the message store.
- * 
+ *
  * Copyright (c) 1987-2010 by the citadel.org team
  *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
  *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "sysdep.h"
@@ -2367,8 +2367,8 @@ void cmd_dlat(char *cmdbuf)
  * this mode of operation only works if we're saving a single message.)
  */
 int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newmsgs,
-                               int do_repl_check, struct CtdlMessage *supplied_msg)
-{
+                       int do_repl_check, struct CtdlMessage *supplied_msg, int suppress_refcount_adj
+{
        int i, j, unique;
        char hold_rm[ROOMNAMELEN];
        struct cdbdata *cdbfr;
@@ -2383,8 +2383,9 @@ int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newms
        int num_msgs_to_be_merged = 0;
 
        CtdlLogPrintf(CTDL_DEBUG,
-               "CtdlSaveMsgPointersInRoom(room=%s, num_msgs=%d, repl=%d)\n",
-               roomname, num_newmsgs, do_repl_check);
+               "CtdlSaveMsgPointersInRoom(room=%s, num_msgs=%d, repl=%d, suppress_rca=%d)\n",
+               roomname, num_newmsgs, do_repl_check, suppress_refcount_adj
+       );
 
        strcpy(hold_rm, CC->room.QRname);
 
@@ -2505,8 +2506,10 @@ int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newms
        CtdlGetRoom(&CC->room, hold_rm);
 
        /* Bump the reference count for all messages which were merged */
-       for (i=0; i<num_msgs_to_be_merged; ++i) {
-               AdjRefCount(msgs_to_be_merged[i], +1);
+       if (!suppress_refcount_adj) {
+               for (i=0; i<num_msgs_to_be_merged; ++i) {
+                       AdjRefCount(msgs_to_be_merged[i], +1);
+               }
        }
 
        /* Free up memory... */
@@ -2526,7 +2529,7 @@ int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newms
 int CtdlSaveMsgPointerInRoom(char *roomname, long msgid,
                        int do_repl_check, struct CtdlMessage *supplied_msg)
 {
-       return CtdlSaveMsgPointersInRoom(roomname, &msgid, 1, do_repl_check, supplied_msg);
+       return CtdlSaveMsgPointersInRoom(roomname, &msgid, 1, do_repl_check, supplied_msg, 0);
 }
 
 
@@ -4402,7 +4405,7 @@ void cmd_move(char *args)
        /*
         * Do the copy
         */
-       err = CtdlSaveMsgPointersInRoom(targ, msgs, num_msgs, 1, NULL);
+       err = CtdlSaveMsgPointersInRoom(targ, msgs, num_msgs, 1, NULL, 0);
        if (err != 0) {
                cprintf("%d Cannot store message(s) in %s: error %d\n",
                        err, targ, err);
@@ -4476,6 +4479,10 @@ void AdjRefCount(long msgnum, int incr)
        struct arcq new_arcq;
        int rv = 0;
 
+       CtdlLogPrintf(CTDL_DEBUG, "AdjRefCount() msg %ld ref count delta %+d\n",
+               msgnum, incr
+       );
+
        begin_critical_section(S_SUPPMSGMAIN);
        if (arcfp == NULL) {
                arcfp = fopen(file_arcq, "ab+");
@@ -4589,8 +4596,9 @@ void TDAP_AdjRefCount(long msgnum, int incr)
        smi.meta_refcount += incr;
        PutMetaData(&smi);
        end_critical_section(S_SUPPMSGMAIN);
-       CtdlLogPrintf(CTDL_DEBUG, "msg %ld ref count delta %+d, is now %d\n",
-               msgnum, incr, smi.meta_refcount);
+       CtdlLogPrintf(CTDL_DEBUG, "TDAP_AdjRefCount() msg %ld ref count delta %+d, is now %d\n",
+               msgnum, incr, smi.meta_refcount
+       );
 
        /* If the reference count is now zero, delete the message
         * (and its supplementary record as well).
index 31a0e520f39b9374198caf07793b8ca4fd2b8807..0917f1978a526115023728a0c601de053b36d741 100644 (file)
@@ -144,7 +144,7 @@ void dump_message(struct CtdlMessage *msg, long Siz);
 int is_valid_message(struct CtdlMessage *);
 void ReplicationChecks(struct CtdlMessage *);
 int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newmsgs,
-                               int do_repl_check, struct CtdlMessage *supplied_msg);
+                       int do_repl_check, struct CtdlMessage *supplied_msg, int suppress_refcount_adj);
 int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int do_repl_check, struct CtdlMessage *msg);
 char *CtdlReadMessageBody(char *terminator, long tlen, size_t maxlen, char *exist, int crlf, int *sock);
 StrBuf *CtdlReadMessageBodyBuf(char *terminator,       /* token signalling EOT */
index 8ea8fd633e97a7273530a86595992a6c63efd78e..097a9034b93b276e6e3da007cfafbcd7b0943308 100644 (file)
@@ -3,6 +3,21 @@
  *
  * Command-line utility to transmit a server command.
  *
+ * Copyright (c) 1987-2010 by the citadel.org team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "ctdl_module.h"
@@ -166,9 +181,6 @@ void sendcommand_die(void) {
 
 
 
-/*
- * main
- */
 int main(int argc, char **argv)
 {
        int a;
@@ -182,7 +194,7 @@ int main(int argc, char **argv)
        char ctdldir[PATH_MAX]=CTDLDIR;
        fd_set read_fd;
        struct timeval tv;
-       int ret, err;
+       int ret;
        int server_shutting_down = 0;
        
        strcpy(ctdl_home_directory, DEFAULT_PORT);
@@ -265,14 +277,10 @@ int main(int argc, char **argv)
                        FD_ZERO(&read_fd);
                        FD_SET(ipc->sock, &read_fd);
                        ret = select(ipc->sock+1, &read_fd, NULL, NULL,  &tv);
-                       err = errno;
-                       if (err!=0)
-                               printf("select failed: %d", err);
-
                        if (ret == -1) {
                                if (!(errno == EINTR || errno == EAGAIN))
-                                       printf("select failed: %d", err);
-                               return 1;
+                                       fprintf(stderr, "select() failed: %s", strerror(errno));
+                               return(1);
                        }
 
                        if (ret != 0) {
@@ -283,7 +291,7 @@ int main(int argc, char **argv)
                                n = read(ipc->sock, rbuf, SIZ);
                                if (n>0) {
                                        rbuf[n]='\0';
-                                       fprintf (stderr, rbuf);
+                                       fprintf(stderr, rbuf);
                                        fflush (stdout);
                                }
                        }