]> git.sur5r.net Git - openldap/commitdiff
Improve prev commit
authorHoward Chu <hyc@openldap.org>
Thu, 9 Feb 2006 07:02:40 +0000 (07:02 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 9 Feb 2006 07:02:40 +0000 (07:02 +0000)
servers/slapd/back-bdb/cache.c

index 5f095e3a2aee9ca0758e76266d7f29e297838d91..1fdeafda92f90742a0e33f381d1569d477341ca2 100644 (file)
@@ -642,6 +642,7 @@ bdb_cache_lru_add(
                        rtask.arg = bdb;
                        bdb_cache_lru_purge( NULL, &rtask );
                } else {
+                       int wake = 0;
                        ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
                        if ( bdb->bi_cache_task ) {
                                if ( !ldap_pvt_runqueue_isrunning( &slapd_rq,
@@ -652,14 +653,18 @@ bdb_cache_lru_add(
                                                0 );
                                        /* But don't try to reschedule it while it's running */
                                        bdb->bi_cache_task->interval.tv_sec = 3600;
+                                       wake = 1;
                                }
                        } else {
                                bdb->bi_cache_task = ldap_pvt_runqueue_insert( &slapd_rq, 3600,
                                        bdb_cache_lru_purge, bdb, "bdb_cache_lru_purge",
                                        bdb->bi_dbenv_home );
+                               wake = 1;
                        }
                        ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
-                       slap_wake_listener();
+                       /* Don't bother waking if the purge task is already running */
+                       if ( wake )
+                               slap_wake_listener();
                }
        }
 }