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

Re: ldap_result returns 0 before exceeding timeout



----- Original Message ----- 
From: "Kurt D. Zeilenga" <Kurt@OpenLDAP.org>
To: <xin@autograf.pl>
Cc: <OpenLDAP-software@OpenLDAP.org>
Sent: Thursday, March 24, 2005 12:20 AM
Subject: Re: ldap_result returns 0 before exceeding timeout


> At 07:07 AM 3/23/2005, xin@autograf.pl wrote:
>>Hey,
>>
>>I'm performing ldap_modify operation and than getting result by calling ldap_result.
>>
>>If I set timeout to 1s mostly it executes correctly, but sometimes ldap_results returns 0 after 5ms as it would have exceeded timeout. If I set timeout to 500ms it always returns 0 after very short time (~5ms). If I set timeout to 1.1s it executes always correctly.
>>
>>Anyone have any idea why is it happening? I would like to have this timeout shorter than 1s.
> 
> There are a number of reasons why ldap_result() will return
> sooner than the timeout (as well as a number of reasons why
> the return will be longer than the timeout).  Your program
> needs to deal with these possibilities in some appropriate
> manner.
> 
> Kurt

If such ldap_result behaviour is expected than do I have to check myself if real timeout happend or it's ldap_result returned 0 sooner than timeout? Some like below:

1) save current time in struct timeval
2) call ldap_result
3) check if it returns 0 and if so compare time from 1) + expected timeout with current time
4) if it's smaller than goto 2; else real timeout happend

Tomas