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

Re: ldap_result returns 0 before exceeding timeout

At 03:47 AM 3/25/2005, xin@autograf.pl wrote:
>----- 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:
>>>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

If you really care about how much time is spent doing this
and that, maybe so.  But I think you question how much your
program should care about the time spent doing this or that.

ldap_result() is intended timeout feature to allow programs
not to wait beyond the timeout (because programs often have
other things to do).   If ldap_result returns with
no result, do some of those other things and then ask again
for results.  And if you have other things to do, it seems
odd that you would waste time waiting at all.