]> git.sur5r.net Git - openldap/blobdiff - servers/slurpd/rq.c
Backend lock wasn't being released properly.
[openldap] / servers / slurpd / rq.c
index 3fb842d48e99bef45be02c28dc2d144773efd584..4ef66727bd51014f8e0e09adbecd6f86089a5944 100644 (file)
  *
  */
 
+#include "portable.h"
+
 #include <stdio.h>
 
+#include <ac/stdlib.h>
+#include <ac/unistd.h>         /* get ftruncate() */
+
 #include "slurp.h"
 #include "globals.h"
 
 
-/* externs */
-#ifdef NEEDPROTOS
-extern void Re_dump( Re *re );
-#else /* NEEDPROTOS */
-extern void Re_dump();
-#endif /* NEEDPROTOS */
-
-#ifndef SYSERRLIST_IN_STDIO
-extern char *sys_errlist[];
-#endif /* SYSERRLIST_IN_STDIO */
-
 /*
  * Lock the replication queue.
  */
@@ -56,13 +50,10 @@ Rq_lock(
     Rq *rq
 )
 {
-    return( pthread_mutex_lock( &rq->rq_mutex ));
+    return( ldap_pvt_thread_mutex_lock( &rq->rq_mutex ));
 }
 
 
-
-
-
 /*
  * Unlock the replication queue.
  */
@@ -71,7 +62,7 @@ Rq_unlock(
     Rq *rq
 )
 {
-    return( pthread_mutex_unlock( &rq->rq_mutex ));
+    return( ldap_pvt_thread_mutex_unlock( &rq->rq_mutex ));
 }
 
 
@@ -89,8 +80,6 @@ Rq_gethead(
 }
 
 
-
-
 /*
  * Return the next item in the queue.  Callers should lock the queue before
  * calling this routine.
@@ -108,8 +97,6 @@ Rq_getnext(
 }
 
 
-
-
 /*
  * Delete the item at the head of the list.  The queue should be locked
  * by the caller before calling this routine.
@@ -144,8 +131,6 @@ Rq_delhead(
 }
 
 
-
-
 /* 
  * Add an entry to the tail of the replication queue.  Locking is handled
  * internally.  When items are added to the queue, this routine wakes
@@ -200,7 +185,7 @@ Rq_add(
     /* Increment count of items in queue */
     rq->rq_nre++;
     /* wake up any threads waiting for more work */
-    pthread_cond_broadcast( &rq->rq_more );
+    ldap_pvt_thread_cond_broadcast( &rq->rq_more );
 
     /* ... and unlock the queue */
     rq->rq_unlock( rq );
@@ -209,8 +194,6 @@ Rq_add(
 }
 
 
-
-
 /*
  * Garbage-collect the replication queue.  Locking is handled internally.
  */
@@ -234,7 +217,6 @@ Rq_gc(
 }
 
 
-
 /*
  * For debugging: dump the contents of the replication queue to a file.
  * Locking is handled internally.
@@ -268,7 +250,6 @@ Rq_dump(
 }
 
 
-
 /*
  * Write the contents of a replication queue to a file.  Returns zero if
  * successful, -1 if not.  Handles queue locking internally.  Callers should
@@ -317,8 +298,6 @@ Rq_write(
 }
 
 
-
-
 /*
  * Check to see if the private slurpd replication log needs trimming.
  * The current criteria are:
@@ -391,8 +370,6 @@ Rq_getcount(
 }
 
 
-
-
 /* 
  * Allocate and initialize an Rq object.
  */
@@ -421,8 +398,8 @@ Rq_init(
     (*rq)->rq_getcount = Rq_getcount;
 
     /* Initialize private data */
-    pthread_mutex_init( &((*rq)->rq_mutex), pthread_mutexattr_default );
-    pthread_cond_init( &((*rq)->rq_more), pthread_condattr_default );
+    ldap_pvt_thread_mutex_init( &((*rq)->rq_mutex) );
+    ldap_pvt_thread_cond_init( &((*rq)->rq_more) );
     (*rq)->rq_head = NULL;
     (*rq)->rq_tail = NULL;
     (*rq)->rq_nre = 0;
@@ -431,4 +408,3 @@ Rq_init(
 
     return 0;
 }
-