From: Luke Howard Date: Sun, 19 Jan 2003 15:04:19 +0000 (+0000) Subject: return error codes from new internal API X-Git-Tag: NO_SLAP_OP_BLOCKS~601 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8866875e698fd2d1bf3d2923ca11c0a33db83fc8;p=openldap return error codes from new internal API --- diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index 24d5e5a737..06b862bb89 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -1133,25 +1133,41 @@ slapi_free_search_results_internal( Slapi_PBlock *pb ) /* * Internal API to prime a Slapi_PBlock with a Backend. */ -void slapi_backend_set_pb( Slapi_PBlock *pb, Backend *be ) +int slapi_backend_set_pb( Slapi_PBlock *pb, Backend *be ) { #if defined(LDAP_SLAPI) - slapi_pblock_set(pb, SLAPI_BACKEND, (void *)be); - slapi_pblock_set(pb, SLAPI_BE_TYPE, (void *)be->bd_info->bi_type); + int rc; + + rc = slapi_pblock_set(pb, SLAPI_BACKEND, (void *)be); + if (rc != LDAP_SUCCESS) + return rc; + + rc = slapi_pblock_set(pb, SLAPI_BE_TYPE, (void *)be->bd_info->bi_type); + if (rc != LDAP_SUCCESS) + return rc; +#else + return -1; #endif /* defined(LDAP_SLAPI) */ } /* * Internal API to prime a Slapi_PBlock with a Connection. */ -void slapi_connection_set_pb( Slapi_PBlock *pb, Connection *conn ) +int slapi_connection_set_pb( Slapi_PBlock *pb, Connection *conn ) { #if defined(LDAP_SLAPI) char *connAuthType; size_t len; + int rc; + + rc = slapi_pblock_set(pb, SLAPI_CONNECTION, (void *)conn); + if (rc != LDAP_SUCCESS) + return rc; + + rc = slapi_pblock_set(pb, SLAPI_CONN_ID, (void *)conn->c_connid); + if (rc != LDAP_SUCCESS) + return rc; - slapi_pblock_set(pb, SLAPI_CONNECTION, (void *)conn); - slapi_pblock_set(pb, SLAPI_CONN_ID, (void *)conn->c_connid); switch (conn->c_authz.sai_method) { case LDAP_AUTH_SASL: len = sizeof(SLAPD_AUTH_SASL) + conn->c_authz.sai_mech.bv_len; @@ -1172,23 +1188,31 @@ void slapi_connection_set_pb( Slapi_PBlock *pb, Connection *conn ) connAuthType = slapi_ch_strdup(SLAPD_AUTH_SSL); } if (connAuthType != NULL) { - slapi_pblock_set(pb, SLAPI_CONN_AUTHTYPE, (void *)connAuthType); + rc = slapi_pblock_set(pb, SLAPI_CONN_AUTHTYPE, (void *)connAuthType); + if (rc != LDAP_SUCCESS) + return rc; } if (conn->c_authz.sai_dn.bv_val != NULL) { char *connDn = slapi_ch_strdup(conn->c_authz.sai_dn.bv_val); - slapi_pblock_set(pb, SLAPI_CONN_DN, (void *)connDn); + rc = slapi_pblock_set(pb, SLAPI_CONN_DN, (void *)connDn); + if (rc != LDAP_SUCCESS) + return rc; } + return LDAP_SUCCESS; +#else + return -1; #endif /* defined(LDAP_SLAPI) */ } /* * Internal API to prime a Slapi_PBlock with an Operation. */ -void slapi_operation_set_pb( Slapi_PBlock *pb, Operation *op ) +int slapi_operation_set_pb( Slapi_PBlock *pb, Operation *op ) { #if defined(LDAP_SLAPI) int isRoot = 0; int isUpdateDn = 0; + int rc; Backend *be; if (slapi_pblock_get(pb, SLAPI_BACKEND, (void *)&be) != 0) { @@ -1199,12 +1223,31 @@ void slapi_operation_set_pb( Slapi_PBlock *pb, Operation *op ) isUpdateDn = be_isupdate(be, &op->o_ndn); } - slapi_pblock_set(pb, SLAPI_OPERATION, (void *)op); - slapi_pblock_set(pb, SLAPI_OPINITIATED_TIME, (void *)op->o_time); - slapi_pblock_set(pb, SLAPI_REQUESTOR_ISROOT, (void *)isRoot); - slapi_pblock_set(pb, SLAPI_REQUESTOR_ISUPDATEDN, (void *)isUpdateDn); - slapi_pblock_set(pb, SLAPI_REQCONTROLS, (void *)op->o_ctrls); - slapi_pblock_set(pb, SLAPI_REQUESTOR_DN, (void *)op->o_ndn.bv_val); + rc = slapi_pblock_set(pb, SLAPI_OPERATION, (void *)op); + if (rc != LDAP_SUCCESS) + return rc; + + rc = slapi_pblock_set(pb, SLAPI_OPINITIATED_TIME, (void *)op->o_time); + if (rc != LDAP_SUCCESS) + return rc; + + rc = slapi_pblock_set(pb, SLAPI_REQUESTOR_ISROOT, (void *)isRoot); + if (rc != LDAP_SUCCESS) + return rc; + + rc = slapi_pblock_set(pb, SLAPI_REQUESTOR_ISUPDATEDN, (void *)isUpdateDn); + if (rc != LDAP_SUCCESS) + return rc; + + rc = slapi_pblock_set(pb, SLAPI_REQCONTROLS, (void *)op->o_ctrls); + if (rc != LDAP_SUCCESS) + return rc; + + rc = slapi_pblock_set(pb, SLAPI_REQUESTOR_DN, (void *)op->o_ndn.bv_val); + + return rc; +#else + return -1; #endif } diff --git a/servers/slapd/slapi/slapi_utils.h b/servers/slapd/slapi/slapi_utils.h index 5f03a9b5b8..252a4f60dd 100644 --- a/servers/slapd/slapi/slapi_utils.h +++ b/servers/slapd/slapi/slapi_utils.h @@ -108,9 +108,9 @@ int slapi_audit_init_header( Connection *conn, Operation *op, int slapi_audit_send_record( Slapi_PBlock *pb, Connection *conn, Operation *op, int rc); -void slapi_backend_set_pb( Slapi_PBlock *pb, Backend *be ); -void slapi_connection_set_pb( Slapi_PBlock *pb, Connection *conn ); -void slapi_operation_set_pb( Slapi_PBlock *pb, Operation *op ); +int slapi_backend_set_pb( Slapi_PBlock *pb, Backend *be ); +int slapi_connection_set_pb( Slapi_PBlock *pb, Connection *conn ); +int slapi_operation_set_pb( Slapi_PBlock *pb, Operation *op ); extern ldap_pvt_thread_mutex_t slapi_hn_mutex; extern ldap_pvt_thread_mutex_t slapi_time_mutex;