From: Howard Chu Date: Sun, 13 Jan 2002 16:40:37 +0000 (+0000) Subject: Reworked callback layout, added send_search_entry callback X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~161 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=af862f8c6b3efac0321631130014b5022808adcf;p=openldap Reworked callback layout, added send_search_entry callback --- diff --git a/servers/slapd/backglue.c b/servers/slapd/backglue.c index 79f20b8f27..2a5bef23b3 100644 --- a/servers/slapd/backglue.c +++ b/servers/slapd/backglue.c @@ -170,6 +170,7 @@ typedef struct glue_state { char *matched; int nrefs; BVarray refs; + slap_callback *prevcb; } glue_state; static void @@ -188,7 +189,7 @@ glue_back_response ( LDAPControl **ctrls ) { - glue_state *gs = op->o_glue; + glue_state *gs = op->o_callback->sc_private; if (err == LDAP_SUCCESS || gs->err != LDAP_SUCCESS) gs->err = err; @@ -240,13 +241,38 @@ glue_back_sresult ( int nentries ) { - glue_state *gs = op->o_glue; + glue_state *gs = op->o_callback->sc_private; gs->nentries += nentries; glue_back_response (c, op, 0, 0, err, matched, text, refs, NULL, NULL, NULL, ctrls); } +static int +glue_back_sendentry ( + BackendDB *be, + Connection *c, + Operation *op, + Entry *e, + AttributeName *an, + int ao, + LDAPControl **ctrls +) +{ + slap_callback *tmp = op->o_callback; + glue_state *gs = tmp->sc_private; + int rc; + + op->o_callback = gs->prevcb; + if (op->o_callback && op->o_callback->sc_sendentry) { + rc = op->o_callback->sc_sendentry(be, c, op, e, an, ao, ctrls); + } else { + rc = send_search_entry(be, c, op, e, an, ao, ctrls); + } + op->o_callback = tmp; + return rc; +} + static int glue_back_search ( BackendDB *b0, @@ -268,9 +294,12 @@ glue_back_search ( BackendDB *be; int i, rc, t2limit = 0, s2limit = 0; long stoptime = 0; - glue_state gs = {0}; struct berval bv; + glue_state gs = {0}; + slap_callback cb = {glue_back_response, glue_back_sresult, + glue_back_sendentry, &gs}; + gs.prevcb = op->o_callback; if (tlimit) { stoptime = slap_get_time () + tlimit; @@ -293,9 +322,7 @@ glue_back_search ( case LDAP_SCOPE_ONELEVEL: case LDAP_SCOPE_SUBTREE: - op->o_glue = &gs; - op->o_sresult = glue_back_sresult; - op->o_response = glue_back_response; + op->o_callback = &cb; /* * Execute in reverse order, most general first @@ -349,9 +376,7 @@ glue_back_search ( } break; } - op->o_sresult = NULL; - op->o_response = NULL; - op->o_glue = NULL; + op->o_callback = gs.prevcb; send_search_result (conn, op, gs.err, gs.matched, NULL, gs.refs, NULL, gs.nentries); diff --git a/servers/slapd/result.c b/servers/slapd/result.c index c79f848d88..4769904349 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -187,8 +187,8 @@ send_ldap_response( int rc; long bytes; - if (op->o_response) { - op->o_response( conn, op, tag, msgid, err, matched, + if (op->o_callback && op->o_callback->sc_response) { + op->o_callback->sc_response( conn, op, tag, msgid, err, matched, text, ref, resoid, resdata, sasldata, ctrls ); return; } @@ -548,8 +548,8 @@ send_search_result( assert( !LDAP_API_ERROR( err ) ); - if (op->o_sresult) { - op->o_sresult(conn, op, err, matched, text, refs, + if (op->o_callback && op->o_callback->sc_sresult) { + op->o_callback->sc_sresult(conn, op, err, matched, text, refs, ctrls, nentries); return; } @@ -631,6 +631,11 @@ send_search_entry( AttributeDescription *ad_entry = slap_schema.si_ad_entry; + if (op->o_callback && op->o_callback->sc_sendentry) { + return op->o_callback->sc_sendentry( be, conn, op, e, attrs, + attrsonly, ctrls ); + } + #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, "send_search_entry: conn %d dn=\"%s\"%s\n", diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index d41355a45a..98b2148be1 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -1360,6 +1360,16 @@ typedef void (slap_sresult)( struct slap_conn *, struct slap_op *, ber_int_t, const char *, const char *, BVarray, LDAPControl **, int nentries); +typedef int (slap_sendentry)( BackendDB *, struct slap_conn *, + struct slap_op *, Entry *, AttributeName *, int, LDAPControl **); + +typedef struct slap_callback { + slap_response *sc_response; + slap_sresult *sc_sresult; + slap_sendentry *sc_sendentry; + void *sc_private; +} slap_callback; + /* * represents an operation pending from an ldap client */ @@ -1388,11 +1398,9 @@ typedef struct slap_op { AuthorizationInformation o_authz; BerElement *o_ber; /* ber of the request */ - slap_response *o_response; /* callback function */ - slap_sresult *o_sresult; /* search result callback */ + slap_callback *o_callback; /* callback pointers */ LDAPControl **o_ctrls; /* controls */ - void *o_glue; /* for the glue backend */ void *o_private; /* anything the backend needs */ LDAP_STAILQ_ENTRY(slap_op) o_next; /* next operation in list */