From: Art Cancro Date: Fri, 27 Jan 2012 16:38:34 +0000 (-0500) Subject: Merge branch 'master' of ssh://git.citadel.org/appl/gitroot/citadel X-Git-Tag: v8.11~217 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=dbebe0b18421f635c0cded24c7194be47b03bc9d;hp=f927644354ef6b22db16a66d043ef42a056b82ee Merge branch 'master' of ssh://git.citadel.org/appl/gitroot/citadel --- diff --git a/citadel/modules/listsub/serv_listsub.c b/citadel/modules/listsub/serv_listsub.c index 19fe74ee6..495fc0f9a 100644 --- a/citadel/modules/listsub/serv_listsub.c +++ b/citadel/modules/listsub/serv_listsub.c @@ -379,18 +379,16 @@ void do_confirm(char *room, char *token) { int line_length; char buf[512]; char cmd[256]; - char email[256]; + char email[256] = ""; char subtype[128]; int success = 0; - char address_to_unsubscribe[256]; + char address_to_unsubscribe[256] = ""; char scancmd[256]; char scanemail[256]; char *holdbuf = NULL; int linelen = 0; int buflen = 0; - strcpy(address_to_unsubscribe, ""); - if (CtdlGetRoom(&qrbuf, room) != 0) { cprintf("%d There is no list called '%s'\n", ERROR + ROOM_NOT_FOUND, room); diff --git a/citadel/modules/network/serv_network.c b/citadel/modules/network/serv_network.c index 599b90d1d..ba87cca5e 100644 --- a/citadel/modules/network/serv_network.c +++ b/citadel/modules/network/serv_network.c @@ -112,7 +112,7 @@ int GetNetworkedRoomNumbers(const char *DirName, HashList *DirList) struct dirent *d; struct dirent *filedir_entry; long RoomNR; - long Count; + long Count = 0; filedir = opendir (DirName); if (filedir == NULL) { @@ -306,7 +306,7 @@ void network_queue_interesting_rooms(struct ctdlroom *qrbuf, void *data) { ptr->namelen = ROOMNAMELEN - 1; memcpy (ptr->name, qrbuf->QRname, ptr->namelen); - ptr->name[ptr->namelen] = 0; + ptr->name[ptr->namelen] = '\0'; ptr->QRNum = qrbuf->QRnumber; for (i = 0; i < ptr->namelen; i++) @@ -314,6 +314,7 @@ void network_queue_interesting_rooms(struct ctdlroom *qrbuf, void *data) { ptr->lcname[i] = tolower(ptr->name[i]); } + ptr->lcname[ptr->namelen] = '\0'; ptr->key = hashlittle(ptr->lcname, ptr->namelen, 9872345); ptr->next = RP->rplist; RP->rplist = ptr; @@ -334,15 +335,16 @@ void network_queue_room(struct ctdlroom *qrbuf, void *data) { ptr->namelen = ROOMNAMELEN - 1; memcpy (ptr->name, qrbuf->QRname, ptr->namelen); - ptr->name[ptr->namelen] = 0; + ptr->name[ptr->namelen] = '\0'; ptr->QRNum = qrbuf->QRnumber; for (i = 0; i < ptr->namelen; i++) { ptr->lcname[i] = tolower(ptr->name[i]); } - + ptr->lcname[ptr->namelen] = '\0'; ptr->key = hashlittle(ptr->lcname, ptr->namelen, 9872345); + begin_critical_section(S_RPLIST); ptr->next = rplist; rplist = ptr; @@ -524,7 +526,8 @@ void network_do_queue(void) { end_critical_section(S_RPLIST); RL.RoomsInterestedIn = NewHash(1, lFlathash); - if (!GetNetworkedRoomNumbers(ctdl_netcfg_dir, RL.RoomsInterestedIn)) + if (full_processing && + (GetNetworkedRoomNumbers(ctdl_netcfg_dir, RL.RoomsInterestedIn)==0)) { doing_queue = 0; DeleteHash(&RL.RoomsInterestedIn); diff --git a/citadel/modules/network/serv_networkclient.c b/citadel/modules/network/serv_networkclient.c index 190121a98..24e354a5c 100644 --- a/citadel/modules/network/serv_networkclient.c +++ b/citadel/modules/network/serv_networkclient.c @@ -437,6 +437,7 @@ eNextState NWC_SendNUOP(AsyncNetworker *NW) NW->State = eQUIT; rc = NWC_SendQUIT(NW); NWC_DBG_SEND(); + return rc; } if (fstat(fd, &statbuf) == -1) { diff --git a/citadel/modules/smtp/serv_smtpeventclient.c b/citadel/modules/smtp/serv_smtpeventclient.c index b38320d2a..518c00a33 100644 --- a/citadel/modules/smtp/serv_smtpeventclient.c +++ b/citadel/modules/smtp/serv_smtpeventclient.c @@ -627,6 +627,7 @@ eNextState SMTP_C_Timeout(AsyncIO *IO) { SmtpOutMsg *pMsg = IO->Data; + pMsg->MyQEntry->Status = 4; EVS_syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__); StrBufPlain(IO->ErrMsg, CKEY(ReadErrors[pMsg->State])); return FailOneAttempt(IO); @@ -635,12 +636,15 @@ eNextState SMTP_C_ConnFail(AsyncIO *IO) { SmtpOutMsg *pMsg = IO->Data; + pMsg->MyQEntry->Status = 4; EVS_syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__); StrBufPlain(IO->ErrMsg, CKEY(ReadErrors[pMsg->State])); return FailOneAttempt(IO); } eNextState SMTP_C_DNSFail(AsyncIO *IO) { + SmtpOutMsg *pMsg = IO->Data; + pMsg->MyQEntry->Status = 4; EVS_syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__); return FailOneAttempt(IO); } diff --git a/citadel/modules/smtp/serv_smtpqueue.c b/citadel/modules/smtp/serv_smtpqueue.c index 3e20779a1..72b73bf1a 100644 --- a/citadel/modules/smtp/serv_smtpqueue.c +++ b/citadel/modules/smtp/serv_smtpqueue.c @@ -94,6 +94,7 @@ pthread_mutex_t ActiveQItemsLock; HashList *ActiveQItems = NULL; HashList *QItemHandlers = NULL; +static const long MaxRetry = SMTP_RETRY_INTERVAL * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2; int MsgCount = 0; int run_queue_now = 0; /* Set to 1 to ignore SMTP send retry times */ @@ -217,7 +218,7 @@ OneQueItem *DeserializeQueueItem(StrBuf *RawQItem, long QueMsgID) Item = (OneQueItem*)malloc(sizeof(OneQueItem)); memset(Item, 0, sizeof(OneQueItem)); - Item->LastAttempt.retry = SMTP_RETRY_INTERVAL; + Item->Retry = SMTP_RETRY_INTERVAL; Item->MessageID = -1; Item->QueMsgID = QueMsgID; @@ -240,6 +241,9 @@ OneQueItem *DeserializeQueueItem(StrBuf *RawQItem, long QueMsgID) FreeStrBuf(&Line); FreeStrBuf(&Token); + if (Item->Retry >= MaxRetry) + Item->FailNow = 1; + pthread_mutex_lock(&ActiveQItemsLock); if (GetHash(ActiveQItems, LKEY(Item->MessageID), @@ -289,30 +293,24 @@ StrBuf *SerializeQueueItem(OneQueItem *MyQItem) StrBufAppendBuf(QMessage, MyQItem->EnvelopeFrom, 0); } + StrBufAppendBufPlain(QMessage, HKEY("\nretry|"), 0); + StrBufAppendPrintf(QMessage, "%ld", + MyQItem->Retry); + + StrBufAppendBufPlain(QMessage, HKEY("\nattempted|"), 0); + StrBufAppendPrintf(QMessage, "%ld", + MyQItem->ReattemptWhen); + It = GetNewHashPos(MyQItem->MailQEntries, 0); while (GetNextHashPos(MyQItem->MailQEntries, It, &len, &Key, &vQE)) { MailQEntry *ThisItem = vQE; - int i; if (!ThisItem->Active) { /* skip already sent ones from the spoolfile. */ continue; } - - for (i=0; i < ThisItem->nAttempts; i++) { - /* TODO: most probably - * there is just one retry/attempted per message! - */ - StrBufAppendBufPlain(QMessage, HKEY("\nretry|"), 0); - StrBufAppendPrintf(QMessage, "%ld", - ThisItem->Attempts[i].retry); - - StrBufAppendBufPlain(QMessage, HKEY("\nattempted|"), 0); - StrBufAppendPrintf(QMessage, "%ld", - ThisItem->Attempts[i].when); - } StrBufAppendBufPlain(QMessage, HKEY("\nremote|"), 0); StrBufAppendBuf(QMessage, ThisItem->Recipient, 0); StrBufAppendBufPlain(QMessage, HKEY("|"), 0); @@ -378,16 +376,9 @@ void QItem_Handle_Recipient(OneQueItem *Item, StrBuf *Line, const char **Pos) void QItem_Handle_retry(OneQueItem *Item, StrBuf *Line, const char **Pos) { - if (Item->Current == NULL) - NewMailQEntry(Item); - if (Item->Current->Attempts[Item->Current->nAttempts].retry != 0) - Item->Current->nAttempts++; - if (Item->Current->nAttempts > MaxAttempts) { - Item->FailNow = 1; - return; - } - Item->Current->Attempts[Item->Current->nAttempts].retry = + Item->Retry = StrBufExtractNext_int(Line, Pos, '|'); + Item->Retry *= 2; } @@ -399,31 +390,7 @@ void QItem_Handle_Submitted(OneQueItem *Item, StrBuf *Line, const char **Pos) void QItem_Handle_Attempted(OneQueItem *Item, StrBuf *Line, const char **Pos) { - if (Item->Current == NULL) - NewMailQEntry(Item); - if (Item->Current->Attempts[Item->Current->nAttempts].when != 0) - Item->Current->nAttempts++; - if (Item->Current->nAttempts > MaxAttempts) { - Item->FailNow = 1; - return; - } - - Item->Current->Attempts[Item->Current->nAttempts].when = - StrBufExtractNext_int(Line, Pos, '|'); - if (Item->Current->Attempts[Item->Current->nAttempts].when > - Item->LastAttempt.when) - { - Item->LastAttempt.when = - Item->Current->Attempts[Item->Current->nAttempts].when; - - Item->LastAttempt.retry = - Item->Current->Attempts[ - Item->Current->nAttempts - ].retry * 2; - - if (Item->LastAttempt.retry > SMTP_RETRY_MAX) - Item->LastAttempt.retry = SMTP_RETRY_MAX; - } + Item->ReattemptWhen = StrBufExtractNext_int(Line, Pos, '|'); } @@ -694,8 +661,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) { /* * Postpone delivery if we've already tried recently. */ - if (((time(NULL) - MyQItem->LastAttempt.when) < - MyQItem->LastAttempt.retry) && + if (((time(NULL) - MyQItem->ReattemptWhen) > 0) && (run_queue_now == 0)) { syslog(LOG_DEBUG, "SMTP client: Retry time not yet reached.\n"); diff --git a/citadel/modules/smtp/smtpqueue.h b/citadel/modules/smtp/smtpqueue.h index 12b2ad387..97b76e790 100644 --- a/citadel/modules/smtp/smtpqueue.h +++ b/citadel/modules/smtp/smtpqueue.h @@ -21,17 +21,9 @@ /* SMTP CLIENT (Queue Management) STUFF */ /*****************************************************************************/ - - #define MaxAttempts 15 -typedef struct _delivery_attempt { - time_t when; - time_t retry; -}DeliveryAttempt; typedef struct _mailq_entry { - DeliveryAttempt Attempts[MaxAttempts]; - int nAttempts; StrBuf *Recipient; StrBuf *StatusMessage; int Status; @@ -58,7 +50,9 @@ typedef struct queueitem { * if null add a new one. */ MailQEntry *Current; - DeliveryAttempt LastAttempt; + time_t ReattemptWhen; + time_t Retry; + long ActiveDeliveries; StrBuf *EnvelopeFrom; StrBuf *BounceTo; diff --git a/webcit/debian/rules b/webcit/debian/rules index 12301764b..cd0a58efb 100755 --- a/webcit/debian/rules +++ b/webcit/debian/rules @@ -52,7 +52,7 @@ endif ifneq "$(wildcard /usr/share/misc/config.guess)" "" cp -f /usr/share/misc/config.guess config.guess endif - CC=$(COMPILER); exportCFLAGS=" -Wformat -Werror=format-security $(CFLAGS)" ./configure \ + export CC=$(COMPILER); export CFLAGS=" -Wformat -Werror=format-security $(CFLAGS)"; ./configure \ --host=$(DEB_HOST_GNU_TYPE) \ --build=$(DEB_BUILD_GNU_TYPE) \ --prefix=/usr/sbin/ \ diff --git a/webcit/roomops.c b/webcit/roomops.c index 85e998bcb..b6fdaa8df 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -481,7 +481,7 @@ int SaveRoomAide(folder *Room) } -int GetCurrentRoomFlags(folder *Room) +int GetCurrentRoomFlags(folder *Room, int CareForStatusMessage) { StrBuf *Buf; @@ -492,8 +492,10 @@ int GetCurrentRoomFlags(folder *Room) FlushStrBuf(Room->XAPass); FlushStrBuf(Room->Directory); StrBufCutLeft(Buf, 4); - AppendImportantMessage (SKEY(Buf)); + if (CareForStatusMessage) + AppendImportantMessage (SKEY(Buf)); FreeStrBuf(&Buf); + Room->XALoaded = 2; return 0; } else { const char *Pos; @@ -560,10 +562,10 @@ void LoadRoomXA (void) { wcsession *WCC = WC; - if (WCC->CurRoom.XALoaded) + if (WCC->CurRoom.XALoaded > 0) return; - GetCurrentRoomFlags(&WCC->CurRoom); + GetCurrentRoomFlags(&WCC->CurRoom, 0); } @@ -658,7 +660,7 @@ void LoadXRoomXCountFiles(void) void toggle_self_service(void) { wcsession *WCC = WC; - if (GetCurrentRoomFlags (&WCC->CurRoom) == 0) + if (GetCurrentRoomFlags (&WCC->CurRoom, 1) == 0) return; if (yesbstr("QR2_SelfList")) @@ -707,8 +709,10 @@ void editroom(void) http_transmit_thing(ChrPtr(do_template("room_edit")), 0); return; } - if (GetCurrentRoomFlags (&WCC->CurRoom) == 0) + if (GetCurrentRoomFlags (&WCC->CurRoom, 1) == 0) { + http_transmit_thing(ChrPtr(do_template("room_edit")), 0); return; + } LoadRoomAide(); @@ -849,7 +853,7 @@ void do_invt_kick(void) wcsession *WCC = WC; - if (GetCurrentRoomFlags(&WCC->CurRoom) == 1) + if (GetCurrentRoomFlags(&WCC->CurRoom, 1) == 1) { const char *Pos; UserNames = sbstr("username"); diff --git a/webcit/roomtokens.c b/webcit/roomtokens.c index d41b36af1..21b8cc4a3 100644 --- a/webcit/roomtokens.c +++ b/webcit/roomtokens.c @@ -266,6 +266,15 @@ int ConditionalRoomIsInbox(StrBuf *Target, WCTemplputParams *TP) /****** Properties ******/ +int ConditionalRoom_MayEdit(StrBuf *Target, WCTemplputParams *TP) +{ + wcsession *WCC = WC; + + LoadRoomXA (); + + return WCC->CurRoom.XALoaded == 1; +} + int ConditionalThisRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP) { long QR_CheckFlag; @@ -613,6 +622,7 @@ InitModule_ROOMTOKENS /****** Properties ******/ RegisterNamespace("ROOM:INFO:QRFLAGS", 0, 1, tmplput_ROOM_QRFLAGS, NULL, CTX_ROOMS); RegisterConditional(HKEY("COND:THISROOM:FLAG:QR"), 0, ConditionalThisRoomHas_QRFlag, CTX_NONE); + RegisterConditional(HKEY("COND:THISROOM:EDIT"), 0, ConditionalRoom_MayEdit, CTX_NONE); RegisterConditional(HKEY("COND:ROOM:FLAG:QR"), 0, ConditionalRoomHas_QRFlag, CTX_ROOMS); RegisterConditional(HKEY("COND:THISROOM:FLAG:QR2"), 0, ConditionalThisRoomHas_QRFlag2, CTX_NONE); diff --git a/webcit/serv_func.c b/webcit/serv_func.c index 71d5d57da..873a3ffde 100644 --- a/webcit/serv_func.c +++ b/webcit/serv_func.c @@ -172,6 +172,7 @@ int GetConnected (void) WCC->serv_sock = tcp_connectsock(ctdlhost, ctdlport); if (WCC->serv_sock < 0) { + WCC->connected = 0; FreeStrBuf(&WCC->ReadBuf); return 1; } diff --git a/webcit/static/t/room/edit/tab_access.html b/webcit/static/t/room/edit/tab_access.html index 3048972f4..8cad949fe 100644 --- a/webcit/static/t/room/edit/tab_access.html +++ b/webcit/static/t/room/edit/tab_access.html @@ -1,4 +1,4 @@ -
+
@@ -39,3 +39,4 @@
+
diff --git a/webcit/static/t/room/edit/tab_config.html b/webcit/static/t/room/edit/tab_config.html index 0a6891c4a..7c45b6ec7 100644 --- a/webcit/static/t/room/edit/tab_config.html +++ b/webcit/static/t/room/edit/tab_config.html @@ -1,4 +1,4 @@ -
+
    @@ -146,3 +146,4 @@
+
diff --git a/webcit/static/t/room/edit/tab_expire.html b/webcit/static/t/room/edit/tab_expire.html index dc4e61c21..fb958151b 100644 --- a/webcit/static/t/room/edit/tab_expire.html +++ b/webcit/static/t/room/edit/tab_expire.html @@ -1,4 +1,4 @@ -
+

@@ -69,3 +69,4 @@
+
diff --git a/webcit/tcp_sockets.c b/webcit/tcp_sockets.c index 735899dbe..9952fd9ab 100644 --- a/webcit/tcp_sockets.c +++ b/webcit/tcp_sockets.c @@ -911,10 +911,12 @@ SessionDestroyModule_TCPSOCKETS { FreeStrBuf(&sess->CLineBuf); FreeStrBuf(&sess->ReadBuf); + sess->connected = 0; sess->ReadPos = NULL; FreeStrBuf(&sess->MigrateReadLineBuf); if (sess->serv_sock > 0) { syslog(LOG_DEBUG, "Closing socket %d", sess->serv_sock); close(sess->serv_sock); } + sess->serv_sock = -1; } diff --git a/webcit/webcit.c b/webcit/webcit.c index 94ff1e22e..944b457c8 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -31,7 +31,7 @@ StrBuf *csslocal = NULL; HashList *HandlerHash = NULL; void stuff_to_cookie(int unset_cookie); -int GetConnected(void); +extern int GetConnected(void); void PutRequestLocalMem(void *Data, DeleteHashDataFunc DeleteIt)