[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: (ITS#4606) Big LDAP Search responses causes IO error in libldap on Windows XP

Hm, on my Visual Studio6 errno.h does a
    #define errno *_errno()
and of course _errno() is an imported function. This problem "shouldn't 

In your patch, directly including <errno.h> should not be needed, since 
<ac/errno.h> will include it already. If <ac/errno.h> isn't bringing in 
<errno.h> for you then it appears you have a configure problem.

alexey.melnikov@isode.com wrote:
> Full_Name: Alexey Melnikov
> Version: 2.2.27
> OS: Windows XP Professional
> URL: ftp://ftp.openldap.org/incoming/
> Submission from: (NULL) (
> Problem symptoms: LDAP Search that returns about 20Kb of data is failing in the
> middle of decoding with IO error.
> Problem description: liblber code is using recv() to read data from socket on
> Windows. If there is some data in the TCP buffer already, the function would
> complete immediately (without blocking), returning number of bytes
> in the buffer. This can lead to a situation when the caller requests,
> say 100 bytes, but only gets 32. If the caller needs more data
> it would call the recv function again to get more data.
> liblber ber_get_next() was setting errno to EAGAIN or EWOULDBLOCK
> (depending on which one is defined on the platform) to signal to
> the caller that it needs to call ber_get_next again to get more data.
> For some bizarre reason when errno is set in liblber, it is not
> set when execution returns to libldap. I suspect both DLLs have
> private copies of the same errno value.
> The end result of errno not being set is that libldap thinks that
> there was some socket error and fails the current operation.
> The fix is to use WSASetLastError/WSAGetLastError on Windows.
> They operate on per thread value and work correctly accross DLL
> boundaries.
> libldap/liblber were built using /MD flag (to link with "Multithreaded DLL" C
> library), using Visual Studio 8 (2005).
> I've compares changes to libldap/liblber code between 2.2.27 and trunk of 2.3.X
> branch and I think the problem is still there.

  -- Howard Chu
  Chief Architect, Symas Corp.  http://www.symas.com
  Director, Highland Sun        http://highlandsun.com/hyc
  OpenLDAP Core Team            http://www.openldap.org/project/