public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Transient fetchmail corruption problem under Windows 2000
@ 2001-08-07  8:31 Jason Tishler
  2001-08-07  8:38 ` Olaf Foellinger
  2001-08-07 15:07 ` Scott Brim
  0 siblings, 2 replies; 12+ messages in thread
From: Jason Tishler @ 2001-08-07  8:31 UTC (permalink / raw)
  To: Cygwin

[I normally would not post such a vague bug report but since this problem
significantly impacts my mail delivery I hope that I will be allowed some
latitude...]

I am using fetchmail/procmail/mutt to retrieve, process, and read my
email.  I recently changed from using a Windows NT 4.0 SP5 to a Windows
2000 SP1 machine.  Shortly thereafter, I started to notice that some
of the emails that I received with binary attachments were corrupted.

After sending the same message to myself repeatedly and examining the
raw message in an mbox file, I began to see the following pattern.
The corrupted messages are always larger than they should be and there
are chunks of garbage characters in them.  Sometimes the MIME separators
are repeated as if fetchmail shuttered when writing to down the pipe to
procmail (this is probably just a special case of the garbage characters).

Not all messages get corrupted.  A little more half were corrupted --
the others were fine.  I also POP-ed directly into the mail server and
verified that the messages were not corrupt and only became so when I
used fetchmail to retrieve them.

I tried various versions of fetchmail (5.8.12, 5.8.14, 5.8.16) and
Cygwin (1.3.2, my CVS build, latest snapshot).  All exhibit the same
transient binary attachment corruption problem.

When I repeat the same experiments on my old Windows NT 4.0 SP5 machine,
I have not received any corrupted email (yet).

Is anyone using fetchmail under Windows 2000?  If so, are you experience
any problems?

I'm starting to slog through the fetchmail code, straces, and debugging
with gdb.  If anyone has any ideas on the best way to debug this problem
or whether the problem is in fetchmail or Cygwin, I would love to hear
them.

Thanks,
Jason

-- 
Jason Tishler
Director, Software Engineering       Phone: 732.264.8770 x235
Dot Hill Systems Corp.               Fax:   732.264.8798
82 Bethany Road, Suite 7             Email: jason@tishler.net
Hazlet, NJ 07730 USA                 WWW:   http://www.dothill.com

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Transient fetchmail corruption problem under Windows 2000
  2001-08-07  8:31 Transient fetchmail corruption problem under Windows 2000 Jason Tishler
@ 2001-08-07  8:38 ` Olaf Foellinger
  2001-08-07 12:23   ` Gerrit P. Haase
  2001-08-07 15:07 ` Scott Brim
  1 sibling, 1 reply; 12+ messages in thread
From: Olaf Foellinger @ 2001-08-07  8:38 UTC (permalink / raw)
  To: Cygwin

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2105 bytes --]

On Tue, Aug 07, 2001 at 11:31:10AM -0400, Jason Tishler wrote:
> [I normally would not post such a vague bug report but since this problem
> significantly impacts my mail delivery I hope that I will be allowed some
> latitude...]
> 
> I am using fetchmail/procmail/mutt to retrieve, process, and read my
> email.  I recently changed from using a Windows NT 4.0 SP5 to a Windows
> 2000 SP1 machine.  Shortly thereafter, I started to notice that some
> of the emails that I received with binary attachments were corrupted.
> 
> After sending the same message to myself repeatedly and examining the
> raw message in an mbox file, I began to see the following pattern.
> The corrupted messages are always larger than they should be and there
> are chunks of garbage characters in them.  Sometimes the MIME separators
> are repeated as if fetchmail shuttered when writing to down the pipe to
> procmail (this is probably just a special case of the garbage characters).
> 
> Not all messages get corrupted.  A little more half were corrupted --
> the others were fine.  I also POP-ed directly into the mail server and
> verified that the messages were not corrupt and only became so when I
> used fetchmail to retrieve them.
> 
> I tried various versions of fetchmail (5.8.12, 5.8.14, 5.8.16) and
> Cygwin (1.3.2, my CVS build, latest snapshot).  All exhibit the same
> transient binary attachment corruption problem.
> 
> When I repeat the same experiments on my old Windows NT 4.0 SP5 machine,
> I have not received any corrupted email (yet).
> 
> Is anyone using fetchmail under Windows 2000?  If so, are you experience
> any problems?

I don't use fetchmail, but with mutt and ssmtp all my sent binary
attachments get corrupted on W2000SP1. Don't know why, didn't try it
under NT.


Gruss Olaf

--
Olaf Föllinger
S.E.S.A. AG GS Berlin
mail: Olaf.Foellinger@sesa.de
fon:  +49-30-390722291

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Transient fetchmail corruption problem under Windows 2000
  2001-08-07  8:38 ` Olaf Foellinger
@ 2001-08-07 12:23   ` Gerrit P. Haase
  2001-08-07 13:10     ` Jason Tishler
  2001-08-09  8:07     ` Olaf Foellinger
  0 siblings, 2 replies; 12+ messages in thread
From: Gerrit P. Haase @ 2001-08-07 12:23 UTC (permalink / raw)
  To: Cygwin; +Cc: Olaf Foellinger, Jason Tishler

Am 7 Aug 2001, um 15:39 hat Olaf Foellinger geschrieben:

> On Tue, Aug 07, 2001 at 11:31:10AM -0400, Jason Tishler wrote:
> > [I normally would not post such a vague bug report but since this
> > problem significantly impacts my mail delivery I hope that I will be
> > allowed some latitude...]
> > 
> > I am using fetchmail/procmail/mutt to retrieve, process, and read my
> > email.  I recently changed from using a Windows NT 4.0 SP5 to a
> > Windows 2000 SP1 machine.  Shortly thereafter, I started to notice
> > that some of the emails that I received with binary attachments were
> > corrupted.

What are the types of the binary attachments?
Is it various or are there only some files corrupted or are all 
attachments destroyed?

> > After sending the same message to myself repeatedly and examining
> > the raw message in an mbox file, I began to see the following
> > pattern. The corrupted messages are always larger than they should
> > be and there are chunks of garbage characters in them.  Sometimes
> > the MIME separators are repeated as if fetchmail shuttered when
> > writing to down the pipe to procmail (this is probably just a
> > special case of the garbage characters).
> > 
> > Not all messages get corrupted.  A little more half were corrupted
> > -- the others were fine.  I also POP-ed directly into the mail
> > server and verified that the messages were not corrupt and only
> > became so when I used fetchmail to retrieve them.
> > 
> > I tried various versions of fetchmail (5.8.12, 5.8.14, 5.8.16) and
> > Cygwin (1.3.2, my CVS build, latest snapshot).  All exhibit the same
> > transient binary attachment corruption problem.
> > 
> > When I repeat the same experiments on my old Windows NT 4.0 SP5
> > machine, I have not received any corrupted email (yet).
> > 
> > Is anyone using fetchmail under Windows 2000?  If so, are you
> > experience any problems?
> 
> I don't use fetchmail, but with mutt and ssmtp all my sent binary
> attachments get corrupted on W2000SP1. Don't know why, didn't try it
> under NT.

Sorry, I don't know enough to help you out of this misere since i 
never used procmail, but io have some more questions.
Jason, do you use also use ssmtp as Olaf mentioned?
Anyway, since it only happens on NT5 and not on NT4 as you reported,
it seems not to be a problem with Fetchmail. Since Fetchmail does 
nothing else but retrieve and send out to a smtp server i could not 
think of big problems with this. Or is it an option to pipe directly 
from fetchmail to procmail?
Are the files stored to disk between retrieving and sending out?
Does Procmail store to disk before delivering?
Are your mounts of binary type?

Please report if you track down the source of the problems, maybe a 
problem with the pipes?

Olaf could you please report exactely what you do to send out a 
corrupt message? Is it a known issue? I never heard before of 
problems with mailing through ssmtp on win2k.
I will try tomorrow to send some mail with ssmtp and binaries 
attached.

Gerrit


-- 
=^..^=

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Transient fetchmail corruption problem under Windows 2000
  2001-08-07 12:23   ` Gerrit P. Haase
@ 2001-08-07 13:10     ` Jason Tishler
  2001-08-08 14:26       ` Gerrit P. Haase
  2001-08-08 14:40       ` Gerrit P. Haase
  2001-08-09  8:07     ` Olaf Foellinger
  1 sibling, 2 replies; 12+ messages in thread
From: Jason Tishler @ 2001-08-07 13:10 UTC (permalink / raw)
  To: Gerrit P. Haase; +Cc: Cygwin, Olaf Foellinger

Gerrit,

[This message was received corrupted...  I have attached it for perusal
by the curious.]

On Tue, Aug 07, 2001 at 09:26:03PM +0100, Gerrit P. Haase wrote:
> What are the types of the binary attachments?

Actually, after further investigation it appears that even plain text
attachments are affected too.

> Is it various or are there only some files corrupted or are all 
> attachment

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Transient fetchmail corruption problem under Windows 2000
  2001-08-07  8:31 Transient fetchmail corruption problem under Windows 2000 Jason Tishler
  2001-08-07  8:38 ` Olaf Foellinger
@ 2001-08-07 15:07 ` Scott Brim
  1 sibling, 0 replies; 12+ messages in thread
From: Scott Brim @ 2001-08-07 15:07 UTC (permalink / raw)
  To: Cygwin

I had similar problems until I made sure everything used unix-style
linends and the spool file was ^M-clean.  What does fetchmail use for an
MTA?  If, e.g., you use a perl script, binmode lavishly.  I also have a
recent cygwin snapshot but I don't think that's critical.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Transient fetchmail corruption problem under Windows 2000
  2001-08-07 13:10     ` Jason Tishler
@ 2001-08-08 14:26       ` Gerrit P. Haase
  2001-08-08 14:40       ` Gerrit P. Haase
  1 sibling, 0 replies; 12+ messages in thread
From: Gerrit P. Haase @ 2001-08-08 14:26 UTC (permalink / raw)
  To: Cygwin

Am 7 Aug 2001, um 16:10 hat Jason Tishler geschrieben:

> Gerrit,
> 
> [This message was received corrupted...  I have attached it for
> perusal by the curious.]

Holla, this attached message looks really like garbage.

> On Tue, Aug 07, 2001 at 09:26:03PM +0100, Gerrit P. Haase wrote:
> > What are the types of the binary attachments?
> 
> Actually, after further investigation it appears that even plain text
> attachments are affected too.
> 
> > Is it various or are there only some files corrupted or are all
> > attachment
>             ^^
> 
> Note the null character above, this is part of the corruption.
> 
> If I send the same message (which includes an attachment) to myself
> repeatedly, most of the time to it is corrupted when fetched via POP
> by fetchmail.

And for this test sendings you used ssmtp?
Plus mutt?
But as you said, it is only a problem when retrieving via fetchmail,
i will try to install 'my' fetchmail version at my box, maybe in 
conjunction with procmail.
Really interesting, never tried before.

> > Are your mounts of binary type?
> 
> Yes.

Then that should be no problem.
 
> > Please report if you track down the source of the problems, maybe a
> > problem with the pipes?
> 
> After further experimentation, I believe that I have ruled out
> procmail as a potential culprit.  I replaced procmail with a shell
> script that just cats stdin to a file.  Even without procmail in the
> picture, I'm still getting corrupted messages.  Hence, the problem is
> with fetchmail (or Cygwin itself).

Hmmm, still there is piping...
I will test at my win2k workstation if there is a problem with pipes 
tomorrow.

> > Olaf could you please report exactely what you do to send out a
> > corrupt message? Is it a known issue? I never heard before of
> > problems with mailing through ssmtp on win2k. I will try tomorrow to
> > send some mail with ssmtp and binaries attached.
> 
> I have not had any problems sending email (without or with
> attachments) with ssmtp under Windows 2000.

How is a file attached to ssmtp?
Only via mutt?

gph


-- 
=^..^=

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Transient fetchmail corruption problem under Windows 2000
  2001-08-07 13:10     ` Jason Tishler
  2001-08-08 14:26       ` Gerrit P. Haase
@ 2001-08-08 14:40       ` Gerrit P. Haase
  2001-08-08 20:02         ` Jason Tishler
  2001-08-14  8:40         ` Transient fetchmail corruption problem under Windows 2000 Olaf Foellinger
  1 sibling, 2 replies; 12+ messages in thread
From: Gerrit P. Haase @ 2001-08-08 14:40 UTC (permalink / raw)
  To: Jason Tishler, Cygwin, Olaf Foellinger

Am 7 Aug 2001, um 16:10 hat Jason Tishler geschrieben:

Jason,

> [This message was received corrupted...  I have attached it for
> perusal by the curious.]

Some more comments:

I just send a binary to myself via mutt from the commandline here at 
my win98 box:

$ mutt -a 037.jpg -s test freeweb@nyckelpiga.de < test.msg 

As mailer for mutt i used ssmtp to my default mailhub.
Guess what, first try a hit, the jpeg is corrupted.
I looks like yopur attached email, it is ok at the beginning and the 
rest is garbage...not completely destroyed, but it's no longer a nice 
picture.

So it seems to be a problem with mutt or ssmtp (for me now), even on 
my win98 box, will try tomorrw with win2k box, too.

gph


-- 
=^..^=

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Transient fetchmail corruption problem under Windows 2000
  2001-08-08 14:40       ` Gerrit P. Haase
@ 2001-08-08 20:02         ` Jason Tishler
  2001-08-14 10:51           ` Winsock recv/WSARecv(..., MSG_PEEK) is unreliable (was Re: Transient fetchmail ...) Jason Tishler
  2001-08-14  8:40         ` Transient fetchmail corruption problem under Windows 2000 Olaf Foellinger
  1 sibling, 1 reply; 12+ messages in thread
From: Jason Tishler @ 2001-08-08 20:02 UTC (permalink / raw)
  To: Gerrit P. Haase; +Cc: Cygwin, Olaf Foellinger

Gerrit,

On Wed, Aug 08, 2001 at 11:42:41PM +0100, Gerrit P. Haase wrote:
> Am 7 Aug 2001, um 16:10 hat Jason Tishler geschrieben:
> > [This message was received corrupted...  I have attached it for
> > perusal by the curious.]
> 
> Some more comments:
> 
> I just send a binary to myself via mutt from the commandline here at 
> my win98 box:
> 
> $ mutt -a 037.jpg -s test freeweb@nyckelpiga.de < test.msg 
> 
> As mailer for mutt i used ssmtp to my default mailhub.
> Guess what, first try a hit, the jpeg is corrupted.
> I looks like yopur attached email, it is ok at the beginning and the 
> rest is garbage...not completely destroyed, but it's no longer a nice 
> picture.
> 
> So it seems to be a problem with mutt or ssmtp (for me now), even on 
> my win98 box, will try tomorrw with win2k box, too.

Thanks for trying to help me, it is much appreciated.  Unfortunately,
your problem seems to be similar to (or the same as) Olaf's.  Your
problem seems to be on the transmit side -- mine seems to be on the
receive side.

My standard test now is to send a multi-part but text/plain message from
my primary 2000 SP1 machines using mutt via ssmtp.  The message arrives
to my ISP's POP server uncorrupted.  If I retrieve it with mutt directly,
then it remains uncorrupted.  If I retrieve it with fetchmail on either
of my two 2000 SP1 machines, then it gets corrupted about 50% - 70%
of the times.  If I retrieve it with fetchmail on either my NT SP5 or
NT SP6a machine, then it remains uncorrupted.

To rule out mutt, I also sent a multi-part message from Netscape.  I got
the same results -- the problem followed fetchmail but only under 2000
SP1.

To rule out procmail, I replaced procmail with a shell script that just
cats stdin to a file.  I got the same results again.

So my hypothesis is that my problem is a bug in fetchmail or possibly in
Cygwin itself.  Now I just have to roll up my sleeves and find out where.
Hopefully, it is not between the keyboard and the chair...

Thanks,
Jason

-- 
Jason Tishler
Director, Software Engineering       Phone: 732.264.8770 x235
Dot Hill Systems Corp.               Fax:   732.264.8798
82 Bethany Road, Suite 7             Email: jason@tishler.net
Hazlet, NJ 07730 USA                 WWW:   http://www.dothill.com

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Transient fetchmail corruption problem under Windows 2000
  2001-08-07 12:23   ` Gerrit P. Haase
  2001-08-07 13:10     ` Jason Tishler
@ 2001-08-09  8:07     ` Olaf Foellinger
  2001-08-10 14:15       ` Gerrit P. Haase
  1 sibling, 1 reply; 12+ messages in thread
From: Olaf Foellinger @ 2001-08-09  8:07 UTC (permalink / raw)
  To: cygwin

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1504 bytes --]

On Tue, Aug 07, 2001 at 09:26:03PM +0100, Gerrit P. Haase wrote:
> Olaf could you please report exactely what you do to send out a 
> corrupt message? Is it a known issue? I never heard before of 
> problems with mailing through ssmtp on win2k.
> I will try tomorrow to send some mail with ssmtp and binaries 
> attached.

I use ssmtp with mutt to send out mails to our mailserver. 

set sendmail="/usr/sbin/ssmtp"  # how to deliver mail

It worked for a long time but for the last time it has problems with
binary attachments. As an example I've sent a zip-file and tried to
unzip it on our mailserver:

unzip sh.zip
Archive:  sh.zip
error [sh.zip]:  missing 2 bytes in zipfile
  (attempting to process anyway)
error [sh.zip]:  attempt to seek before beginning of zipfile
  (please check that you have transferred or created the zipfile in the
  appropriate BINARY mode and that you have compiled UnZip properly)
  (attempting to re-compensate)
  inflating: file.doc       bad CRC e3c50fe3  (should be
5d7c7b00)
file #2:  bad zipfile offset (local header sig):  36817
  (attempting to re-compensate)
file #2:  bad zipfile offset (local header sig):  36817

That's all I know. 


Gruss Olaf

--
Olaf Föllinger
S.E.S.A. AG GS Berlin
mail: Olaf.Foellinger@sesa.de
fon:  +49-30-390722291

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Transient fetchmail corruption problem under Windows 2000
  2001-08-09  8:07     ` Olaf Foellinger
@ 2001-08-10 14:15       ` Gerrit P. Haase
  0 siblings, 0 replies; 12+ messages in thread
From: Gerrit P. Haase @ 2001-08-10 14:15 UTC (permalink / raw)
  To: cygwin

Am 9 Aug 2001, um 15:08 hat Olaf Foellinger geschrieben:

> On Tue, Aug 07, 2001 at 09:26:03PM +0100, Gerrit P. Haase wrote:
> > Olaf could you please report exactely what you do to send out a
> > corrupt message? Is it a known issue? I never heard before of
> > problems with mailing through ssmtp on win2k. I will try tomorrow to
> > send some mail with ssmtp and binaries attached.
> 
> I use ssmtp with mutt to send out mails to our mailserver. 
> 
> set sendmail="/usr/sbin/ssmtp"  # how to deliver mail
> 
> It worked for a long time but for the last time it has problems with
> binary attachments. As an example I've sent a zip-file and tried to
> unzip it on our mailserver:

I got the same problems with binary attachments sent out this way 
from Win98, so i tend to think of a a problem with mutt or ssmtp.

Jason, 

would it be an option to use other software for all these tasks?
Have you ever tried to build xmailserver from http://xmailserver.org ?

It has support for Windows and Linux, it retrieves mail from pop3 
Server, it has strong filter mechanisms, it comes with a sendmail 
emulation, it is fast, a real MTA which MAY build at cygwin (i never 
tried since it builds OOTB with MSVS6 for me, so i have no need to 
try).

Ciao,

Gerrit



-- 
=^..^=

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Transient fetchmail corruption problem under Windows 2000
  2001-08-08 14:40       ` Gerrit P. Haase
  2001-08-08 20:02         ` Jason Tishler
@ 2001-08-14  8:40         ` Olaf Foellinger
  1 sibling, 0 replies; 12+ messages in thread
From: Olaf Foellinger @ 2001-08-14  8:40 UTC (permalink / raw)
  To: Cygwin

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1354 bytes --]

On Wed, Aug 08, 2001 at 11:42:41PM +0100, Gerrit P. Haase wrote:
> Am 7 Aug 2001, um 16:10 hat Jason Tishler geschrieben:
> 
> Jason,
> 
> > [This message was received corrupted...  I have attached it for
> > perusal by the curious.]
> 
> Some more comments:
> 
> I just send a binary to myself via mutt from the commandline here at 
> my win98 box:
> 
> $ mutt -a 037.jpg -s test freeweb@nyckelpiga.de < test.msg 
> 
> As mailer for mutt i used ssmtp to my default mailhub.
> Guess what, first try a hit, the jpeg is corrupted.
> I looks like yopur attached email, it is ok at the beginning and the 
> rest is garbage...not completely destroyed, but it's no longer a nice 
> picture.
> 
> So it seems to be a problem with mutt or ssmtp (for me now), even on 
> my win98 box, will try tomorrw with win2k box, too.

I've just replaced the cygwin ssmtp with that from unixmail
( http://sourceforge.net/projects/unixmail-w32/ ) and I can now send
binary attachments without problems. It seems that the cygwin ssmtp is
doing wrong.


Gruss Olaf

--
Olaf Föllinger
S.E.S.A. AG GS Berlin
mail: Olaf.Foellinger@sesa.de
fon:  +49-30-390722291

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Winsock recv/WSARecv(..., MSG_PEEK) is unreliable (was Re: Transient fetchmail ...)
  2001-08-08 20:02         ` Jason Tishler
@ 2001-08-14 10:51           ` Jason Tishler
  0 siblings, 0 replies; 12+ messages in thread
From: Jason Tishler @ 2001-08-14 10:51 UTC (permalink / raw)
  To: Gerrit P. Haase; +Cc: Cygwin

On Wed, Aug 08, 2001 at 11:01:00PM -0400, Jason Tishler wrote:
> Thanks for trying to help me, it is much appreciated.  Unfortunately,
> your problem seems to be similar to (or the same as) Olaf's.  Your
> problem seems to be on the transmit side -- mine seems to be on the
> receive side.

I believe that I have finally found the root cause to my transient
fetchmail corruption problems under Windows 2000.  From the following
MSDN articles, it appears the Winsock's recv/WSARecv(..., MSG_PEEK)
is inherently unreliable and strongly discouraged:
 
    http://support.microsoft.com/support/kb/articles/Q192/5/99.ASP
    http://support.microsoft.com/support/kb/articles/Q140/2/63.asp

The following fetchmail code is affected by the above:

    int SockRead(int sock, char *buf, int len)
    {
        char *bp = buf;
        ...
        do
        {
            ...
            if ((n = recv(sock, bp, len, MSG_PEEK)) <= 0)
                return (-1);
            if ((newline = memchr(bp, '\n', n)) != NULL)
                n = newline - bp + 1;           // *** [1] ***
            if ((n = read(sock, bp, n)) == -1)  // *** [2] ***
                return (-1);
            bp += n;
            ...
        }
        while (!newline && len);
        *bp = '\0';
        ...
    }

The number of bytes read in [2] is occasionally less than the number of
bytes requested as determined by [1].  This causes fetchmail to put null
characters in the wrong place and to read the same bytes more than once.
This is the source of the "corruption" that I have been experiencing
under 2000.  For some reason, this problem has not occurred (yet) under
NT 4.0 SP5/SP6a.

Is there any way to fix this in Cygwin?  Otherwise, other applications
that use MSG_PEEK may fail in similar ways.

The attached *ugly* patch to fetchmail works around this problem.  If
the MSG_PEEK problem cannot be fixed in Cygwin, then what is the best
way to solve this issue in fetchmail?  I see the following options:

1. Leverage off of existing BeOS specific code that does not use MSG_PEEK
but only reads one byte at a time.

2. Rework the ugly patch with __CYGWIN__ #ifdefs.

3. Rework SockRead() to not use MSG_PEEK, but instead "drain data
immediately upon arrival into application-allocated buffer space" as
suggested by the MSDN.

I guess that have I ordered the above in what I think is decreasing
chance of acceptance into fetchmail CVS.

Does anyone have any other, hopefully better, ideas?

Thanks,
Jason

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2001-08-14 10:51 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-07  8:31 Transient fetchmail corruption problem under Windows 2000 Jason Tishler
2001-08-07  8:38 ` Olaf Foellinger
2001-08-07 12:23   ` Gerrit P. Haase
2001-08-07 13:10     ` Jason Tishler
2001-08-08 14:26       ` Gerrit P. Haase
2001-08-08 14:40       ` Gerrit P. Haase
2001-08-08 20:02         ` Jason Tishler
2001-08-14 10:51           ` Winsock recv/WSARecv(..., MSG_PEEK) is unreliable (was Re: Transient fetchmail ...) Jason Tishler
2001-08-14  8:40         ` Transient fetchmail corruption problem under Windows 2000 Olaf Foellinger
2001-08-09  8:07     ` Olaf Foellinger
2001-08-10 14:15       ` Gerrit P. Haase
2001-08-07 15:07 ` Scott Brim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).