]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/connection.c
Fix pkiUser
[openldap] / servers / slapd / connection.c
index a93af0d11679b6b19f2934aa1053dfd50cbd8260..6425e199f2561e28e8e49ebfa1dca01f64d001f4 100644 (file)
@@ -417,8 +417,6 @@ long connection_init(
                c->c_dn.bv_len = 0;
                c->c_ndn.bv_val = NULL;
                c->c_ndn.bv_len = 0;
-               c->c_cdn.bv_val = NULL;
-               c->c_cdn.bv_len = 0;
                c->c_groups = NULL;
 
                c->c_listener_url.bv_val = NULL;
@@ -461,7 +459,6 @@ long connection_init(
     assert( c->c_authmech.bv_val == NULL );
     assert( c->c_dn.bv_val == NULL );
     assert( c->c_ndn.bv_val == NULL );
-    assert( c->c_cdn.bv_val == NULL );
     assert( c->c_groups == NULL );
     assert( c->c_listener_url.bv_val == NULL );
     assert( c->c_peer_domain.bv_val == NULL );
@@ -573,8 +570,8 @@ long connection_init(
 
 void connection2anonymous( Connection *c )
 {
-    assert( connections != NULL );
-    assert( c != NULL );
+       assert( connections != NULL );
+       assert( c != NULL );
 
        {
                ber_len_t max = sockbuf_max_incoming;
@@ -587,35 +584,27 @@ void connection2anonymous( Connection *c )
        }
        c->c_authmech.bv_len = 0;
 
-    if(c->c_dn.bv_val != NULL) {
-       free(c->c_dn.bv_val);
-       c->c_dn.bv_val = NULL;
-    }
-    c->c_dn.bv_len = 0;
-    if(c->c_ndn.bv_val != NULL) {
-       free(c->c_ndn.bv_val);
-       c->c_ndn.bv_val = NULL;
-    }
-    c->c_ndn.bv_len = 0;
-
-       if(c->c_cdn.bv_val != NULL) {
-               free(c->c_cdn.bv_val);
-               c->c_cdn.bv_val = NULL;
+       if(c->c_dn.bv_val != NULL) {
+               free(c->c_dn.bv_val);
+               c->c_dn.bv_val = NULL;
+       }
+       c->c_dn.bv_len = 0;
+       if(c->c_ndn.bv_val != NULL) {
+               free(c->c_ndn.bv_val);
+               c->c_ndn.bv_val = NULL;
        }
-       c->c_cdn.bv_len = 0;
+       c->c_ndn.bv_len = 0;
 
        c->c_authz_backend = NULL;
-    
-    {
-       GroupAssertion *g, *n;
-       for (g = c->c_groups; g; g=n)
+       
        {
-           n = g->ga_next;
-           free(g);
+               GroupAssertion *g, *n;
+               for (g = c->c_groups; g; g=n) {
+                       n = g->ga_next;
+                       free(g);
+               }
+               c->c_groups = NULL;
        }
-       c->c_groups = NULL;
-    }
-
 }
 
 static void
@@ -1175,14 +1164,13 @@ int connection_read(ber_socket_t s)
                         * to propagate to client. */
                        FD_ZERO(&rfd);
                        FD_SET(s, &rfd);
-                       for (rc=1; rc>0;)
-                       {
+                       for (rc=1; rc>0;) {
                            tv.tv_sec = 1;
                            tv.tv_usec = 0;
                            rc = select(s+1, &rfd, NULL, NULL, &tv);
-                           if (rc == 1)
-                               ber_sockbuf_ctrl( c->c_sb, LBER_SB_OPT_DRAIN,
-                                   NULL);
+                           if (rc == 1) {
+                                       ber_sockbuf_ctrl( c->c_sb, LBER_SB_OPT_DRAIN, NULL);
+                               }
                        }
 #endif
                        connection_close( c );
@@ -1217,9 +1205,15 @@ int connection_read(ber_socket_t s)
                        slap_sasl_external( c, c->c_tls_ssf, authid.bv_val );
                        if ( authid.bv_val )    free( authid.bv_val );
                }
-               connection_return( c );
-               ldap_pvt_thread_mutex_unlock( &connections_mutex );
-               return 0;
+
+               /* if success and data is ready, fall thru to data input loop */
+               if( rc != 0 ||
+                       !ber_sockbuf_ctrl( c->c_sb, LBER_SB_OPT_DATA_READY, NULL ) )
+               {
+                       connection_return( c );
+                       ldap_pvt_thread_mutex_unlock( &connections_mutex );
+                       return 0;
+               }
        }
 #endif