From 1a14def9031cbaf92865c8b265b2f9155305d537 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Fri, 14 Feb 2003 20:51:35 +0000 Subject: [PATCH] Use function pointers to get at backend routines. --- servers/slapd/abandon.c | 9 +++------ servers/slapd/back-bdb/init.c | 7 +++++++ servers/slapd/back-bdb/proto-bdb.h | 10 ++++++++-- servers/slapd/back-bdb/psearch.c | 2 ++ servers/slapd/cancel.c | 15 +++++++++------ servers/slapd/slap.h | 6 ++++++ 6 files changed, 35 insertions(+), 14 deletions(-) diff --git a/servers/slapd/abandon.c b/servers/slapd/abandon.c index 33bd0ab159..82cc58e607 100644 --- a/servers/slapd/abandon.c +++ b/servers/slapd/abandon.c @@ -109,14 +109,11 @@ do_abandon( done: -#ifdef LDAP_CLIENT_UPDATE for ( i = 0; i < nbackends; i++ ) { - if ( strncmp( backends[i].be_type, "bdb", 3 ) ) continue; - if ( bdb_abandon( &backends[i], conn, id ) == LDAP_SUCCESS ) { - break; - } + Backend *be = &backends[i]; + + if( be->be_abandon ) be->be_abandon( be, conn, op, id ); } -#endif ldap_pvt_thread_mutex_unlock( &conn->c_mutex ); diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index 91d81b7a2a..89fc7f6fd5 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -635,7 +635,14 @@ bdb_initialize( bi->bi_op_search = bdb_search; bi->bi_op_unbind = 0; + +#ifdef LDAP_CLIENT_UPDATE + bi->bi_op_abandon = bdb_abandon; + bi->bi_op_cancel = bdb_cancel; +#else bi->bi_op_abandon = 0; + bi->bi_op_cancel = 0; +#endif bi->bi_extended = bdb_extended; diff --git a/servers/slapd/back-bdb/proto-bdb.h b/servers/slapd/back-bdb/proto-bdb.h index 5ec4228d43..fe7a308468 100644 --- a/servers/slapd/back-bdb/proto-bdb.h +++ b/servers/slapd/back-bdb/proto-bdb.h @@ -368,13 +368,19 @@ void bdb_cache_release_all( Cache *cache ); * lcup.c */ -#ifdef LDAP_CLIENT_UPDATE int bdb_abandon( BackendDB *be, Connection *conn, + Operation *op, + ber_int_t id +); + +int bdb_cancel( + BackendDB *be, + Connection *conn, + Operation *op, ber_int_t id ); -#endif #if defined(LDAP_CLIENT_UPDATE) || defined(LDAP_SYNC) int bdb_add_psearch_spec( diff --git a/servers/slapd/back-bdb/psearch.c b/servers/slapd/back-bdb/psearch.c index 2dbd40e752..e62c8ec18b 100644 --- a/servers/slapd/back-bdb/psearch.c +++ b/servers/slapd/back-bdb/psearch.c @@ -37,6 +37,7 @@ int bdb_abandon( BackendDB *be, Connection *conn, + Operation *op, ber_int_t id ) { Operation *ps_list; @@ -59,6 +60,7 @@ int bdb_cancel( BackendDB *be, Connection *conn, + Operation *op, ber_int_t id ) { Operation *ps_list; diff --git a/servers/slapd/cancel.c b/servers/slapd/cancel.c index dd98928941..4416869ad2 100644 --- a/servers/slapd/cancel.c +++ b/servers/slapd/cancel.c @@ -76,8 +76,7 @@ int cancel_extop( } ldap_pvt_thread_mutex_unlock( &conn->c_mutex ); - if ( found ) - return LDAP_SUCCESS; + if ( found ) return LDAP_SUCCESS; found = 0; ldap_pvt_thread_mutex_lock( &conn->c_mutex ); @@ -91,9 +90,13 @@ int cancel_extop( if ( !found ) { #ifdef LDAP_SYNC for ( i = 0; i < nbackends; i++ ) { - if ( strncmp( backends[i].be_type, "bdb", 3 ) ) continue; + Backend *be = &backends[i]; + if( !be->be_abandon ) continue; + + ldap_pvt_thread_mutex_unlock( &conn->c_mutex ); - if ( bdb_cancel( &backends[i], conn, opid ) == LDAP_SUCCESS ) { + + if ( be->be_cancel( be, conn, op, opid ) == LDAP_SUCCESS ) { return LDAP_SUCCESS; } else { *text = "message ID not found"; @@ -101,15 +104,15 @@ int cancel_extop( } } #else - *text = "message ID not found"; ldap_pvt_thread_mutex_unlock( &conn->c_mutex ); + *text = "message ID not found"; return LDAP_NO_SUCH_OPERATION; #endif } if ( op->o_cancel != SLAP_CANCEL_NONE ) { - *text = "message ID already being cancelled"; ldap_pvt_thread_mutex_unlock( &conn->c_mutex ); + *text = "message ID already being cancelled"; return LDAP_PROTOCOL_ERROR; } diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 8bf8df0e47..29b8d6e723 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -1226,6 +1226,8 @@ struct slap_backend_db { #define be_modify bd_info->bi_op_modify #define be_modrdn bd_info->bi_op_modrdn #define be_search bd_info->bi_op_search +#define be_abandon bd_info->bi_op_abandon +#define be_cancel bd_info->bi_op_cancel #define be_extended bd_info->bi_extended @@ -1402,6 +1404,9 @@ typedef int (BI_op_delete) LDAP_P((BackendDB *bd, typedef int (BI_op_abandon) LDAP_P((BackendDB *bd, struct slap_conn *c, struct slap_op *o, ber_int_t msgid)); +typedef int (BI_op_cancel) LDAP_P((BackendDB *bd, + struct slap_conn *c, struct slap_op *o, + ber_int_t msgid)); typedef int (BI_op_extended) LDAP_P(( BackendDB *be, @@ -1527,6 +1532,7 @@ struct slap_backend_info { BI_op_add *bi_op_add; BI_op_delete *bi_op_delete; BI_op_abandon *bi_op_abandon; + BI_op_cancel *bi_op_cancel; /* Extended Operations Helper */ BI_op_extended *bi_extended; -- 2.39.5