Hi there,

There were quite a few people who wrote to me about this particular 
crash these last few weeks; apparently what I uploaded to the tracker 
fixed only the non-SSL access.

So I finally installed an IMAPS server, and it did exhibit the crash, 
even when accessed locally. I tweaked the patch some more, and once 
again "it works for me" now ... But I am not sure how robust it is, esp. 
with truly remote servers.

Is anyone on this list both affected by the crash and brave enough to 
test the attached info file and associated patch, before I submit it to 
the tracker ?

Thanks,

  /v

-- 
Vincent Beffara
UMPA - ENS Lyon
46 Allée d'Italie
69364 LYON cedex 07
Tel: 04 72 72 85 25
Fax: 04 72 72 84 80
diff --git a/offlineimap/imapserver.py b/offlineimap/imapserver.py
index 4e37ece..2f0119e 100644
--- a/offlineimap/imapserver.py
+++ b/offlineimap/imapserver.py
@@ -23,6 +23,9 @@ from threading import *
 import thread, hmac, os
 import base64
 
+from StringIO import StringIO
+from platform import system
+
 try:
     # do we have a recent pykerberos?
     have_gss = False
@@ -60,10 +63,42 @@ class UsefulIMAP4(UsefulIMAPMixIn, imaplib.IMAP4):
     def open(self, host = '', port = imaplib.IMAP4_PORT):
         imaplibutil.new_open(self, host, port)
 
+    # This is a hack around Darwin's implementation of realloc() (which
+    # Python uses inside the socket code). On Darwin, we split the
+    # message into 100k chunks, which should be small enough - smaller
+    # might start seriously hurting performance ...
+
+    def read(self, size):
+        if system() == 'Darwin':
+            read = 0
+            io = StringIO()
+            while read < size:
+                data = self.file.read(min(size-read,100000))
+                read += len(data)
+                io.write(data)
+            return io.getvalue()
+        else:
+            return self.file.read(size)
+
 class UsefulIMAP4_SSL(UsefulIMAPMixIn, imaplibutil.WrappedIMAP4_SSL):
     def open(self, host = '', port = imaplib.IMAP4_SSL_PORT):
         imaplibutil.new_open_ssl(self, host, port)
 
+    # This is the same hack as above, to be used in the case of an SSL
+    # connexion.
+
+    def read(self, size):
+        if system() == 'Darwin':
+            read = 0
+            io = StringIO()
+            while read < size:
+                data = self.sslobj.read(min(size-read,100000))
+                read += len(data)
+                io.write(data)
+            return io.getvalue()
+        else:
+            return self.sslobj.read(size)
+
 class UsefulIMAP4_Tunnel(UsefulIMAPMixIn, imaplibutil.IMAP4_Tunnel): pass
 
 class IMAPServer:
Package: offlineimap
Version: 5.99.11
Revision: 2

Maintainer: Vincent Beffara <[EMAIL PROTECTED]>
HomePage: http://software.complete.org/offlineimap
License: GPL

Description: Mailbox synchronization tool

Source: mirror:debian:pool/main/o/%n/%n_%v.tar.gz
Source-MD5: 4a5369593ab386a9776f8a95e2cb9b6a

PatchFile: %n.patch
PatchFile-MD5: fe6e3025f632fdadf989f150625429bc

SourceDirectory: offlineimap

Depends: python25
BuildDepends: docbook-utils, fink (>= 0.24.12)

CompileScript: <<
%p/bin/python2.5 setup.py build
%p/bin/docbook2man offlineimap.sgml
%p/bin/docbook2man offlineimap.sgml
<<

InstallScript: <<
%p/bin/python2.5 setup.py install --prefix=%p --root=%d
mkdir -p %i/share/man/man1
cp offlineimap.1 %i/share/man/man1
<<

DocFiles: COPYING COPYRIGHT FAQ.html README UPGRADING offlineimap.conf* 
offlineimap.sgml
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Fink-devel mailing list
Fink-devel@lists.sourceforge.net
http://news.gmane.org/gmane.os.apple.fink.devel

Reply via email to