]> git.sur5r.net Git - openldap/commitdiff
do not assume that someone parsed the paged results response; in case, re-parse ...
authorPierangelo Masarati <ando@openldap.org>
Wed, 7 Apr 2010 00:53:36 +0000 (00:53 +0000)
committerPierangelo Masarati <ando@openldap.org>
Wed, 7 Apr 2010 00:53:36 +0000 (00:53 +0000)
servers/slapd/backglue.c

index 839cd490cf28909539fa3171599881432563af21..f983bd01131fe450f26294b8a83bb787cf8c15b6 100644 (file)
@@ -553,14 +553,18 @@ glue_op_search ( Operation *op, SlapReply *rs )
                                                 * Only remember the last one if there's more state left.
                                                 */
                                                if ( op->o_bd != b0 &&
-                                                       ( op->o_conn->c_pagedresults_state.ps_cookie ||
+                                                       ( !BER_BVISNULL( &op->o_conn->c_pagedresults_state.ps_cookieval ) ||
                                                        op->o_bd != gi->gi_n[0].gn_be ))
+                                               {
                                                        op->o_conn->c_pagedresults_state.ps_be = op->o_bd;
+                                               }
 
                                                /* Check whether the cookie is empty,
                                                 * and give remaining databases a chance
                                                 */
-                                               if ( op->o_bd != gi->gi_n[0].gn_be ) {
+                                               if ( op->o_bd != gi->gi_n[0].gn_be ||
+                                                       BER_BVISNULL( &op->o_conn->c_pagedresults_state.ps_cookieval ) )
+                                               {
                                                        int             c;
 
                                                        for ( c = 0; gs.ctrls[c] != NULL; c++ ) {
@@ -585,8 +589,8 @@ glue_op_search ( Operation *op, SlapReply *rs )
                                                                        if ( btmp == b0 ) {
                                                                                op->o_conn->c_pagedresults_state.ps_be = gi->gi_n[gi->gi_nodes - 1].gn_be;
 
-                                                                       } else if (i > 0 ) {
-                                                                               op->o_conn->c_pagedresults_state.ps_be = gi->gi_n[i - 1].gn_be;
+                                                                       } else {
+                                                                               op->o_conn->c_pagedresults_state.ps_be = gi->gi_n[(i > 0 ? i - 1: 0)].gn_be;
                                                                        }
 
                                                                        /* delete old, create new cookie with NOID */
@@ -614,6 +618,9 @@ glue_op_search ( Operation *op, SlapReply *rs )
                                                                        gs.ctrls[c] = newctrl;
 
                                                                        ber_free_buf( ber );
+
+                                                               } else {
+                                                                       op->o_conn->c_pagedresults_state.ps_be = op->o_bd;
                                                                }
                                                        }
                                                }