#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 ) {
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) );
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;
}
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;
}
int
do_bind(
Operation *op,
- SlapReply *rs
-)
+ SlapReply *rs )
{
BerElement *ber = op->o_ber;
ber_int_t version;
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;
}
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;
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,
#endif
send_ldap_error( op, &rs, LDAP_OPERATIONS_ERROR,
"SASL bind in progress" );
+ rc = LDAP_OPERATIONS_ERROR;
goto operations_error;
}
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) {
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 );
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 )
{
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;
}
connection_resched( conn );
-
ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
-
return NULL;
}
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;
}
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;
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
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;
}
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;
}
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;
}
}
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 );
*/
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 */
#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;
#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;
}
}
#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;
}
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 {
/*
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;
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 );
}
#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 */