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

Re: How to use LDAP_OPT_CONNECT_ASYNC?



> Hi,
>
> I'm trying to use the new LDAP_OPT_CONNECT_ASYNC with OpenLDAP 2.4.23
> client and I can't see how it can be done.
>
> After creating the connection structure via ldap_initialize() I then call
> ldap_sasl_bind() to do the bind. That calls down to ldap_new_connection()
> (ldap_sasl_bind -> ldap_send_initial_request -> ldap_open_defconn ->
> ldap_new_connection) and that implements the asynchronous connect, setting
> the lconn_status to LDAP_CONNST_CONNECTING and not calling ldap_int_poll()
> in ldap_pvt_connect().
>
> So far so good. But ldap_send_initial_request() then gets a good return
> code from ldap_open_defconn(), and so it goes on to call
> ldap_send_server_request() to send the bind, and that then calls
> ldap_int_poll() which waits for the connect to complete, making the whole
> operation synchronous.

No. ldap_int_poll() will return -2 if timeout is 0 and the filedes was not
active.  So ldap_send_server_request() will return LDAP_X_CONNECTING if
async.  The only place where this is used is in back-meta, where searches
to multiple handles were initiated sequentially, and
LDAP_OPT_CONNECT_ASYNC was introduced to avoid having to wait for each
connection to be established before starting processing available results.
 Now each target independently connects/binds/sends search request
asynchronously, and the main loop waits for the most recent event (bind
response, search responses) and starts the following one accordingly.

p.


> It seems to me that for this to work asynchronously, either:
>
> 1. ldap_send_initial_request() should check for lconn_status to
> LDAP_CONNST_CONNECTING on return from ldap_open_defconn(), and if it is
> then return, probably with error LDAP_X_CONNECTING. It should then be
> possible to re-call ldap_sasl_bind() when the connect has completed.
>
> 2. Establish the connection via ldap_new_connection() before calling
> ldap_sasl_bind(). But the functions to do that don't appear to be
> available on the API. ldap_open() could have probably done it, but it is
> now deprecated. So this would appear to require a new API function that
> would simply call ldap_open_defconn() and return LDAP_X_CONNECTING.
>
> Or is there some other way to achieve this?
>
> Ian
>
>