]> git.sur5r.net Git - openldap/commitdiff
more on ITS#6507
authorPierangelo Masarati <ando@openldap.org>
Thu, 8 Apr 2010 19:51:18 +0000 (19:51 +0000)
committerPierangelo Masarati <ando@openldap.org>
Thu, 8 Apr 2010 19:51:18 +0000 (19:51 +0000)
servers/slapd/back-bdb/search.c
servers/slapd/backglue.c
servers/slapd/controls.c

index 3a29064538405ac183648ac37f191d440a5aaff4..4e22809a04cee72f7474aa07ad3ff126ef095470 100644 (file)
@@ -1262,6 +1262,9 @@ parse_paged_cookie( Operation *op, SlapReply *rs )
                        goto done;
                }
 
+       } else {
+               /* we're going to use ps_cookie */
+               op->o_conn->c_pagedresults_state.ps_cookie = 0;
        }
 
 done:;
index 8911f1595e82d48ed374ecf63bcaf103d6a41a57..7c6de8fd6afb5f9ee106f0f99725580b4d56f28d 100644 (file)
@@ -549,12 +549,15 @@ glue_op_search ( Operation *op, SlapReply *rs )
                                         * from here on a subsequent request.
                                         */
                                        if ( rs->sr_nentries >= ps->ps_size ) {
+                                               PagedResultsState *cps = &op->o_conn->c_pagedresults_state;
+                                               
                                                /* Don't bother to remember the first backend.
                                                 * Only remember the last one if there's more state left.
                                                 */
                                                if ( op->o_bd != b0 &&
-                                                       ( !BER_BVISNULL( &op->o_conn->c_pagedresults_state.ps_cookieval ) ||
-                                                       op->o_bd != gi->gi_n[0].gn_be ))
+                                                       ( cps->ps_cookie != NOID
+                                                               || !BER_BVISNULL( &cps->ps_cookieval )
+                                                               || op->o_bd != gi->gi_n[0].gn_be ) )
                                                {
                                                        op->o_conn->c_pagedresults_state.ps_be = op->o_bd;
                                                }
@@ -562,9 +565,7 @@ glue_op_search ( Operation *op, SlapReply *rs )
                                                /* Check whether the cookie is empty,
                                                 * and give remaining databases a chance
                                                 */
-                                               if ( op->o_bd != gi->gi_n[0].gn_be ||
-                                                       BER_BVISNULL( &op->o_conn->c_pagedresults_state.ps_cookieval ) )
-                                               {
+                                               if ( op->o_bd != gi->gi_n[0].gn_be || cps->ps_cookie == NOID ) {
                                                        int             c;
 
                                                        for ( c = 0; gs.ctrls[c] != NULL; c++ ) {
@@ -620,7 +621,7 @@ glue_op_search ( Operation *op, SlapReply *rs )
 
                                                                        ber_free_buf( ber );
 
-                                                               } else if ( op->o_bd != gi->gi_n[0].gn_be ) {
+                                                               } else if ( !BER_BVISEMPTY( &cookie ) && op->o_bd != b0 ) {
                                                                        /* if cookie not empty, it's again this database's turn */
                                                                        op->o_conn->c_pagedresults_state.ps_be = op->o_bd;
                                                                }
@@ -635,14 +636,8 @@ glue_op_search ( Operation *op, SlapReply *rs )
                                         * next backend will start up properly. Only back-[bh]db
                                         * and back-sql look at this state info.
                                         */
-                                       if ( ps->ps_cookieval.bv_len == sizeof( PagedResultsCookie )) {
-                                               ps->ps_cookie = (PagedResultsCookie)0;
-#if 0
-                                               memset( ps->ps_cookieval.bv_val, 0,
-                                                       sizeof( PagedResultsCookie ));
-#endif
-                                               BER_BVZERO( &ps->ps_cookieval );
-                                       }
+                                       ps->ps_cookie = (PagedResultsCookie)0;
+                                       BER_BVZERO( &ps->ps_cookieval );
 
                                        {
                                                /* change the size of the page in the request
index 5d877ab683e102200a36d022d0ef953f8f859a4c..f8170df43fa1f8edf58afa98f409c2aa8dd38fdc 100644 (file)
@@ -1234,6 +1234,8 @@ static int parsePagedResults (
        if ( !cookie.bv_len ) {
                ps->ps_count = 0;
                ps->ps_cookie = 0;
+               /* taint ps_cookie, to detect whether it's set */
+               op->o_conn->c_pagedresults_state.ps_cookie = NOID;
        }
 
        /* NOTE: according to RFC 2696 3.: