[haiku-commits] r36820 - haiku/trunk/src/servers/mail

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 15 May 2010 15:26:13 +0200 (CEST)

Author: axeld
Date: 2010-05-15 15:26:13 +0200 (Sat, 15 May 2010)
New Revision: 36820
Changeset: http://dev.haiku-os.org/changeset/36820/haiku
Ticket: http://dev.haiku-os.org/ticket/5899

Modified:
   haiku/trunk/src/servers/mail/main.cpp
Log:
* Possible work-around for #5899: if the index does not contain the correct
  information, the mail is no longer sent.


Modified: haiku/trunk/src/servers/mail/main.cpp
===================================================================
--- haiku/trunk/src/servers/mail/main.cpp       2010-05-15 12:40:59 UTC (rev 
36819)
+++ haiku/trunk/src/servers/mail/main.cpp       2010-05-15 13:26:13 UTC (rev 
36820)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx
+ * Copyright 2009-2010, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx
  * Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
  *
  * Distributed under the terms of the MIT License.
@@ -78,7 +78,9 @@
 
 private:
                        void                            
_UpdateAutoCheck(bigtime_t interval);
+                       bool                            _IsPending(BNode& 
entry) const;
 
+private:
                        BMessageRunner*         fAutoCheckRunner;
                        BMailSettings           fSettingsFile;
 
@@ -467,7 +469,7 @@
        BList list;
        GetInboundMailChains(&list);
 
-       RunChains(list,msg);
+       RunChains(list, msg);
 }
 
 
@@ -513,8 +515,13 @@
                                off_t size;
 
                                while (query.GetNextEntry(&entry) == B_OK) {
-                                       while (node.SetTo(&entry) == B_BUSY) 
snooze(100);
-                                       if 
(node.ReadAttr("MAIL:chain",B_INT32_TYPE,0,&chain,4) < B_OK)
+                                       while (node.SetTo(&entry) == B_BUSY)
+                                               snooze(1000);
+                                       if (!_IsPending(node))
+                                               continue;
+
+                                       if (node.ReadAttr("MAIL:chain", 
B_INT32_TYPE, 0, &chain, 4)
+                                                       < B_OK)
                                                chain = defaultChain;
                                        entry.GetPath(&path);
                                        node.GetSize(&size);
@@ -554,6 +561,9 @@
 
                                while (query.GetNextEntry(&entry) == B_OK) {
                                        node.SetTo(&entry);
+                                       if (!_IsPending(node))
+                                               continue;
+
                                        entry.GetPath(&path);
                                        node.GetSize(&size);
                                        ids += path.Path();
@@ -594,6 +604,20 @@
 }
 
 
+/*!    Work-around for a broken index that contains out-of-date information.
+*/
+bool
+MailDaemonApp::_IsPending(BNode& node) const
+{
+       int32 flags;
+       if (node.ReadAttr(B_MAIL_ATTR_FLAGS, B_INT32_TYPE, 0, &flags, 
sizeof(int32))
+                       != (ssize_t)sizeof(int32))
+               return false;
+
+       return (flags & B_MAIL_PENDING) != 0;
+}
+
+
 //     #pragma mark -
 
 


Other related posts:

  • » [haiku-commits] r36820 - haiku/trunk/src/servers/mail - axeld