]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/result.c
ITS#6098 issuerUID and subjectUID are primitive, not constructed
[openldap] / servers / slapd / result.c
index 22cfde86886e14c67b07492f72dc34eda0d95b20..e0800f4ffc59fb7c3256f692f7ab3ae58afbc0ea 100644 (file)
@@ -133,9 +133,10 @@ slap_req2res( ber_tag_t tag )
 }
 
 static long send_ldap_ber(
-       Connection *conn,
+       Operation *op,
        BerElement *ber )
 {
+       Connection *conn = op->o_conn;
        ber_len_t bytes;
        long ret = 0;
        int closing = 0;
@@ -144,7 +145,7 @@ static long send_ldap_ber(
 
        /* write only one pdu at a time - wait til it's our turn */
        ldap_pvt_thread_mutex_lock( &conn->c_write1_mutex );
-       if ( connection_state_closing( conn )) {
+       if ( op->o_abandon || connection_state_closing( conn )) {
                ldap_pvt_thread_mutex_unlock( &conn->c_write1_mutex );
                return 0;
        }
@@ -171,7 +172,15 @@ static long send_ldap_ber(
                int err;
 
                /* lock the connection */ 
-               ldap_pvt_thread_mutex_lock( &conn->c_mutex );
+               if ( ldap_pvt_thread_mutex_trylock( &conn->c_mutex )) {
+                       ldap_pvt_thread_mutex_unlock( &conn->c_write1_mutex );
+                       ldap_pvt_thread_mutex_lock( &conn->c_write1_mutex );
+                       if ( conn->c_writers < 0 ) {
+                               ret = 0;
+                               break;
+                       }
+                       continue;
+               }
 
                if ( ber_flush2( conn->c_sb, ber, LBER_FLUSH_FREE_NEVER ) == 0 ) {
                        ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
@@ -191,18 +200,18 @@ static long send_ldap_ber(
                    err, sock_errstr(err), 0 );
 
                if ( err != EWOULDBLOCK && err != EAGAIN ) {
+                       conn->c_writers--;
+                       ldap_pvt_thread_mutex_unlock( &conn->c_write1_mutex );
                        connection_closing( conn, "connection lost on write" );
 
                        ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
-
-                       ret = -1;
-                       break;
+                       return -1;
                }
 
                /* wait for socket to be write-ready */
                ldap_pvt_thread_mutex_lock( &conn->c_write2_mutex );
                conn->c_writewaiter = 1;
-               slapd_set_write( conn->c_sd, 1 );
+               slapd_set_write( conn->c_sd, 2 );
 
                ldap_pvt_thread_mutex_unlock( &conn->c_write1_mutex );
                ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
@@ -524,7 +533,7 @@ send_ldap_response(
        }
 
        /* send BER */
-       bytes = send_ldap_ber( op->o_conn, ber );
+       bytes = send_ldap_ber( op, ber );
 #ifdef LDAP_CONNECTIONLESS
        if (!op->o_conn || op->o_conn->c_is_udp == 0)
 #endif
@@ -1235,7 +1244,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
        }
 
        if ( op->o_res_ber == NULL ) {
-               bytes = send_ldap_ber( op->o_conn, ber );
+               bytes = send_ldap_ber( op, ber );
                ber_free_buf( ber );
 
                if ( bytes < 0 ) {
@@ -1408,7 +1417,7 @@ slap_send_search_reference( Operation *op, SlapReply *rs )
 #ifdef LDAP_CONNECTIONLESS
        if (!op->o_conn || op->o_conn->c_is_udp == 0) {
 #endif
-       bytes = send_ldap_ber( op->o_conn, ber );
+       bytes = send_ldap_ber( op, ber );
        ber_free_buf( ber );
 
        if ( bytes < 0 ) {
@@ -1648,9 +1657,9 @@ slap_attr_flags( AttributeName *an )
                flags |= ( SLAP_OPATTRS_NO | SLAP_USERATTRS_YES );
 
        } else {
-               flags |= an_find( an, &AllOper )
+               flags |= an_find( an, slap_bv_all_operational_attrs )
                        ? SLAP_OPATTRS_YES : SLAP_OPATTRS_NO;
-               flags |= an_find( an, &AllUser )
+               flags |= an_find( an, slap_bv_all_user_attrs )
                        ? SLAP_USERATTRS_YES : SLAP_USERATTRS_NO;
        }