#include "portable.h"
#include <stdio.h>
+#ifdef HAVE_LIMITS_H
#include <limits.h>
+#endif
#include <ac/socket.h>
#include <ac/errno.h>
ber_sockbuf_ctrl( c->c_sb, LBER_SB_OPT_SET_MAX_INCOMING, &max );
}
- if(c->c_authmech.bv_val != NULL ) {
- free(c->c_authmech.bv_val);
+ if ( !BER_BVISNULL( &c->c_authmech ) ) {
+ ch_free(c->c_authmech.bv_val);
}
BER_BVZERO( &c->c_authmech );
- if(c->c_dn.bv_val != NULL) {
- free(c->c_dn.bv_val);
+ if ( !BER_BVISNULL( &c->c_dn ) ) {
+ ch_free(c->c_dn.bv_val);
}
BER_BVZERO( &c->c_dn );
- if(c->c_ndn.bv_val != NULL) {
- free(c->c_ndn.bv_val);
+ if ( !BER_BVISNULL( &c->c_ndn ) ) {
+ ch_free(c->c_ndn.bv_val);
}
BER_BVZERO( &c->c_ndn );
+ if ( !BER_BVISNULL( &c->c_sasl_authz_dn ) ) {
+ ber_memfree_x( c->c_sasl_authz_dn.bv_val, NULL );
+ }
+ BER_BVZERO( &c->c_sasl_authz_dn );
c->c_authz_backend = NULL;
}
/* wake write blocked operations */
slapd_clr_write( sd, 1 );
- ldap_pvt_thread_cond_signal( &c->c_write_cv );
+ if ( c->c_writewaiter ) {
+ ldap_pvt_thread_cond_signal( &c->c_write_cv );
+ ldap_pvt_thread_mutex_unlock( &c->c_mutex );
+ ldap_pvt_thread_yield();
+ ldap_pvt_thread_mutex_lock( &c->c_mutex );
+ }
}
}
* already pending ops, let them go first. Abandon operations
* get exceptions to some, but not all, cases.
*/
- if (tag != LDAP_REQ_ABANDON && conn->c_conn_state == SLAP_C_CLOSING) {
- defer = "closing";
- } else if (tag != LDAP_REQ_ABANDON && conn->c_writewaiter) {
- defer = "awaiting write";
- } else if (conn->c_n_ops_executing >= connection_pool_max/2) {
- defer = "too many executing";
- } else if (conn->c_conn_state == SLAP_C_BINDING) {
- defer = "binding";
- } else if (tag != LDAP_REQ_ABANDON && conn->c_n_ops_pending) {
- defer = "pending operations";
+ switch( tag ){
+ default:
+ /* Abandon and Unbind are exempt from these checks */
+ if (conn->c_conn_state == SLAP_C_CLOSING) {
+ defer = "closing";
+ break;
+ } else if (conn->c_writewaiter) {
+ defer = "awaiting write";
+ break;
+ } else if (conn->c_n_ops_pending) {
+ defer = "pending operations";
+ break;
+ }
+ /* FALLTHRU */
+ case LDAP_REQ_ABANDON:
+ /* Unbind is exempt from these checks */
+ if (conn->c_n_ops_executing >= connection_pool_max/2) {
+ defer = "too many executing";
+ break;
+ } else if (conn->c_conn_state == SLAP_C_BINDING) {
+ defer = "binding";
+ break;
+ }
+ /* FALLTHRU */
+ case LDAP_REQ_UNBIND:
+ break;
}
if( defer ) {
if (!op->o_dn.bv_len) {
op->o_authz = op->o_conn->c_authz;
- ber_dupbv( &op->o_dn, &op->o_conn->c_dn );
- ber_dupbv( &op->o_ndn, &op->o_conn->c_ndn );
+ if ( BER_BVISNULL( &op->o_conn->c_sasl_authz_dn )) {
+ ber_dupbv( &op->o_dn, &op->o_conn->c_dn );
+ ber_dupbv( &op->o_ndn, &op->o_conn->c_ndn );
+ } else {
+ ber_dupbv( &op->o_dn, &op->o_conn->c_sasl_authz_dn );
+ ber_dupbv( &op->o_ndn, &op->o_conn->c_sasl_authz_dn );
+ }
}
op->o_authtype = op->o_conn->c_authtype;
ber_dupbv( &op->o_authmech, &op->o_conn->c_authmech );