X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fconnection.c;h=4e7fb9bc5587d60226e852009bf46c5ca65e04ef;hb=38383fca41d73745ea086c57946dfe2b8c7d7115;hp=674b04de85a313ebc5c80177c287c3a218f6f697;hpb=b6fbfe8540ebb48f89bf6484a61ce63e752be174;p=openldap diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index 674b04de85..4e7fb9bc55 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -1049,7 +1049,10 @@ operations_error: } if ( op->o_cancel == SLAP_CANCEL_REQ ) { - op->o_cancel = LDAP_TOO_LATE; + if ( rc == SLAPD_ABANDON ) + op->o_cancel = SLAP_CANCEL_ACK; + else + op->o_cancel = LDAP_TOO_LATE; } while ( op->o_cancel != SLAP_CANCEL_NONE && op->o_cancel != SLAP_CANCEL_DONE ) @@ -1061,27 +1064,11 @@ operations_error: ber_set_option( op->o_ber, LBER_OPT_BER_MEMCTX, &memctx_null ); -#if 0 /* DELETE ME */ - if ( op->o_cancel != SLAP_CANCEL_ACK && - ( 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 -#endif - { - LDAP_STAILQ_REMOVE( &conn->c_ops, op, slap_op, o_next); - LDAP_STAILQ_NEXT(op, o_next) = NULL; - slap_op_free( op ); - conn->c_n_ops_executing--; - conn->c_n_ops_completed++; - } + LDAP_STAILQ_REMOVE( &conn->c_ops, op, slap_op, o_next); + LDAP_STAILQ_NEXT(op, o_next) = NULL; + slap_op_free( op ); + conn->c_n_ops_executing--; + conn->c_n_ops_completed++; switch( tag ) { case LBER_ERROR: @@ -1648,6 +1635,7 @@ static int connection_op_activate( Operation *op ) int connection_write(ber_socket_t s) { Connection *c; + Operation *op; assert( connections != NULL ); @@ -1679,6 +1667,26 @@ int connection_write(ber_socket_t s) if ( ber_sockbuf_ctrl( c->c_sb, LBER_SB_OPT_NEEDS_WRITE, NULL ) ) { slapd_set_write( s, 1 ); } + /* If there are ops pending because of a writewaiter, start + * one up. + */ + while ((op = LDAP_STAILQ_FIRST( &c->c_pending_ops )) != NULL) { + if ( !c->c_writewaiter ) break; + if ( c->c_n_ops_executing > connection_pool_max/2 ) { + break; + } + LDAP_STAILQ_REMOVE_HEAD( &c->c_pending_ops, o_next ); + LDAP_STAILQ_NEXT(op, o_next) = NULL; + /* pending operations should not be marked for abandonment */ + assert(!op->o_abandon); + + c->c_n_ops_pending--; + c->c_n_ops_executing++; + + connection_op_activate( op ); + + break; + } connection_return( c ); ldap_pvt_thread_mutex_unlock( &connections_mutex ); return 0;