Re: Perl syswrite and IO/SSL
Graham Barr <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.ldap |
|---|---|
| Message-ID | <[email protected]> |
On May 19, 2009, at 2:31 PM, Dale Moore wrote: > I am having a problem with LDAP.pm and wondering > if any other folks are experiencing similar problems. > > The problems are the result of code that was modified > in this patch > > http://git.goingon.net/?p=perl-ldap.git;a=commitdiff;h=8c6c9cfcb78adf229437507f2e8ffe86d15e712d > > There are some style issues that I don’t like about this patch. > - We do a length() call on each time through the loop rather than > once > - We do a substr call each time through the loop, which isnt > necessary > if we would instead use the offset parameter to syswrite > - No reference in where the number 15000 came from. > > But the patch appears to basically sound, even if it does offend my > sense > of asthetics. Patches welcome. > The only problem I am having is that after a successful > bind and several passes through this code, it starts to misbehave. > The calls to syswrite return the value 1 instead of the number of > bytes > in the buffer as I might have expected. > > The problem is > - The call to syswrite() of a buffer of several hundred bytes > always returns 1 > and not the number of the several hundred bytes as expected. > This causes the syswrite to be retried with a slightly smaller > buffer. > The remote server appears to receive the original request, and > responds > but subsequent writes of the smaller buffer confuse it and it > drops the connection. > - A system call trace of perl process reveals that it is calling > write() > with several hundred bytes, and it is succeeding in writing all > of the bytes, > NOT just 1 or a smaller number of bytes... Do you have the latest Net::SSLeay and IO::Socket::SSL installed ? When using SSL, the syswrite is effectively a call to Net::SSLeay::write_partial > I've tried judicious use of 'use bytes;' and a few other common > tricks. use bytes would not make a difference here. > If you'll look at the previous version, before this patch, you'll > see where > we only looked to see if syswrite returned zero or non-zero. Not > the actual > number of bytes. Which was a bug as syswrite does not guarantee to send all the data Graham. > If I tweak my private copy of LDAP.pm to assume that > syswrite returned what I was expecting, it works as expected, and > the client > and server successfully communicate for as long as expected. > > I've seen this problem with Perl 5.8.8 on Solaris 9, 10, and 32Bit > i386 Redhat Fc5. > If you've seen this problem, or similar problems, or have a strong > clue > as to what might be wrong, I'd appreciate your comments. > > Comments welcome, > >