]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/result.c
Add comments.
[openldap] / libraries / libldap / result.c
index adc34d9db4159ff1c50cce4e7d4de66e7aeceeaf..042e92a52e0a75d0cd5a863db182bb21a97838fb 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -61,7 +62,11 @@ static void merge_error_info LDAP_P(( LDAP *ld, LDAPRequest *parentr, LDAPReques
  *     ldap_result( s, msgid, all, timeout, result )
  */
 int
-ldap_result( LDAP *ld, int msgid, int all, struct timeval *timeout,
+ldap_result(
+       LDAP *ld,
+       int msgid,
+       int all,
+       struct timeval *timeout,
        LDAPMessage **result )
 {
        LDAPMessage     *lm, *lastlm, *nextlm;
@@ -121,8 +126,7 @@ ldap_result( LDAP *ld, int msgid, int all, struct timeval *timeout,
                        }
 
                        if ( tmp == NULL ) {
-                               return( wait4msg( ld, msgid, all, timeout,
-                                   result ) );
+                               lm = NULL;
                        }
 
                        break;
@@ -140,8 +144,11 @@ ldap_result( LDAP *ld, int msgid, int all, struct timeval *timeout,
                lastlm->lm_next = (all == 0 && lm->lm_chain != NULL
                    ? lm->lm_chain : lm->lm_next);
        }
-       if ( all == 0 )
+       if ( all == 0 && lm->lm_chain != NULL )
+       {
+               lm->lm_chain->lm_next = lm->lm_next;
                lm->lm_chain = NULL;
+       }
        lm->lm_next = NULL;
 
        *result = lm;
@@ -337,7 +344,7 @@ try_read1msg(
        if (( lr = ldap_find_request_by_msgid( ld, id )) == NULL ) {
                Debug( LDAP_DEBUG_ANY,
                    "no request for response with msgid %ld (tossing)\n",
-                   id, 0, 0 );
+                   (long) id, 0, 0 );
                ber_free( ber, 1 );
                return( -2 );   /* continue looking */
        }
@@ -349,10 +356,10 @@ try_read1msg(
                return( -1 );
        }
 
-       Debug( LDAP_DEBUG_TRACE, "ldap_read: %s msgid %ld, original id %d\n",
+       Debug( LDAP_DEBUG_TRACE, "ldap_read: %s msgid %ld, original id %ld\n",
            ( tag == LDAP_RES_SEARCH_ENTRY ) ? "entry" : 
                ( tag == LDAP_RES_SEARCH_REFERENCE ) ? "reference" : "result",
-               id, lr->lr_origid );
+               (long) id, (long) lr->lr_origid );
 
        id = lr->lr_origid;
        refer_cnt = 0;
@@ -425,7 +432,7 @@ Debug( LDAP_DEBUG_TRACE,
                                id = lr->lr_msgid;
                                tag = lr->lr_res_msgtype;
                                Debug( LDAP_DEBUG_ANY, "request %ld done\n",
-                                   id, 0, 0 );
+                                   (long) id, 0, 0 );
 Debug( LDAP_DEBUG_TRACE,
 "res_errno: %d, res_error: <%s>, res_matched: <%s>\n",
 lr->lr_res_errno, lr->lr_res_error ? lr->lr_res_error : "",
@@ -507,8 +514,8 @@ lr->lr_res_matched ? lr->lr_res_matched : "" );
                return( -2 );   /* continue looking */
        }
 
-       Debug( LDAP_DEBUG_TRACE, "adding response id %d type %d:\n",
-           new->lm_msgid, new->lm_msgtype, 0 );
+       Debug( LDAP_DEBUG_TRACE, "adding response id %ld type %ld:\n",
+           (long) new->lm_msgid, (long) new->lm_msgtype, 0 );
 
        /* part of a search response - add to end of list of entries */
        for ( tmp = l; tmp->lm_chain != NULL &&
@@ -639,7 +646,7 @@ int
 ldap_msgtype( LDAPMessage *lm )
 {
        assert( lm != NULL );
-       return ( lm == NULL ) ? lm->lm_msgtype : -1;
+       return ( lm != NULL ) ? lm->lm_msgtype : -1;
 }
 
 
@@ -648,7 +655,7 @@ ldap_msgid( LDAPMessage *lm )
 {
        assert( lm != NULL );
 
-       return ( lm == NULL ) ? lm->lm_msgid : -1;
+       return ( lm != NULL ) ? lm->lm_msgid : -1;
 }
 
 
@@ -759,7 +766,14 @@ cldap_getmsg( LDAP *ld, struct timeval *timeout, BerElement *ber )
        ber_len_t       len;
 
        if ( ! ber_pvt_sb_data_ready(&ld->ld_sb) ) {
-               rc = ldap_select1( ld, timeout );
+               /* restored from ldap_select1() in result.c version 1.24 */
+               fd_set  readfds;
+               if ( ldap_int_tblsize == 0 )
+                       ldap_int_ip_init();
+               FD_ZERO( &readfds );
+               FD_SET( ber_pvt_sb_get_desc(&ld->ld_sb), &readfds );
+               rc = select( ldap_int_tblsize, &readfds, 0, 0, timeout );
+
                if ( rc == -1 || rc == 0 ) {
                        ld->ld_errno = (rc == -1 ? LDAP_SERVER_DOWN :
                            LDAP_TIMEOUT);