]> git.sur5r.net Git - openldap/commitdiff
implement search timeout when the remote server does not respond in the specified...
authorPierangelo Masarati <ando@openldap.org>
Fri, 26 Jan 2007 01:39:05 +0000 (01:39 +0000)
committerPierangelo Masarati <ando@openldap.org>
Fri, 26 Jan 2007 01:39:05 +0000 (01:39 +0000)
servers/slapd/back-meta/config.c
servers/slapd/back-meta/search.c

index 00b63027317b19d1b685dd0da4c7e10f7f190fa4..bb60979931db322d71c328ce7df30258425fc2a7 100644 (file)
@@ -973,10 +973,8 @@ meta_back_db_config(
                                        t = &tv[ SLAP_OP_MODIFY ];
                                } else if ( strncasecmp( argv[ c ], "compare", len ) == 0 ) {
                                        t = &tv[ SLAP_OP_COMPARE ];
-#if 0                          /* uses timelimit instead */
                                } else if ( strncasecmp( argv[ c ], "search", len ) == 0 ) {
                                        t = &tv[ SLAP_OP_SEARCH ];
-#endif
                                /* abandon makes little sense */
 #if 0                          /* not implemented yet */
                                } else if ( strncasecmp( argv[ c ], "extended", len ) == 0 ) {
index f6dbad8018e67bbb1a1490dbea98e725d3e6aa98..618c5224fadcb54a5c2ad449c607f52c7e69699e 100644 (file)
@@ -665,7 +665,8 @@ meta_back_search( Operation *op, SlapReply *rs )
        metaconn_t      *mc;
        struct timeval  save_tv = { 0, 0 },
                        tv;
-       time_t          stoptime = (time_t)-1;
+       time_t          stoptime = (time_t)(-1),
+                       lastres_time = slap_get_time();
        int             rc = 0, sres = LDAP_SUCCESS;
        char            *matched = NULL;
        int             last = 0, ncandidates = 0,
@@ -861,6 +862,22 @@ getconn:;
                int     gotit = 0,
                        doabandon = 0,
                        alreadybound = ncandidates;
+               time_t  curr_time = 0;
+
+               /* check timeout */
+               if ( mi->mi_timeout[ SLAP_OP_SEARCH ]
+                       && lastres_time > 0
+                       && ( slap_get_time() - lastres_time ) > mi->mi_timeout[ SLAP_OP_SEARCH ] )
+               {
+                       doabandon = 1;
+                       rs->sr_text = "Operation timed out";
+                       rc = rs->sr_err = LDAP_ADMINLIMIT_EXCEEDED;
+                       savepriv = op->o_private;
+                       op->o_private = (void *)i;
+                       send_ldap_result( op, rs );
+                       op->o_private = savepriv;
+                       goto finish;
+               }
 
                /* check time limit */
                if ( op->ors_tlimit != SLAP_NO_LIMIT
@@ -1072,9 +1089,11 @@ really_bad:;
                                continue;
 
                        default:
+                               lastres_time = slap_get_time();
+
                                /* only touch when activity actually took place... */
-                               if ( mi->mi_idle_timeout != 0 && msc->msc_time < op->o_time ) {
-                                       msc->msc_time = op->o_time;
+                               if ( mi->mi_idle_timeout != 0 && msc->msc_time < lastres_time ) {
+                                       msc->msc_time = lastres_time;
                                }
                                break;
                        }