Removed race condition from CheckIfAlreadySeen()
[citadel.git] / citadel / msgbase.c
index 88b21f5ad91fad6db0d4645fca428f3ce3d46ea5..7e66e4a870b1f2a8deb66c66615a4cbe39765264 100644 (file)
@@ -3091,70 +3091,6 @@ long quickie_message(const char *from,
 }
 
 
-void flood_protect_quickie_message(const char *from,
-                                  const char *fromaddr,
-                                  const char *to,
-                                  char *room,
-                                  const char *text, 
-                                  int format_type,
-                                  const char *subject,
-                                  int nCriterions,
-                                  const char **CritStr,
-                                  const long *CritStrLen,
-                                  long ccid,
-                                  long ioid,
-                                  time_t NOW)
-{
-       int i;
-       u_char rawdigest[MD5_DIGEST_LEN];
-       struct MD5Context md5context;
-       StrBuf *guid;
-       char timestamp[64];
-       long tslen;
-       static const time_t tsday = (8*60*60); /* just care for a day... */
-       time_t seenstamp;
-
-       tslen = snprintf(timestamp, sizeof(timestamp), "%ld", tsday);
-       MD5Init(&md5context);
-
-       for (i = 0; i < nCriterions; i++)
-               MD5Update(&md5context,
-                         (const unsigned char*)CritStr[i], CritStrLen[i]);
-       MD5Update(&md5context,
-                 (const unsigned char*)timestamp, tslen);
-       MD5Final(rawdigest, &md5context);
-
-       guid = NewStrBufPlain(NULL,
-                             MD5_DIGEST_LEN * 2 + 12);
-       StrBufHexEscAppend(guid, NULL, rawdigest, MD5_DIGEST_LEN);
-       StrBufAppendBufPlain(guid, HKEY("_fldpt"), 0);
-       if (StrLength(guid) > 40)
-               StrBufCutAt(guid, 40, NULL);
-
-       seenstamp = CheckIfAlreadySeen(guid, NOW, tsday, eUpdate);
-       if ((seenstamp > 0) && (seenstamp < tsday))
-       {
-               FreeStrBuf(&guid);
-               /* yes, we did. flood protection kicks in. */
-               syslog(LOG_DEBUG, "not sending message again - %ld < %ld \n", seenstamp, tsday);
-               return;
-       }
-       else
-       {
-               syslog(LOG_DEBUG, "sending message. %ld >= %ld", seenstamp, tsday);
-               FreeStrBuf(&guid);
-               /* no, this message isn't sent recently; go ahead. */
-               quickie_message(from,
-                               fromaddr,
-                               to,
-                               room,
-                               text, 
-                               format_type,
-                               subject);
-       }
-}
-
-
 /*
  * Back end function used by CtdlMakeMessage() and similar functions
  */