Selaa lähdekoodia

Resoves: #484157
Summary: timelimit not honored in some cases
Description: Range search operations could take longer time than the time limit
depending upon the data size, but there was no chance to check the time limit
in the code (index_range_read). Thus, once the range search operation has
started, it could have lasted far exceeding the specified time limit.
I introduced the time check in the range search function.

Noriko Hosoi 17 vuotta sitten
vanhempi
sitoutus
a7371944f0
1 muutettua tiedostoa jossa 13 lisäystä ja 0 poistoa
  1. 13 0
      ldap/servers/slapd/back-ldbm/index.c

+ 13 - 0
ldap/servers/slapd/back-ldbm/index.c

@@ -1055,6 +1055,8 @@ index_range_read(
     int retry_count = 0;
     int is_and = 0;
     int sizelimit = 0;
+    time_t curtime, stoptime, optime;
+    int timelimit = -1;
 
     *err = 0;
     plen = strlen( prefix = index2prefix( indextype ));
@@ -1063,6 +1065,9 @@ index_range_read(
     {
         slapi_pblock_get(pb, SLAPI_SEARCH_SIZELIMIT, &sizelimit);
     }
+    slapi_pblock_get( pb, SLAPI_OPINITIATED_TIME, &optime );
+    slapi_pblock_get(pb, SLAPI_SEARCH_TIMELIMIT, &timelimit);
+    stoptime = optime + timelimit;
 
     /*
      * Determine the lookthrough_limit from the PBlock.
@@ -1307,6 +1312,14 @@ index_range_read(
                                   0, 0, 0);
             break;
         }
+        /* check time limit */
+        curtime = current_time();
+        if ( timelimit != -1 && curtime >= stoptime )
+        {
+            LDAPDebug(LDAP_DEBUG_TRACE, "index_range_read timelimit exceeded\n",
+                                  0, 0, 0);
+            break;
+        }
 
         /* Check to see if the operation has been abandoned (also happens
          * when the connection is closed by the client).