]> git.sur5r.net Git - openldap/commitdiff
SLAPD_DISCONNECT v -1 cleanup
authorKurt Zeilenga <kurt@openldap.org>
Wed, 23 Jun 2004 01:04:52 +0000 (01:04 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 23 Jun 2004 01:04:52 +0000 (01:04 +0000)
misc other cleanup

servers/slapd/abandon.c
servers/slapd/add.c
servers/slapd/bind.c
servers/slapd/connection.c
servers/slapd/dn.c
servers/slapd/extended.c
servers/slapd/result.c
servers/slapd/search.c

index 10dab8d82cb6c279f5dc46bd4874b23ac4ceddca..a0cba25f792f4a40a78733ac7026385cfddcfd29 100644 (file)
@@ -57,9 +57,8 @@ do_abandon( Operation *op, SlapReply *rs )
 #else
                Debug( LDAP_DEBUG_ANY, "do_abandon: ber_scanf failed\n", 0, 0 ,0 );
 #endif
-               send_ldap_discon( op, rs,
-                       LDAP_PROTOCOL_ERROR, "decoding error" );
-               return -1;
+               send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding error" );
+               return SLAPD_DISCONNECT;
        }
 
        if( get_ctrls( op, rs, 0 ) != LDAP_SUCCESS ) {
index da0ae87789e1e80a7f817bfd2196231236fed38e..9b4734ed9cdc5c3a61e5ba9698400432ed4a7729 100644 (file)
@@ -82,7 +82,7 @@ do_add( Operation *op, SlapReply *rs )
                Debug( LDAP_DEBUG_ANY, "do_add: ber_scanf failed\n", 0, 0, 0 );
 #endif
                send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding error" );
-               return -1;
+               return SLAPD_DISCONNECT;
        }
 
        e = (Entry *) ch_calloc( 1, sizeof(Entry) );
@@ -130,7 +130,7 @@ do_add( Operation *op, SlapReply *rs )
                        Debug( LDAP_DEBUG_ANY, "do_add: decoding error\n", 0, 0, 0 );
 #endif
                        send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding error" );
-                       rs->sr_err = -1;
+                       rs->sr_err = SLAPD_DISCONNECT;
                        goto done;
                }
 
@@ -168,7 +168,7 @@ do_add( Operation *op, SlapReply *rs )
                Debug( LDAP_DEBUG_ANY, "do_add: ber_scanf failed\n", 0, 0, 0 );
 #endif
                send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding error" );
-               rs->sr_err = -1;
+               rs->sr_err = SLAPD_DISCONNECT;
                goto done;
        }
 
index eb5ead1044627c1ca0e5fb91d69de452896b9533..57e164751df739c923934c2e6a00c347b377b4b7 100644 (file)
@@ -41,8 +41,7 @@
 int
 do_bind(
     Operation  *op,
-    SlapReply  *rs
-)
+    SlapReply  *rs )
 {
        BerElement *ber = op->o_ber;
        ber_int_t version;
@@ -117,7 +116,7 @@ do_bind(
                Debug( LDAP_DEBUG_ANY, "bind: ber_scanf failed\n", 0, 0, 0 );
 #endif
                send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding error" );
-               rs->sr_err = -1;
+               rs->sr_err = SLAPD_DISCONNECT;
                goto cleanup;
        }
 
index 3e9b90805c049ec92489e9a19a6df47e5a772115..7271677d8fb899140af4ebaa009a7655cc0413ef 100644 (file)
@@ -948,7 +948,7 @@ void connection_done( Connection *c )
 static void *
 connection_operation( void *ctx, void *arg_v )
 {
-       int rc = SLAPD_DISCONNECT;
+       int rc = LDAP_OTHER;
        Operation *op = arg_v;
        SlapReply rs = {REP_RESULT};
        ber_tag_t tag = op->o_tag;
@@ -966,6 +966,36 @@ connection_operation( void *ctx, void *arg_v )
 
        op->o_threadctx = ctx;
 
+       switch ( tag ) {
+       case LDAP_REQ_BIND:
+       case LDAP_REQ_UNBIND:
+       case LDAP_REQ_ADD:
+       case LDAP_REQ_DELETE:
+       case LDAP_REQ_MODRDN:
+       case LDAP_REQ_MODIFY:
+       case LDAP_REQ_COMPARE:
+       case LDAP_REQ_SEARCH:
+       case LDAP_REQ_ABANDON:
+       case LDAP_REQ_EXTENDED:
+               break;
+       default:
+#ifdef NEW_LOGGING
+               LDAP_LOG( CONNECTION, INFO, "connection_operation: "
+                       "conn %lu unknown LDAP request 0x%lx\n",
+                       conn->c_connid, tag, 0 );
+#else
+               Debug( LDAP_DEBUG_ANY, "connection_operation: "
+                       "conn %lu unknown LDAP request 0x%lx\n",
+                       conn->c_connid, tag, 0 );
+#endif
+               op->o_tag = LBER_ERROR;
+               rs.sr_err = LDAP_PROTOCOL_ERROR;
+               rs.sr_text = "unknown LDAP request";
+               send_ldap_disconnect( op, &rs );
+               rc = SLAPD_DISCONNECT;
+               goto operations_error;
+       }
+
        if( conn->c_sasl_bind_in_progress && tag != LDAP_REQ_BIND ) {
 #ifdef NEW_LOGGING
                LDAP_LOG( CONNECTION, ERR, 
@@ -978,6 +1008,7 @@ connection_operation( void *ctx, void *arg_v )
 #endif
                send_ldap_error( op, &rs, LDAP_OPERATIONS_ERROR,
                        "SASL bind in progress" );
+               rc = LDAP_OPERATIONS_ERROR;
                goto operations_error;
        }
 
@@ -1053,29 +1084,15 @@ connection_operation( void *ctx, void *arg_v )
                break;
 
        default:
-#ifdef NEW_LOGGING
-               LDAP_LOG( CONNECTION, INFO, 
-                       "connection_operation: conn %lu unknown LDAP request 0x%lx\n",
-                       conn->c_connid, tag, 0 );
-#else
-               Debug( LDAP_DEBUG_ANY, "unknown LDAP request 0x%lx\n",
-                       tag, 0, 0 );
-#endif
-               op->o_tag = LBER_ERROR;
-               rs.sr_err = LDAP_PROTOCOL_ERROR;
-               rs.sr_text = "unknown LDAP request";
-               send_ldap_disconnect( op, &rs );
-               rc = -1;
-               break;
+               /* not reachable */
+               assert( 0 );
        }
 
-#ifdef SLAPD_MONITOR
-       oldtag = tag;
-#endif /* SLAPD_MONITOR */
+operations_error:
        if( rc == SLAPD_DISCONNECT ) tag = LBER_ERROR;
 
-operations_error:
        ldap_pvt_thread_mutex_lock( &num_ops_mutex );
+
        num_ops_completed++;
 #ifdef SLAPD_MONITOR
        switch (oldtag) {
@@ -1109,6 +1126,9 @@ operations_error:
        case LDAP_REQ_EXTENDED:
                num_ops_completed_[SLAP_OP_EXTENDED]++;
                break;
+       default:
+               /* not reachable */
+               assert( 0 );
        }
 #endif /* SLAPD_MONITOR */
        ldap_pvt_thread_mutex_unlock( &num_ops_mutex );
@@ -1116,7 +1136,6 @@ operations_error:
        if ( op->o_cancel == SLAP_CANCEL_REQ ) {
                op->o_cancel = LDAP_TOO_LATE;
        }
-
        while ( op->o_cancel != SLAP_CANCEL_NONE &&
                op->o_cancel != SLAP_CANCEL_DONE )
        {
@@ -1128,14 +1147,17 @@ operations_error:
        ber_set_option( op->o_ber, LBER_OPT_BER_MEMCTX, &memctx_null );
 
        if ( op->o_cancel != SLAP_CANCEL_ACK &&
-                               ( op->o_sync_mode & SLAP_SYNC_PERSIST ) ) {
+               ( op->o_sync_mode & SLAP_SYNC_PERSIST ) )
+       {
                slap_sl_mem_detach( ctx, memctx );
+
        } else if (( op->o_sync_slog_size != -1 )) {
                slap_sl_mem_detach( ctx, memctx );
                LDAP_STAILQ_REMOVE( &conn->c_ops, op, slap_op, o_next);
                LDAP_STAILQ_NEXT(op, o_next) = NULL;
                conn->c_n_ops_executing--;
                conn->c_n_ops_completed++;
+
        } else {
                LDAP_STAILQ_REMOVE( &conn->c_ops, op, slap_op, o_next);
                LDAP_STAILQ_NEXT(op, o_next) = NULL;
@@ -1161,9 +1183,7 @@ operations_error:
        }
 
        connection_resched( conn );
-
        ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
-
        return NULL;
 }
 
@@ -1174,11 +1194,12 @@ int connection_client_setup(
        ldap_pvt_thread_start_t *func,
        void *arg )
 {
+       int rc;
        Connection *c;
 
-       if ( connection_init( s, (Listener *)&dummy_list, "", "", CONN_IS_CLIENT, 0, NULL ) < 0 ) {
-               return -1;
-       }
+       rc = connection_init( s, (Listener *)&dummy_list, "", "",
+               CONN_IS_CLIENT, 0, NULL );
+       if ( rc < 0 ) return -1;
 
        c = connection_get( s );
        c->c_clientfunc = func;
@@ -1190,15 +1211,13 @@ int connection_client_setup(
 }
 
 void connection_client_enable(
-       ber_socket_t s
-)
+       ber_socket_t s )
 {
        slapd_set_read( s, 1 );
 }
 
 void connection_client_stop(
-       ber_socket_t s
-)
+       ber_socket_t s )
 {
        Connection *c;
 
index 6702e8dc18816938c6e106dfdc6ca184257aa2f2..e6d268ac781cf49e0a2bacbe0eed8e3656ab7b29 100644 (file)
@@ -918,6 +918,7 @@ int
 dnX509peerNormalize( void *ssl, struct berval *dn )
 {
 
-       return ldap_pvt_tls_get_peer_dn( ssl, dn, (LDAPDN_rewrite_dummy *)LDAPDN_rewrite, 0 );
+       return ldap_pvt_tls_get_peer_dn( ssl, dn,
+               (LDAPDN_rewrite_dummy *)LDAPDN_rewrite, 0 );
 }
 #endif
index 0abb6db23d38036b82e1ab48c754c10f7888eee7..27a06ad87cc291727a2db341035266fb877be51f 100644 (file)
@@ -163,7 +163,7 @@ do_extended(
                        op->o_protocol, 0 ,0 );
 #endif
                send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "requires LDAPv3" );
-               rs->sr_err = -1;
+               rs->sr_err = SLAPD_DISCONNECT;
                goto done;
        }
 
@@ -175,7 +175,7 @@ do_extended(
                Debug( LDAP_DEBUG_ANY, "do_extended: ber_scanf failed\n", 0, 0 ,0 );
 #endif
                send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding error" );
-               rs->sr_err = -1;
+               rs->sr_err = SLAPD_DISCONNECT;
                goto done;
        }
 
@@ -211,7 +211,7 @@ do_extended(
                        Debug( LDAP_DEBUG_ANY, "do_extended: ber_scanf failed\n", 0, 0 ,0 );
 #endif
                        send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding error" );
-                       rs->sr_err = -1;
+                       rs->sr_err = SLAPD_DISCONNECT;
                        goto done;
                }
        }
index af9510da362aa3dc943db83e1dd30c06dd66d322..c8a6d177854f20707609b99df1781b6a3a84c7bb 100644 (file)
@@ -524,7 +524,6 @@ send_ldap_disconnect( Operation     *op, SlapReply *rs )
                rs->sr_err, rs->sr_text ? rs->sr_text : "", NULL );
 #endif
 
-
        if ( op->o_protocol < LDAP_VERSION3 ) {
                rs->sr_rspoid = NULL;
                rs->sr_tag = req2res( op->o_tag );
@@ -614,11 +613,15 @@ slap_send_ldap_result( Operation *op, SlapReply *rs )
         */
        if ( op->o_pb != NULL ) {
                slapi_int_pblock_set_operation( op->o_pb, op );
-               slapi_pblock_set( op->o_pb, SLAPI_RESULT_CODE, (void *)rs->sr_err );
-               slapi_pblock_set( op->o_pb, SLAPI_RESULT_TEXT, (void *)rs->sr_text );
-               slapi_pblock_set( op->o_pb, SLAPI_RESULT_MATCHED, (void *)rs->sr_matched );
+               slapi_pblock_set( op->o_pb, SLAPI_RESULT_CODE,
+                       (void *)rs->sr_err );
+               slapi_pblock_set( op->o_pb, SLAPI_RESULT_TEXT,
+                       (void *)rs->sr_text );
+               slapi_pblock_set( op->o_pb, SLAPI_RESULT_MATCHED,
+                       (void *)rs->sr_matched );
 
-               (void) slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_PRE_RESULT_FN, op->o_pb );
+               (void) slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_PRE_RESULT_FN,
+                       op->o_pb );
        }
 #endif /* LDAP_SLAPI */
 
@@ -949,7 +952,8 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
 #endif
 
                                if ( op->o_res_ber == NULL ) ber_free_buf( ber );
-                               send_ldap_error( op, rs, LDAP_OTHER, "encoding description error");
+                               send_ldap_error( op, rs, LDAP_OTHER,
+                                       "encoding description error");
                                goto error_return;
                        }
                        finish = 1;
@@ -992,7 +996,8 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
 #endif
 
                                                if ( op->o_res_ber == NULL ) ber_free_buf( ber );
-                                               send_ldap_error( op, rs, LDAP_OTHER, "encoding description error");
+                                               send_ldap_error( op, rs, LDAP_OTHER,
+                                                       "encoding description error");
                                                goto error_return;
                                        }
                                }
@@ -1147,7 +1152,8 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
 #endif
 
                        if ( op->o_res_ber == NULL ) ber_free_buf( ber );
-                       send_ldap_error( op, rs, LDAP_OTHER, "encoding description error" );
+                       send_ldap_error( op, rs, LDAP_OTHER,
+                               "encoding description error" );
                        attrs_free( aa );
                        goto error_return;
                }
@@ -1232,9 +1238,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
                        for ( anp = rs->sr_attrs; anp->an_name.bv_val != NULL; anp++ ) {
                                rc = compute_evaluator( &ctx, anp->an_name.bv_val,
                                        rs->sr_entry, slapi_int_compute_output_ber );
-                               if ( rc == 1 ) {
-                                       break;
-                               }
+                               if ( rc == 1 ) break;
                        }
                } else {
                        /*
index 1783c9619f24017e4fcaf67f1b48400ff40608b9..4738f5dfcc6a24c8e92740e748713ec5ef4f3fea 100644 (file)
@@ -47,8 +47,8 @@ static void call_search_postop_plugins( Operation *op );
 int
 do_search(
     Operation  *op,    /* info about the op to which we're responding */
-    SlapReply  *rs     /* all the response data we'll send */
-{
+    SlapReply  *rs     /* all the response data we'll send */ )
+{
        struct berval base = BER_BVNULL;
        ber_len_t       siz, off, i;
        int                     manageDSAit;
@@ -164,6 +164,7 @@ do_search(
                if( rs->sr_err == SLAPD_DISCONNECT ) {
                        rs->sr_err = LDAP_PROTOCOL_ERROR;
                        send_ldap_disconnect( op, rs );
+                       rs->sr_err = SLAPD_DISCONNECT;
                } else {
                        send_ldap_result( op, rs );
                }
@@ -427,19 +428,24 @@ do_search(
 #endif /* LDAP_SLAPI */
 
 return_results:;
+       if ( ( op->o_sync_mode & SLAP_SYNC_PERSIST ) ) return rs->sr_err;
+       if ( ( op->o_sync_slog_size != -1 ) ) return rs->sr_err;
 
-       if ( ( op->o_sync_mode & SLAP_SYNC_PERSIST ) )
-               return rs->sr_err;
-
-       if ( ( op->o_sync_slog_size != -1 ) )
-               return rs->sr_err;
-
-       if( !BER_BVISNULL( &op->o_req_dn ) ) slap_sl_free( op->o_req_dn.bv_val, op->o_tmpmemctx );
-       if( !BER_BVISNULL( &op->o_req_ndn ) ) slap_sl_free( op->o_req_ndn.bv_val, op->o_tmpmemctx );
+       if( !BER_BVISNULL( &op->o_req_dn ) ) {
+               slap_sl_free( op->o_req_dn.bv_val, op->o_tmpmemctx );
+       }
+       if( !BER_BVISNULL( &op->o_req_ndn ) ) {
+               slap_sl_free( op->o_req_ndn.bv_val, op->o_tmpmemctx );
+       }
 
-       if( !BER_BVISNULL( &op->ors_filterstr ) ) op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
+       if( !BER_BVISNULL( &op->ors_filterstr ) ) {
+               op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
+       }
        if( op->ors_filter != NULL) filter_free_x( op, op->ors_filter );
-       if( op->ors_attrs != NULL ) op->o_tmpfree( op->ors_attrs, op->o_tmpmemctx );
+       if( op->ors_attrs != NULL ) {
+               op->o_tmpfree( op->ors_attrs, op->o_tmpmemctx );
+       }
+
 #ifdef LDAP_SLAPI
        if( attrs != NULL) op->o_tmpfree( attrs, op->o_tmpmemctx );
 #endif /* LDAP_SLAPI */