[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openldap-bugs
Subject:    (ITS#2774
From:       john.matthews () crossml ! com
Date:       2003-11-19 22:17:50
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


FYI - this patch seemed to sort my problem out. I don't know why
ldap_pvt_thread_cond_wait() wasn't waking up when the thread was
signaled. Maybe a bug in pthreads? (I was using v10 as included with
RedHat9). This could be extended to timeout idle threads but I didn't
have time to add that functionality.

 

--- libraries/libldap_r/tpool.c.orig    2003-10-27 19:52:44.000000000
-0500

+++ libraries/libldap_r/tpool.c 2003-10-27 19:56:53.000000000 -0500

@@ -408,8 +408,21 @@

                         *       check timer, leave thread (break;)

                         */

 

-                       if (pool->ltp_state ==
LDAP_INT_THREAD_POOL_RUNNING)

-
ldap_pvt_thread_cond_wait(&pool->ltp_cond, &pool->ltp_mutex);

+                       if (pool->ltp_state ==
LDAP_INT_THREAD_POOL_RUNNING) {

+
//ldap_pvt_thread_cond_wait(&pool->ltp_cond, &pool->ltp_mutex);

+                               struct timespec to;

+                               memset(&to, 0, sizeof to);

+                               to.tv_sec = time(0) + 60;

+                               to.tv_nsec = 0;

+                               // syslog( ldap_syslog_level, "thread %d
waiting for signal\n", ldap_pvt_thread_self());

+                               int rc =
pthread_cond_timedwait(&pool->ltp_cond, &pool->ltp_mutex, &to);

+                               // Should be able to let this idle
thread die. TODO: Fix bug that makes slapd crash if we do this

+                               // if( (rc == ETIMEDOUT) &&
(pool->ltp_open_count > 1) && (pool->ltp_starting == 0) ) {

+                                       // syslog( ldap_syslog_level,
"thread %d timed out due to inactivity\n", ldap_pvt_thread_self());

+                                       // break;

+                               // }

+                               // syslog( ldap_syslog_level, "thread %d
got signal %d\n", ldap_pvt_thread_self(), rc);

+                       }

 

                        continue;

                }

 

 



John Matthews

CROSSML

Phone: 1300 305 110

 


[Attachment #5 (text/html)]

FYI - this patch seemed to sort my problem out. I = don’t know why \
ldap_pvt_thread_cond_wait() wasn’t waking up when the = thread was signaled. Maybe a \
bug in pthreads? (I was using v10 as included with = RedHat9). This could be extended \
to timeout idle threads but I didn’t have = time to add that functionality.



--- = libraries/libldap_r/tpool.c.orig    2003-10-27 19:52:44.000000000 -0500

+++ libraries/libldap_r/tpool.c 2003-10-27 19:56:53.000000000 -0500

@@ -408,8 +408,21 @@

         =                 *       check timer, leave thread = (break;)

         =                 */



-         = ;            =   if (pool->ltp_state == = LDAP_INT_THREAD_POOL_RUNNING)

-         = ;            =           ldap_pvt_thread_cond_wait(&pool->ltp_cond, = \
&pool->ltp_mutex);

+         = ;            =   if (pool->ltp_state == LDAP_INT_THREAD_POOL_RUNNING) = {

+         = ;            =           //ldap_pvt_thread_cond_wait(&pool->ltp_cond, = \
&pool->ltp_mutex);

+         = ;            =           struct timespec to;

+         = ;            =           memset(&to, 0, sizeof to);

+         = ;            =           to.tv_sec = time(0) + 60;

+         = ;            =           to.tv_nsec = 0;

+         = ;            =           // syslog( ldap_syslog_level, "thread %d waiting \
for = signal\n", ldap_pvt_thread_self());

+         = ;            =           int rc = pthread_cond_timedwait(&pool->ltp_cond, \
= &pool->ltp_mutex, &to);

+         = ;            =           // Should be able to let this idle thread die. \
TODO: Fix bug that makes = slapd crash if we do this

+         = ;                      /= / if( (rc == ETIMEDOUT) && \
(pool->ltp_open_count > 1) = && (pool->ltp_starting == 0) ) {

+         = ;            =                   // syslog( ldap_syslog_level, \
"thread %d timed out due to inactivity\n", ldap_pvt_thread_self());

+         = ;                              // break;

+         = ;            =           // }

+         = ;            =           // syslog( ldap_syslog_level, "thread %d got \
signal %d\n", = ldap_pvt_thread_self(), rc);

+         = ;            =   }



         =                continue;

      =           }





John Matthews

CROSSML

Phone: 1300 305 110


["image001.gif" (image/gif)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic