Commit 08836a7d authored by Pierangelo Masarati's avatar Pierangelo Masarati Committed by Quanah Gibson-Mount
Browse files

ITS#7088 fix deadlock on write operations that do not need to be logged (please check)

parent 1bfb20ef
...@@ -1432,6 +1432,24 @@ static void accesslog_val2val(AttributeDescription *ad, struct berval *val, ...@@ -1432,6 +1432,24 @@ static void accesslog_val2val(AttributeDescription *ad, struct berval *val,
dst->bv_val[dst->bv_len] = '\0'; dst->bv_val[dst->bv_len] = '\0';
} }
static int
accesslog_op2logop( Operation *op )
{
switch ( op->o_tag ) {
case LDAP_REQ_ADD: return LOG_EN_ADD;
case LDAP_REQ_DELETE: return LOG_EN_DELETE;
case LDAP_REQ_MODIFY: return LOG_EN_MODIFY;
case LDAP_REQ_MODRDN: return LOG_EN_MODRDN;
case LDAP_REQ_COMPARE: return LOG_EN_COMPARE;
case LDAP_REQ_SEARCH: return LOG_EN_SEARCH;
case LDAP_REQ_BIND: return LOG_EN_BIND;
case LDAP_REQ_EXTENDED: return LOG_EN_EXTENDED;
default: /* unknown operation type */
break;
} /* Unbind and Abandon never reach here */
return LOG_EN_UNKNOWN;
}
static int accesslog_response(Operation *op, SlapReply *rs) { static int accesslog_response(Operation *op, SlapReply *rs) {
slap_overinst *on = (slap_overinst *)op->o_bd->bd_info; slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
log_info *li = on->on_bi.bi_private; log_info *li = on->on_bi.bi_private;
...@@ -1452,19 +1470,7 @@ static int accesslog_response(Operation *op, SlapReply *rs) { ...@@ -1452,19 +1470,7 @@ static int accesslog_response(Operation *op, SlapReply *rs) {
if ( rs->sr_type != REP_RESULT && rs->sr_type != REP_EXTENDED ) if ( rs->sr_type != REP_RESULT && rs->sr_type != REP_EXTENDED )
return SLAP_CB_CONTINUE; return SLAP_CB_CONTINUE;
switch ( op->o_tag ) { logop = accesslog_op2logop( op );
case LDAP_REQ_ADD: logop = LOG_EN_ADD; break;
case LDAP_REQ_DELETE: logop = LOG_EN_DELETE; break;
case LDAP_REQ_MODIFY: logop = LOG_EN_MODIFY; break;
case LDAP_REQ_MODRDN: logop = LOG_EN_MODRDN; break;
case LDAP_REQ_COMPARE: logop = LOG_EN_COMPARE; break;
case LDAP_REQ_SEARCH: logop = LOG_EN_SEARCH; break;
case LDAP_REQ_BIND: logop = LOG_EN_BIND; break;
case LDAP_REQ_EXTENDED: logop = LOG_EN_EXTENDED; break;
default: /* unknown operation type */
logop = LOG_EN_UNKNOWN; break;
} /* Unbind and Abandon never reach here */
lo = logops+logop+EN_OFFSET; lo = logops+logop+EN_OFFSET;
if ( !( li->li_ops & lo->mask )) { if ( !( li->li_ops & lo->mask )) {
log_base *lb; log_base *lb;
...@@ -1479,6 +1485,8 @@ static int accesslog_response(Operation *op, SlapReply *rs) { ...@@ -1479,6 +1485,8 @@ static int accesslog_response(Operation *op, SlapReply *rs) {
return SLAP_CB_CONTINUE; return SLAP_CB_CONTINUE;
} }
/* mutex and so were only set for write operations;
* if we got here, the operation must be logged */
if ( lo->mask & LOG_OP_WRITES ) { if ( lo->mask & LOG_OP_WRITES ) {
slap_callback *cb; slap_callback *cb;
...@@ -1898,19 +1906,23 @@ accesslog_op_mod( Operation *op, SlapReply *rs ) ...@@ -1898,19 +1906,23 @@ accesslog_op_mod( Operation *op, SlapReply *rs )
{ {
slap_overinst *on = (slap_overinst *)op->o_bd->bd_info; slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
log_info *li = on->on_bi.bi_private; log_info *li = on->on_bi.bi_private;
slap_verbmasks *lo;
int logop;
int doit = 0; int doit = 0;
/* These internal ops are not logged */ /* These internal ops are not logged */
if ( op->o_dont_replicate && op->orm_no_opattrs ) if ( op->o_dont_replicate && op->orm_no_opattrs )
return SLAP_CB_CONTINUE; return SLAP_CB_CONTINUE;
logop = accesslog_op2logop( op );
lo = logops+logop+EN_OFFSET;
if ( li->li_ops & LOG_OP_WRITES ) { if ( li->li_ops & lo->mask ) {
doit = 1; doit = 1;
} else { } else {
log_base *lb; log_base *lb;
for ( lb = li->li_bases; lb; lb = lb->lb_next ) for ( lb = li->li_bases; lb; lb = lb->lb_next )
if (( lb->lb_ops & LOG_OP_WRITES ) && dnIsSuffix( &op->o_req_ndn, &lb->lb_base )) { if (( lb->lb_ops & lo->mask ) && dnIsSuffix( &op->o_req_ndn, &lb->lb_base )) {
doit = 1; doit = 1;
break; break;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment