Overview
Features
Download
Documentation
Community
Add-Ons & Services

Poco::StreamCopier::copyStream loops forever

Please post support and help requests here.

Poco::StreamCopier::copyStream loops forever

Postby saka » 12 May 2007, 08:20

I've been using poco with some extensions to send and receive emails (pop and smtp) with SSL - sometimes -the following code (far from complete) hangs and just consumes all the available memory. I believe there is something with the MultipartReader but have not been able to figure that one out. Any suggestions....

I've been using a mailbox with 400 messages totaling 80 mb to test and sometimes I can download everything and sometimes not - it does not hang on any particular message.

...

MailInputStream mis(sis);

MultipartReader reader(mis, boundary);

strstream strstr;

StreamCopier::copyStream(reader.stream(), strstr);


saka
 
Posts: 4
Joined: 19 Sep 2006, 16:52

Re: Poco::StreamCopier::copyStream loops forever

Postby saka » 12 May 2007, 08:24

Sorry I forgot to mention I'm using the trunk at revision 279 (with som local mods...)
saka
 
Posts: 4
Joined: 19 Sep 2006, 16:52

Re: Poco::StreamCopier::copyStream loops forever

Postby peter » 14 May 2007, 07:41

Does this happen without ssl too?

br
Peter

> I've been using poco with some extensions to send and receive emails (pop and smtp) with SSL - sometimes -the following code (far from complete) hangs and just consumes all the available memory. I believe there is something with the MultipartReader but have not been able to figure that one out. Any suggestions....
>
> I've been using a mailbox with 400 messages totaling 80 mb to test and sometimes I can download everything and sometimes not - it does not hang on any particular message.
>
> ...
>
> MailInputStream mis(sis);
>
> MultipartReader reader(mis, boundary);
>
> strstream strstr;
>
> StreamCopier::copyStream(reader.stream(), strstr);
>
>
>
peter
 
Posts: 67
Joined: 11 Jul 2006, 16:26
Location: Austria

Re: Poco::StreamCopier::copyStream loops forever

Postby saka » 14 May 2007, 16:33

Yes this happens both with and without ssl.

I found the problem in multipartstreamreader.cpp

int MultipartStreamBuf__readFromDevice(char* buffer, std::streamsize length)
{
poco_assert_dbg (length >= _boundary.length() + 6);

static const int eof = std::char_traits::eof();
int n = 0;
int ch = _istr.get();

the following line is missing after line 76

if (ch == eof) return -1;

or 0 whatever convention you like... it's a bit mixed in the readFromDevice methods... - I believe both will work. Otherwise we write junk in the buffer and we also loop forever...

excuse the formatting - I just cant get it to look nice in this forum...

/svante
saka
 
Posts: 4
Joined: 19 Sep 2006, 16:52

Re: Re: Poco::StreamCopier::copyStream loops forever

Postby guenter » 14 May 2007, 16:41

Thanks. I have filed a bug report on Sourceforge:
http://sourceforge.net/tracker/index.php?func=detail&aid=1718724&group_id=132964&atid=725709

The fix will be in 1.3.1.
guenter
 
Posts: 1165
Joined: 11 Jul 2006, 16:27
Location: Austria


Return to Support

Who is online

Users browsing this forum: No registered users and 2 guests