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

Windows and multiple client connections



Sorry to dredge up this old discussion, but we never resolved it
satisfactorily:
>>>
>From Kurt:
At 03:00 AM 5/16/00 -0700, Howard Chu wrote:
>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,

Don't do that.  Do init ( bind [search|modify|...]* )* unbind.

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

We likely should put a note that unbind relates to init, not to bind.
<<<
I note that my original message was slightly mis-stated; of course the app
calls init first, then bind, search, unbind. There is no other way to write
the app since unbind destroys the LDAP handle. The problem still remains -
Winsock hangs if the library is completely initialized and completely
deinitialized more than once in the same process. The only way to fix this
problem is to insure that it only happens once.

Note that WSAStartup increments a reference counter, so a full de-init only
happens after a matching number of WSACleanup calls. The workaround we used
in our client was to add an explicit WSAStartup in our application code.
This bumps up the refcount, so the LDAP library's WSACleanup calls have no
real effect.

The right way to fix this would be to move the WSAStartup call into
ldap_int_initialize or some other such init function where it will only be
executed once within any application. Unfortunately the LDAP C API doesn't
define a user-level library initialization function. More importantly, the
API doesn't provide a user-level global de-init function. Using atexit to
clean up seems like an ugly hack.

Does anyone else think there should be an explicit user-visible global
init/deinit function for libldap? Or should we just hide this stuff inside
internal functions, atexit handlers, etc?

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