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

Windows and multiple client connections

This may be common knowledge already, but it surprised us. On Windows the
libldap calls WSAStartup on every new LDAP session, and WSACleanup on every
ldap_unbind. Unfortunately, after WSACleanup does its thing, a subsequent
WSAStartup is insufficient to resume socket operations. It appears that
WSACleanup does a very thorough (and irreversible) job of deallocating
socket resources...

This problem hasn't surfaced in the standard tools because they generally
set up only one session per invocation. We've been developing a longer-lived
client that performs a series of bind/search/unbind operations, and only the
first sequence would work. There's a simple workaround though - simply issue
an explicit WSAStartup call in our client. WSACleanup must be called as many
times as WSAStartup, and it only actually cleans up on the last call. A more
ideal solution would be for libldap to only call WSAStartup once, e.g. in
ldap_int_initialize, but then we'd need to register an exit handler (using
atexit or something similar) to perform the mandatory WSACleanup when a
program finishes.

I wonder if this behavior needs to be noted on the FAQ... ?

  -- Howard Chu
  Chief Architect, Symas Corp.       Director, Highland Sun
  http://www.symas.com               http://highlandsun.com/hyc