ID *ids,
ID *scopes );
-static void send_pagerequest_response(
+static int parse_paged_cookie( Operation *op, SlapReply *rs );
+
+static void send_paged_response(
Operation *op,
SlapReply *rs,
- ID lastid,
+ ID *lastid,
int tentries );
/* Dereference aliases for a single alias entry. Return the final
ID cursora, ida, cursoro, ido, *subscop2;
Entry *matched, *a;
EntryInfo *ei;
- struct berval bv_alias = { sizeof("alias")-1, "alias" };
+ struct berval bv_alias = BER_BVC( "alias" );
AttributeAssertion aa_alias;
Filter af;
DB_LOCK locka, lockr;
ida = bdb_idl_next(curscop, &cursora))
{
ei = NULL;
+retry1:
rs->sr_err = bdb_cache_find_id(op, NULL,
ida, &ei, 0, locker, &lockr );
if (rs->sr_err != LDAP_SUCCESS) {
+ if ( rs->sr_err == DB_LOCK_DEADLOCK ||
+ rs->sr_err == DB_LOCK_NOTGRANTED ) goto retry1;
continue;
}
a = ei->bei_e;
* Set the name so that the scope's IDL can be retrieved.
*/
ei = NULL;
+sameido:
rs->sr_err = bdb_cache_find_id(op, NULL, ido, &ei,
0, locker, &locka );
- if ( rs->sr_err != LDAP_SUCCESS ) goto nextido;
+ if ( rs->sr_err != LDAP_SUCCESS ) {
+ if ( rs->sr_err == DB_LOCK_DEADLOCK ||
+ rs->sr_err == DB_LOCK_NOTGRANTED )
+ goto sameido;
+ goto nextido;
+ }
e = ei->bei_e;
}
return rs->sr_err;
ps = bdb_drop_psearch( op, op->oq_abandon.rs_msgid );
if ( ps ) {
if ( ps->o_tmpmemctx ) {
- sl_mem_destroy( NULL, ps->o_tmpmemctx );
+ slap_sl_mem_destroy( NULL, ps->o_tmpmemctx );
}
slap_op_free ( ps );
return LDAP_SUCCESS;
rs->sr_err = LDAP_CANCELLED;
send_ldap_result( ps, rs );
if ( ps->o_tmpmemctx ) {
- sl_mem_destroy( NULL, ps->o_tmpmemctx );
+ slap_sl_mem_destroy( NULL, ps->o_tmpmemctx );
}
slap_op_free ( ps );
return LDAP_SUCCESS;
return bdb_do_search( op, rs, op, NULL, 0 );
}
+int bdb_psearch( Operation *op, SlapReply *rs, Operation *sop,
+ Entry *ps_e, int ps_type )
+{
+ int rc;
+
+ sop->o_private = op->o_private;
+ rc = bdb_do_search( op, rs, sop, ps_e, ps_type );
+ sop->o_private = NULL;
+
+ return rc;
+}
+
/* For persistent searches, op is the currently executing operation,
* sop is the persistent search. For regular searches, sop = op.
*/
BerVarray syncUUID_set = NULL;
int syncUUID_set_cnt = 0;
+ struct bdb_op_info *opinfo = NULL;
+ DB_TXN *ltid = NULL;
+
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ENTRY, "bdb_search\n", 0, 0, 0 );
#else
- Debug( LDAP_DEBUG_TRACE, "=> bdb_search\n",
- 0, 0, 0);
+ Debug( LDAP_DEBUG_TRACE, "=> bdb_search\n", 0, 0, 0);
#endif
attrs = sop->oq_search.rs_attrs;
+ opinfo = (struct bdb_op_info *) op->o_private;
+
if ( !IS_PSEARCH && sop->o_sync_mode & SLAP_SYNC_REFRESH_AND_PERSIST ) {
struct slap_session_entry *sent;
if ( sop->o_sync_state.sid >= 0 ) {
null_attr.an_desc = NULL;
null_attr.an_oc = NULL;
null_attr.an_oc_exclude = 0;
- null_attr.an_name.bv_len = 0;
- null_attr.an_name.bv_val = NULL;
+ BER_BVZERO( &null_attr.an_name );
for( num_ctrls = 0; num_ctrls < SLAP_MAX_RESPONSE_CONTROLS; num_ctrls++ ) {
ctrls[num_ctrls] = NULL;
attrs[0].an_desc = NULL;
attrs[0].an_oc = NULL;
attrs[0].an_oc_exclude = 0;
- attrs[0].an_name.bv_len = 0;
- attrs[0].an_name.bv_val = NULL;
+ BER_BVZERO( &attrs[0].an_name );
}
manageDSAit = get_manageDSAit( sop );
}
}
- rs->sr_err = LOCK_ID( bdb->bi_dbenv, &locker );
+ if ( opinfo ) {
+ ltid = opinfo->boi_txn;
+ locker = TXN_ID( ltid );
+ } else {
+ rs->sr_err = LOCK_ID( bdb->bi_dbenv, &locker );
- switch(rs->sr_err) {
- case 0:
- break;
- default:
- send_ldap_error( sop, rs, LDAP_OTHER, "internal error" );
- return rs->sr_err;
+ switch(rs->sr_err) {
+ case 0:
+ break;
+ default:
+ send_ldap_error( sop, rs, LDAP_OTHER, "internal error" );
+ return rs->sr_err;
+ }
}
if ( sop->o_req_ndn.bv_len == 0 ) {
ei_root.bei_e = &e_root;
ei_root.bei_parent = &ei_root;
e_root.e_private = &ei_root;
- e_root.e_id = 1;
+ e_root.e_id = 0;
+ BER_BVSTR( &e_root.e_nname, "" );
+ BER_BVSTR( &e_root.e_name, "" );
ei = &ei_root;
rs->sr_err = LDAP_SUCCESS;
} else {
dn2entry_retry:
/* get entry with reader lock */
- rs->sr_err = bdb_dn2entry( op, NULL, &sop->o_req_ndn, &ei,
+ rs->sr_err = bdb_dn2entry( op, ltid, &sop->o_req_ndn, &ei,
1, locker, &lock );
}
break;
case LDAP_BUSY:
send_ldap_error( sop, rs, LDAP_BUSY, "ldap server busy" );
- LOCK_ID_FREE (bdb->bi_dbenv, locker );
+ if ( !opinfo )
+ LOCK_ID_FREE (bdb->bi_dbenv, locker );
return LDAP_BUSY;
case DB_LOCK_DEADLOCK:
case DB_LOCK_NOTGRANTED:
goto dn2entry_retry;
default:
send_ldap_error( sop, rs, LDAP_OTHER, "internal error" );
- LOCK_ID_FREE (bdb->bi_dbenv, locker );
+ if ( !opinfo )
+ LOCK_ID_FREE (bdb->bi_dbenv, locker );
return rs->sr_err;
}
rs->sr_matched = matched_dn.bv_val;
send_ldap_result( sop, rs );
- LOCK_ID_FREE (bdb->bi_dbenv, locker );
+ if ( !opinfo )
+ LOCK_ID_FREE (bdb->bi_dbenv, locker );
if ( rs->sr_ref ) {
ber_bvarray_free( rs->sr_ref );
rs->sr_ref = NULL;
rs->sr_matched = matched_dn.bv_val;
send_ldap_result( sop, rs );
- LOCK_ID_FREE (bdb->bi_dbenv, locker );
+ if ( !opinfo )
+ LOCK_ID_FREE (bdb->bi_dbenv, locker );
ber_bvarray_free( rs->sr_ref );
rs->sr_ref = NULL;
ber_memfree( matched_dn.bv_val );
}
/* if not root and candidates exceed to-be-checked entries, abort */
- if ( sop->ors_limit /* isroot == TRUE */
- && sop->ors_limit->lms_s_unchecked != -1
- && BDB_IDL_N(candidates) > (unsigned) sop->ors_limit->lms_s_unchecked )
+ if ( sop->ors_limit /* isroot == FALSE */ &&
+ sop->ors_limit->lms_s_unchecked != -1 &&
+ BDB_IDL_N(candidates) > (unsigned) sop->ors_limit->lms_s_unchecked )
{
rs->sr_err = LDAP_ADMINLIMIT_EXCEEDED;
send_ldap_result( sop, rs );
goto done;
}
- if ( sop->ors_limit == NULL /* isroot == FALSE */
- || !sop->ors_limit->lms_s_pr_hide ) {
+ if ( sop->ors_limit == NULL /* isroot == TRUE */ ||
+ !sop->ors_limit->lms_s_pr_hide )
+ {
tentries = BDB_IDL_N(candidates);
}
- if ( get_pagedresults(sop) ) {
+ if ( get_pagedresults( sop ) > SLAP_NO_CONTROL ) {
+ /* deferred cookie parsing */
+ rs->sr_err = parse_paged_cookie( sop, rs );
+ if ( rs->sr_err != LDAP_SUCCESS ) {
+ send_ldap_result( sop, rs );
+ goto done;
+ }
+
if ( (ID)( sop->o_pagedresults_state.ps_cookie ) == 0 ) {
id = bdb_idl_first( candidates, &cursor );
goto done;
}
for ( id = bdb_idl_first( candidates, &cursor );
- id != NOID && id <= (ID)( sop->o_pagedresults_state.ps_cookie );
- id = bdb_idl_next( candidates, &cursor ) ) /* empty */;
+ id != NOID &&
+ id <= (ID)( sop->o_pagedresults_state.ps_cookie );
+ id = bdb_idl_next( candidates, &cursor ) )
+ {
+ /* empty */;
+ }
}
+
if ( cursor == NOID ) {
#ifdef NEW_LOGGING
LDAP_LOG ( OPERATION, RESULTS,
"bdb_search: no paged results candidates\n",
- 0, 0, 0 );
+ 0, 0, 0 );
#else
Debug( LDAP_DEBUG_TRACE,
"bdb_search: no paged results candidates\n",
0, 0, 0 );
#endif
- send_pagerequest_response( sop, rs, lastid, 0 );
+ send_paged_response( sop, rs, &lastid, 0 );
rs->sr_err = LDAP_OTHER;
goto done;
}
/* check time limit */
- if ( sop->ors_tlimit != -1 && slap_get_time() > stoptime ) {
+ if ( sop->ors_tlimit != SLAP_NO_LIMIT
+ && slap_get_time() > stoptime )
+ {
rs->sr_err = LDAP_TIMELIMIT_EXCEEDED;
rs->sr_ref = rs->sr_v2ref;
send_ldap_result( sop, rs );
id2entry_retry:
/* get the entry with reader lock */
ei = NULL;
- rs->sr_err = bdb_cache_find_id( op, NULL,
+ rs->sr_err = bdb_cache_find_id( op, ltid,
id, &ei, 0, locker, &lock );
if (rs->sr_err == LDAP_BUSY) {
#endif
case LDAP_SCOPE_SUBTREE: {
EntryInfo *tmp;
- for (tmp = BEI(e); tmp->bei_parent;
+ for (tmp = BEI(e); tmp;
tmp = tmp->bei_parent ) {
if ( tmp->bei_id == base.e_id ) {
scopeok = 1;
} else {
rs->sr_err = LDAP_COMPARE_TRUE;
}
+
} else {
if ( sop->o_sync_mode & SLAP_SYNC_REFRESH ) {
rc_sync = test_filter( sop, rs->sr_entry, &cookief );
#endif
}
entry_sync_state = LDAP_SYNC_ADD;
+
} else {
if ( no_sync_state_change ) {
goto loop_continue;
entry_sync_state = LDAP_SYNC_PRESENT;
}
}
+
} else {
rs->sr_err = test_filter( sop,
rs->sr_entry, sop->oq_search.rs_filter );
if ( rs->sr_err == LDAP_COMPARE_TRUE ) {
/* check size limit */
if ( --sop->ors_slimit == -1 &&
- sop->o_sync_slog_size == -1 )
+ sop->o_sync_slog_size == -1 )
{
if (!IS_PSEARCH) {
bdb_cache_return_entry_r( bdb->bi_dbenv,
goto done;
}
- if ( get_pagedresults(sop) ) {
+ if ( get_pagedresults(sop) > SLAP_NO_CONTROL ) {
if ( rs->sr_nentries >= sop->o_pagedresults_size ) {
- send_pagerequest_response( sop, rs,
- lastid, tentries );
+ send_paged_response( sop, rs, &lastid, tentries );
goto done;
}
lastid = id;
}
if (psid_e != NULL) free (psid_e);
}
+
if ( ps_type == LDAP_PSEARCH_BY_ADD ) {
entry_sync_state = LDAP_SYNC_ADD;
} else if ( ps_type == LDAP_PSEARCH_BY_DELETE ) {
rs->sr_err = LDAP_OTHER;
goto done;
}
+
if ( sop->o_sync_slog_size != -1 ) {
if ( entry_sync_state == LDAP_SYNC_DELETE ) {
result = slap_add_session_log( op, sop, e );
num_ctrls++, 1, &cookie );
if ( rs->sr_err != LDAP_SUCCESS ) goto done;
rs->sr_attrs = attrs;
+ rs->sr_operational_attrs = NULL;
rs->sr_ctrls = ctrls;
rs->sr_flags = 0;
result = send_search_entry( sop, rs );
if ( cookie.bv_val ) ch_free( cookie.bv_val );
- sl_free( ctrls[num_ctrls-1]->ldctl_value.bv_val,
- sop->o_tmpmemctx );
- sl_free( ctrls[--num_ctrls], sop->o_tmpmemctx );
+ slap_sl_free(
+ ctrls[num_ctrls-1]->ldctl_value.bv_val,
+ sop->o_tmpmemctx );
+ slap_sl_free( ctrls[--num_ctrls],
+ sop->o_tmpmemctx );
ctrls[num_ctrls] = NULL;
rs->sr_ctrls = NULL;
}
+
} else if ( ps_type == LDAP_PSEARCH_BY_PREMODIFY ) {
struct psid_entry* psid_e;
psid_e = (struct psid_entry *) ch_calloc(1,
ps_type, 0, 0);
#endif
}
+
} else {
if ( sop->o_sync_mode & SLAP_SYNC_REFRESH ) {
if ( rc_sync == LDAP_COMPARE_TRUE ) { /* ADD */
if ( rs->sr_err != LDAP_SUCCESS ) goto done;
rs->sr_ctrls = ctrls;
rs->sr_attrs = sop->oq_search.rs_attrs;
+ rs->sr_operational_attrs = NULL;
rs->sr_flags = 0;
result = send_search_entry( sop, rs );
- sl_free( ctrls[num_ctrls-1]->ldctl_value.bv_val,
- sop->o_tmpmemctx );
- sl_free( ctrls[--num_ctrls], sop->o_tmpmemctx );
+ slap_sl_free(
+ ctrls[num_ctrls-1]->ldctl_value.bv_val,
+ sop->o_tmpmemctx );
+ slap_sl_free( ctrls[--num_ctrls],
+ sop->o_tmpmemctx );
ctrls[num_ctrls] = NULL;
rs->sr_ctrls = NULL;
+
} else { /* PRESENT */
if ( sync_send_present_mode ) {
result = slap_build_syncUUID_set( sop,
syncUUID_set_cnt = 0;
}
}
+
} else {
result = 1;
}
}
+
} else {
rs->sr_attrs = sop->oq_search.rs_attrs;
+ rs->sr_operational_attrs = NULL;
rs->sr_ctrls = NULL;
rs->sr_flags = 0;
rs->sr_err = LDAP_SUCCESS;
case 1: /* entry not sent */
break;
case -1: /* connection closed */
- if (!IS_PSEARCH)
- bdb_cache_return_entry_r(bdb->bi_dbenv,
- &bdb->bi_cache, e, &lock);
+ if (!IS_PSEARCH) {
+ bdb_cache_return_entry_r(bdb->bi_dbenv,
+ &bdb->bi_cache, e, &lock);
+ }
e = NULL;
rs->sr_entry = NULL;
rs->sr_err = LDAP_OTHER;
goto done;
}
}
+
} else {
#ifdef NEW_LOGGING
LDAP_LOG ( OPERATION, RESULTS,
rs->sr_ctrls = NULL;
slap_send_syncinfo( sop, rs,
LDAP_TAG_SYNC_REFRESH_PRESENT, &cookie, 1, NULL, 0 );
+
} else {
if ( !no_sync_state_change ) {
int slog_found = 0;
{
if ( ps_list->o_sync_slog_size > 0 ) {
if ( ps_list->o_sync_state.sid ==
- sop->o_sync_state.sid ) {
+ sop->o_sync_state.sid )
+ {
slog_found = 1;
break;
}
}
ldap_pvt_thread_rdwr_runlock( &bdb->bi_pslist_rwlock );
}
+
rs->sr_err = LDAP_SUCCESS;
rs->sr_rspoid = LDAP_SYNC_INFO;
rs->sr_ctrls = NULL;
LDAP_TAG_SYNC_REFRESH_DELETE, &cookie, 1, NULL, 0 );
}
- if ( cookie.bv_val ) {
- ch_free( cookie.bv_val );
- }
+ if ( cookie.bv_val ) ch_free( cookie.bv_val );
+
} else {
/* refreshOnly mode */
struct berval cookie;
if ( sync_send_present_mode ) {
slap_build_sync_done_ctrl( sop, rs, ctrls,
num_ctrls++, 1, &cookie, LDAP_SYNC_REFRESH_PRESENTS );
+
} else {
if ( !no_sync_state_change ) {
int slog_found = 0;
}
ldap_pvt_thread_rdwr_runlock( &bdb->bi_pslist_rwlock );
}
+
slap_build_sync_done_ctrl( sop, rs, ctrls,
num_ctrls++, 1, &cookie, LDAP_SYNC_REFRESH_DELETES );
}
rs->sr_rspoid = NULL;
send_ldap_result( sop, rs );
if ( ctrls[num_ctrls-1]->ldctl_value.bv_val != NULL ) {
- sl_free( ctrls[num_ctrls-1]->ldctl_value.bv_val,
+ slap_sl_free( ctrls[num_ctrls-1]->ldctl_value.bv_val,
sop->o_tmpmemctx );
}
- sl_free( ctrls[--num_ctrls], sop->o_tmpmemctx );
+ slap_sl_free( ctrls[--num_ctrls], sop->o_tmpmemctx );
ctrls[num_ctrls] = NULL;
if ( cookie.bv_val ) ch_free( cookie.bv_val );
}
+
} else {
rs->sr_ctrls = NULL;
rs->sr_ref = rs->sr_v2ref;
rs->sr_err = (rs->sr_v2ref == NULL) ? LDAP_SUCCESS : LDAP_REFERRAL;
rs->sr_rspoid = NULL;
- send_ldap_result( sop, rs );
+ if ( get_pagedresults(sop) > SLAP_NO_CONTROL ) {
+ send_paged_response( sop, rs, NULL, 0 );
+ } else {
+ send_ldap_result( sop, rs );
+ }
}
}
bdb_cache_return_entry_r( bdb->bi_dbenv, &bdb->bi_cache, e, &lock );
}
- LOCK_ID_FREE( bdb->bi_dbenv, locker );
+ if ( !opinfo )
+ LOCK_ID_FREE( bdb->bi_dbenv, locker );
ber_bvfree( search_context_csn );
{
if( !get_manageDSAit(op) && !get_domainScope(op) ) {
/* match referral objects */
- struct berval bv_ref = { sizeof("referral")-1, "referral" };
+ struct berval bv_ref = BER_BVC( "referral" );
rf.f_choice = LDAP_FILTER_EQUALITY;
rf.f_ava = &aa_ref;
rf.f_av_desc = slap_schema.si_ad_objectClass;
#ifdef BDB_SUBENTRIES
if( get_subentries_visibility( op ) ) {
- struct berval bv_subentry = { sizeof("SUBENTRY")-1, "SUBENTRY" };
+ struct berval bv_subentry = BER_BVC( "SUBENTRY" );
sf.f_choice = LDAP_FILTER_EQUALITY;
sf.f_ava = &aa_subentry;
sf.f_av_desc = slap_schema.si_ad_objectClass;
return rc;
}
+static int
+parse_paged_cookie( Operation *op, SlapReply *rs )
+{
+ LDAPControl **c;
+ int rc = LDAP_SUCCESS;
+ ber_tag_t tag;
+ ber_int_t size;
+ BerElement *ber;
+ struct berval cookie = BER_BVNULL;
+
+ /* this function must be invoked only if the pagedResults
+ * control has been detected, parsed and partially checked
+ * by the frontend */
+ assert( get_pagedresults( op ) > SLAP_NO_CONTROL );
+
+ /* look for the appropriate ctrl structure */
+ for ( c = op->o_ctrls; c[0] != NULL; c++ ) {
+ if ( strcmp( c[0]->ldctl_oid, LDAP_CONTROL_PAGEDRESULTS ) == 0 )
+ {
+ break;
+ }
+ }
+
+ if ( c[0] == NULL ) {
+ rs->sr_text = "missing pagedResults control";
+ return LDAP_PROTOCOL_ERROR;
+ }
+
+ /* Already tested by frontend */
+ assert( c[0]->ldctl_value.bv_len > 0 );
+#if 0
+ if ( c[0]->ldctl_value.bv_len == 0 ) {
+ rs->sr_text = "paged results control value is empty (or absent)";
+ return LDAP_PROTOCOL_ERROR;
+ }
+#endif
+
+ /* Parse the control value
+ * realSearchControlValue ::= SEQUENCE {
+ * size INTEGER (0..maxInt),
+ * -- requested page size from client
+ * -- result set size estimate from server
+ * cookie OCTET STRING
+ * }
+ */
+ ber = ber_init( &c[0]->ldctl_value );
+ if ( ber == NULL ) {
+ rs->sr_text = "internal error";
+ return LDAP_OTHER;
+ }
+
+ tag = ber_scanf( ber, "{im}", &size, &cookie );
+
+ /* Already tested by frontend */
+ assert( tag != LBER_ERROR );
+#if 0
+ if ( tag == LBER_ERROR ) {
+ rs->sr_text = "paged results control could not be decoded";
+ rc = LDAP_PROTOCOL_ERROR;
+ goto done;
+ }
+#endif
+
+ /* Already tested by frontend */
+ assert( size >= 0 );
+#if 0
+ if ( size < 0 ) {
+ rs->sr_text = "paged results control size invalid";
+ rc = LDAP_PROTOCOL_ERROR;
+ goto done;
+ }
+#endif
+
+ /* cookie decoding/checks deferred to backend... */
+ if ( cookie.bv_len ) {
+ PagedResultsCookie reqcookie;
+ if( cookie.bv_len != sizeof( reqcookie ) ) {
+ /* bad cookie */
+ rs->sr_text = "paged results cookie is invalid";
+ rc = LDAP_PROTOCOL_ERROR;
+ goto done;
+ }
+
+ AC_MEMCPY( &reqcookie, cookie.bv_val, sizeof( reqcookie ));
+
+ if ( reqcookie > op->o_pagedresults_state.ps_cookie ) {
+ /* bad cookie */
+ rs->sr_text = "paged results cookie is invalid";
+ rc = LDAP_PROTOCOL_ERROR;
+ goto done;
+
+ } else if ( reqcookie < op->o_pagedresults_state.ps_cookie ) {
+ rs->sr_text = "paged results cookie is invalid or old";
+ rc = LDAP_UNWILLING_TO_PERFORM;
+ goto done;
+ }
+
+ } else {
+ /* Initial request. Initialize state. */
+#if 0
+ if ( op->o_conn->c_pagedresults_state.ps_cookie != 0 ) {
+ /* There's another pagedResults control on the
+ * same connection; reject new pagedResults controls
+ * (allowed by RFC2696) */
+ rs->sr_text = "paged results cookie unavailable; try later";
+ rc = LDAP_UNWILLING_TO_PERFORM;
+ goto done;
+ }
+#endif
+ op->o_pagedresults_state.ps_cookie = 0;
+ op->o_pagedresults_state.ps_count = 0;
+ }
+
+done:;
+ (void)ber_free( ber, 1 );
+
+ return rc;
+}
+
static void
-send_pagerequest_response(
+send_paged_response(
Operation *op,
SlapReply *rs,
- ID lastid,
+ ID *lastid,
int tentries )
{
LDAPControl ctrl, *ctrls[2];
BerElementBuffer berbuf;
BerElement *ber = (BerElement *)&berbuf;
- struct berval cookie = BER_BVNULL;
PagedResultsCookie respcookie;
+ struct berval cookie;
#ifdef NEW_LOGGING
LDAP_LOG ( OPERATION, ENTRY,
- "send_pagerequest_response: lastid: (0x%08lx) "
- "nentries: (0x%081x)\n",
- lastid, rs->sr_nentries, NULL );
+ "send_paged_response: lastid=0x%08lx nentries=%d\n",
+ lastid ? *lastid : 0, rs->sr_nentries, NULL );
#else
- Debug(LDAP_DEBUG_ARGS, "send_pagerequest_response: lastid: (0x%08lx) "
- "nentries: (0x%081x)\n", lastid, rs->sr_nentries, NULL );
+ Debug(LDAP_DEBUG_ARGS,
+ "send_paged_response: lastid=0x%08lx nentries=%d\n",
+ lastid ? *lastid : 0, rs->sr_nentries, NULL );
#endif
- ctrl.ldctl_value.bv_val = NULL;
+ BER_BVZERO( &ctrl.ldctl_value );
ctrls[0] = &ctrl;
ctrls[1] = NULL;
ber_init2( ber, NULL, LBER_USE_DER );
- respcookie = ( PagedResultsCookie )lastid;
+ if ( lastid ) {
+ respcookie = ( PagedResultsCookie )(*lastid);
+ cookie.bv_len = sizeof( respcookie );
+ cookie.bv_val = (char *)&respcookie;
+
+ } else {
+ respcookie = ( PagedResultsCookie )0;
+ BER_BVSTR( &cookie, "" );
+ }
+
op->o_conn->c_pagedresults_state.ps_cookie = respcookie;
- op->o_conn->c_pagedresults_state.ps_count = op->o_pagedresults_state.ps_count + rs->sr_nentries;
- cookie.bv_len = sizeof( respcookie );
- cookie.bv_val = (char *)&respcookie;
+ op->o_conn->c_pagedresults_state.ps_count =
+ op->o_pagedresults_state.ps_count + rs->sr_nentries;
- /*
- * FIXME: we should consider sending an estimate of the entries
- * left, after appropriate security check is done
- */
- ber_printf( ber, "{iO}", tentries, &cookie );
+ /* return size of 0 -- no estimate */
+ ber_printf( ber, "{iO}", 0, &cookie );
if ( ber_flatten2( ber, &ctrls[0]->ldctl_value, 0 ) == -1 ) {
goto done;
rs->sr_ctrls = ctrls;
rs->sr_err = LDAP_SUCCESS;
send_ldap_result( op, rs );
+ rs->sr_ctrls = NULL;
done:
(void) ber_free_buf( ber );