Subject: | possible solution for select() timeouts in reading from SSL socket |
Date: | Sat, 21 Jun 2008 10:36:15 +0800 (CST) |
To: | bug-Mail-IMAPClient [...] rt.cpan.org |
From: | Renjie Guan <phota001 [...] yahoo.com.cn> |
Hi David or Mark,
I'm using Mail::IMAPClient v3.07 on Perl v5.10.0 on a Linux 2.6.24 box. I
encountered the same timeout problem as reported on CPAN
(http://rt.cpan.org/Public/Bug/Display.html?id=31655). On reading from SSL
socket, I see in the debug log that all the email body has been downloaded, but
the module waits indefinitely in select() from the socket to be ready to read,
and finally times out (in sub _read_line).
I found the following quote that might be useful to indicate the cause and help
to solve the problem (by "Rob Mueller" <robm@fastmail.fm>).
Show quoted text
> SSL sockets have some slightly strange features which can break
> existing code that relies on certain assumptions of regular sockets.
>
> The main one being that you might syswrite() or print() some data
> to send to the server, and be expecting a response, so you use a
> select() call on the file descriptor to wait for the server to
> respond. However because of the way SSL works, in fact, the SSL
> layer may want to do a "write" on the socket, not a read. The net
> result of this is that the other end never returns data, and your
> select() times out.
>
> The solutions are either:
> 1. Don't use select(), but that means timeouts are hard to do.
> 2. You need to use select() + non-blocking, and look for
> SSL_WANT_WRITE errors
I'm not capable enough myself to propose workable codes. But I think this piece
of information would be useful to improve the module.
Thanks
Renjie Guan
Show quoted text ___________________________________________________________
雅虎邮箱,您的终生邮箱!
http://cn.mail.yahoo.com/