Hi once again,

Some more of my observations:

  When LDAP_OPT_THREAD_FN_PTRS parameter is set the program goes into a
loop.
Debugging more it was found that the get_errno function is invoked by
nsldapi_send_ber_message (Line No. 402 - request.c).

  402.  int terrno = LDAP_GET_ERRNO( ld );
  403.  if ( NSLDAPI_ERRNO_IO_INPROGRESS( terrno )) {
  404.      if ( async ) {
  405.         rc = -2;
  406.         break;
  407.      }
  408.    } else {
  409.        nsldapi_connection_lost_nolock( ld, sb );
  410.        rc = -1;   /* fatal error */
  411.        break;
  412.   }

It is from #402 that the get_errno function is invoked. This function
returns 11 as mentioned in an earlier mail.

The difference between the hanging & the non-hanging program lies here.
When we do not set LDAP_OPT_THREAD_FN_PTRS, the value I see for terrno is 0,
whereas it's value is 11 when the parameter has been set.

The NSLDAPI_ERRNO_IO_INPROGRESS macro evaluates 11 as an IO_IN_PROGRESS.
However, strangely the value for async is false ('0') in both the cases.
Due to this, the program does not execute #405.

However, I am still not clear as to why the value of "errno" is different
for the 2 cases (when we set the parameter & not).

I just saw that the LDAP_GET_ERRNO macro is defined as follows (ldap-int.h)

        #define LDAP_GET_ERRNO( ld ) \
        (((ld)->ld_get_errno_fn != NULL) ? \
                (ld)->ld_get_errno_fn() : errno)
The backtrace for the program is as follows:
#0  0x00478938 in poll () from /lib/i686/libc.so.6
#1  0x008c14f7 in pt_poll_now (op=0xbff24770) at
../../../../pr/src/pthreads/ptio.c:650
#2  0x008c16d3 in pt_Continue (op=0xbff24770) at
../../../../pr/src/pthreads/ptio.c:715
#3  0x008c347d in pt_Recv (fd=0x83034c0, buf=0x8331200, amount=3, flags=0,
timeout=5000) at ../../../../pr/src/pthreads/ptio.c:1833
#4  0x00230224 in ssl_DefRecv (ss=0x8331020, buf=0x8331200 "", len=3,
flags=0) at ssldef.c:91
#5  0x002307bf in ssl2_GatherData (ss=0x8331020, gs=0x83311c0, flags=0) at
sslgathr.c:114
#6  0x0023107b in ssl2_GatherRecord (ss=0x8331020, flags=0) at
sslgathr.c:390
#7  0x0022af2d in ssl_GatherRecord1stHandshake (ss=0x8331020) at
sslcon.c:1259
#8  0x00232598 in ssl_Do1stHandshake (ss=0x8331020) at sslsecur.c:145
#9  0x0023408a in ssl_SecureSend (ss=0x8331020, buf=0x8330af4
"0\031\002\001\001`\024\002\001\003\004\bcn=admin\200\005abcdbcdebcdeb",
len=27, flags=0)
    at sslsecur.c:1024
#10 0x00239581 in ssl_Send (fd=0x8330fe0, buf=0x8330af4, len=27, flags=0,
timeout=5000) at sslsock.c:1222
#11 0x008a4739 in PR_Send (fd=0x8330fe0, buf=0x8330af4, amount=27, flags=0,
timeout=5000) at ../../../../pr/src/io/priometh.c:221
#12 0x00bf79a0 in prldap_write (s=1, buf=0x8330af4, len=27,
socketarg=0x832a760) at ldappr-io.c:210
#13 0x00a457e3 in ber_flush (sb=0x83306c8, ber=0x83309d0, freeit=0) at
io.c:414
#14 0x00a307bb in nsldapi_send_ber_message (ld=0x8330510, sb=0x83306c8,
ber=0x83309d0, freeit=0) at request.c:399
#15 0x00a30350 in nsldapi_send_server_request (ld=0x8330510, ber=0x83309d0,
msgid=1, parentreq=0x0, srvlist=0x0, lc=0x8303488,
    bindreqdn=0x8333888 "cn=admin", bind=0) at request.c:333
#16 0x00a2f711 in nsldapi_send_initial_request (ld=0x8330510, msgid=1,
msgtype=96, dn=0x80499fa "cn=admin", ber=0x83309d0) at request.c:147
#17 0x00a38287 in simple_bind_nolock (ld=0x8330510, dn=0x80499fa "cn=admin",
passwd=0x80499f4 "abcde", unlock_permitted=1) at sbind.c:149
#18 0x00a37de1 in ldap_simple_bind (ld=0x8330510, dn=0x80499fa "cn=admin",
passwd=0x80499f4 "abcde") at sbind.c:79
#19 0x0804944f in main (argc=1, argv=0xbff25114) at
Mozilla_LDAP_Client.cpp:222

What I would like to know is that is there anything that we need to do in
the get_errno function /
Thread Function Pointers so that ldap_simple_bind does not hang.

Here is the function:
/* Function for getting errno. */
static int
get_errno( void )
{
  int eno = errno;
  printf("Error : %d\n", eno);
  printf("Error Info : %s\n", ldap_err2string(eno));
  return( errno );
}

/* Function for setting errno. */
static void
set_errno( int err )
{
  errno = err;
}


Thanks,
Denish

On Thu, Aug 27, 2009 at 9:00 PM, denish patel <[email protected]>wrote:

> Hi All,
>
>   I am facing a peculiar problem.
> When the DS is in hang state, my LDAP Client hangs up on the
> ldap_simple_bind() call:
> Here is what I am doing:
>
>   1) ldapssl_client_init
>   2) ldapssl_init
>   3) ldap_set_option( ld, LDAP_X_OPT_CONNECT_TIMEOUT, &uiTimeLimit1 );
>   4) ldap_set_option( ld, LDAP_OPT_REFERRALS, LDAP_OPT_ON );
>   5) ldap_set_option( ld, LDAP_OPT_SIZELIMIT, &uiSizeLimit );
>   6) ldap_set_option( ld, LDAP_OPT_TIMELIMIT, &timelimit2 );
>   7) prldap_set_session_option( ld, NULL, PRLDAP_OPT_IO_MAX_TIMEOUT, tmout
> ); // tmout set to 5000
>   8) ldap_set_option( ld, LDAP_OPT_THREAD_FN_PTRS, (void *) &tfns );
>   9) ldap_set_option( ld, LDAP_OPT_EXTRA_THREAD_FN_PTRS, (void *) &extrafns
> );
> 10) ldap_simple_bind
>
> I see that all the steps from 1-9 are successful. However, still the
> program hangs up on step 10.
> This happens only when the DS is in hang state.
>
> One more thing I noticed is that when I omit step 8 i.e.
> LDAP_OPT_THREAD_FN_PTRS, I see it working
> properly i.e. ldap_simple_bind returns after 5 seconds.
>
> We cannot ignore this step because we have a multi threaded application
> that might have multiple threads
> using the same LDAP handle.
>
> When used I also see that the functions used for "ltf_get_errno" &
> "ltf_set_errno" are being invoked repeatedly
> & in the "ltf_get_errno" the value of erno is 11, which maps to
> "Administrative limit exceeded".
>
> The stack traces for the 2 functions are as below:
> for set_errno:
> #0  set_errno (err=0) at Mozilla_LDAP_Client.cpp:62
> #1  0x005f0f03 in nsldapi_send_ber_message () from
> /home/oracle/Denish/ldapcsdk-5.1.7/lib/libldap50.so
> #2  0x005f1d4b in nsldapi_send_server_request () from
> /home/oracle/Denish/ldapcsdk-5.1.7/lib/libldap50.so
> #3  0x005f21fb in nsldapi_send_initial_request () from
> /home/oracle/Denish/ldapcsdk-5.1.7/lib/libldap50.so
> #4  0x005f5931 in simple_bind_nolock () from
> /home/oracle/Denish/ldapcsdk-5.1.7/lib/libldap50.so
> #5  0x0804943d in main (argc=1, argv=0xbfebda04) at
> Mozilla_LDAP_Client.cpp:219
>
> for get_errno:
> #0  get_errno () at Mozilla_LDAP_Client.cpp:53
> #1  0x005f0f2a in nsldapi_send_ber_message () from
> /home/oracle/Denish/ldapcsdk-5.1.7/lib/libldap50.so
> #2  0x005f1d4b in nsldapi_send_server_request () from
> /home/oracle/Denish/ldapcsdk-5.1.7/lib/libldap50.so
> #3  0x005f21fb in nsldapi_send_initial_request () from
> /home/oracle/Denish/ldapcsdk-5.1.7/lib/libldap50.so
> #4  0x005f5931 in simple_bind_nolock () from
> /home/oracle/Denish/ldapcsdk-5.1.7/lib/libldap50.so
> #5  0x0804943d in main (argc=1, argv=0xbfebda04) at
> Mozilla_LDAP_Client.cpp:219
>
> It seems that somwhere there is an infinite loop going on that is causing
> the ldap_simple_bind to hang.
>
> Would appreciate any inputs on this problem
>
> Thanks,
> Denish
>
_______________________________________________
dev-tech-ldap mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-ldap

Reply via email to