[Date Prev][Date Next]
Re: ldap_result returns 0
Yuri Rabover wrote:
> "Kurt D. Zeilenga" wrote:
> > man ldap_result
> > ERRORS
> > ldap_result() returns -1 if something bad happens,
> > and zero if the timeout specified was exceeded.
> Thanks, Kurt. I missed it in the man page and this is exactly
> what is happening. Still, I am getting some strange results.
> I am using ldap_result with timeval initialized to 0, i.e. it
> just polls. My search test is supposed to return 12 entries.
> Just for the sake of exploring I am doing
> while ((rc = ldap_result(ld, -1, 1, &tv, &result)) == 0)
> Then I look at the actual return code and if it is LDAP_RES_SEARCH_RESULT
> I process and print the results, otherwise I just print the return
> code. Most of the time the results are printed correctly but once
> in a while I am getting just a subset of the attributes (my search
> request asked for everything including all attributes). As this is
> the same code working against the same server, I am
> wondering what might be the reason of this behavior? Is polling
> inherently problematic and I should always use a non-0 timeout?
> [My LDAP client is actually a server serving my test client, so
> all these repeated queries are going through one established
> connection with enabled cache].
Some clarifications and more questions. As I said, my LDAP client
is actually a server serving simple clients over some proprietary
protocol. Every client sends a request which is ldap_bind_s'ed,
then ldap_search'ed asynchronously. In this server I perform a select
on several sockets including the one I obtained from the LDAP
connection. As soon as I get something on this socket, I do ldap_result,
match parsed results to the request and send them back to the client.
If my (non-LDAP) client sends a request, gets results, exits
and this procedure is repeated with the same query data, everything
is working fine. If I invoke the same client with a different query
and then repeat the first query, the entry either doesn't contain
any attributes or only a small amount comparing with the normal
Question. Does the OpenLDAP API support this model or I have to
do some clean up before attempting to reuse the same connection
for different queries?