[Fedora-directory-commits] ldapserver/ldap/servers/slapd libglobs.c, 1.6, 1.6.2.1 proto-slap.h, 1.10.2.3, 1.10.2.4 connection.c, 1.8, 1.8.2.1 daemon.c, 1.6, 1.6.2.1 task.c, 1.7, 1.7.2.1 monitor.c, 1.5, 1.5.2.1 psearch.c, 1.5, 1.5.2.1 fe.h, 1.4, 1.4.2.1 globals.c, 1.4, 1.4.2.1

Noriko Hosoi (nhosoi) fedora-directory-commits at redhat.com
Fri Jan 11 01:09:17 UTC 2008


Author: nhosoi

Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv31666

Modified Files:
      Tag: Directory71RtmBranch
	libglobs.c proto-slap.h connection.c daemon.c task.c monitor.c 
	psearch.c fe.h globals.c 
Log Message:
Resolves: #240897
Summary: CRM 1474928 : ds7.1 db index/vlv not handling a stop-slapd, hangs slapd
Description: applied the patch to Directory71RtmBranch



Index: libglobs.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/libglobs.c,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -u -r1.6 -r1.6.2.1
--- libglobs.c	19 Apr 2005 22:07:36 -0000	1.6
+++ libglobs.c	11 Jan 2008 01:09:14 -0000	1.6.2.1
@@ -651,6 +651,29 @@
 }
 
 /*
+ * counter for active threads
+ */
+static PRInt32 active_threads = 0;
+
+void
+g_incr_active_threadcnt()
+{
+    PR_AtomicIncrement(&active_threads);
+}
+
+void
+g_decr_active_threadcnt()
+{
+    PR_AtomicDecrement(&active_threads);
+}
+
+int
+g_get_active_threadcnt()
+{
+    return (int)active_threads;
+}
+
+/*
 ** Setting this flag forces the server to shutdown.
 */
 static int slapd_shutdown;


Index: proto-slap.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/proto-slap.h,v
retrieving revision 1.10.2.3
retrieving revision 1.10.2.4
diff -u -r1.10.2.3 -r1.10.2.4
--- proto-slap.h	18 Mar 2006 17:48:37 -0000	1.10.2.3
+++ proto-slap.h	11 Jan 2008 01:09:14 -0000	1.10.2.4
@@ -196,6 +196,9 @@
 int g_get_deftime();
 void be_unbindall( Connection *conn, Operation *op); 
 int be_nbackends_public();
+void g_incr_active_threadcnt();
+void g_decr_active_threadcnt();
+int g_get_active_threadcnt();
 
 /*
  * bind.c


Index: connection.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/connection.c,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -u -r1.8 -r1.8.2.1
--- connection.c	12 May 2005 03:43:15 -0000	1.8
+++ connection.c	11 Jan 2008 01:09:14 -0000	1.8.2.1
@@ -393,7 +393,7 @@
 			LDAPDebug( LDAP_DEBUG_ANY, "PR_CreateThread failed, " SLAPI_COMPONENT_NAME_NSPR " error %d (%s)\n",
 				prerr, slapd_pr_strerror( prerr ), 0 );
 		} else {
-			PR_AtomicIncrement(&active_threads);
+			g_incr_active_threadcnt();
 		}
 	}
 }
@@ -730,7 +730,7 @@
 			}
 		}
 	}
-	PR_AtomicDecrement(&active_threads);
+	g_decr_active_threadcnt();
 }
 
 static int handle_read_data(Connection *conn,Operation **op,
@@ -1911,9 +1911,11 @@
 		   No bother to do so much calcuation, short-cut to non-turbo mode if no activities in passed interval */
 		new_mode = 0;
 	} else {
+	  double activet = 0.0;
 	  connection_find_our_rank(conn,&connection_count, &our_rank);
 	  LDAPDebug(LDAP_DEBUG_CONNS,"conn %d turbo rank = %d out of %d conns\n",conn->c_connid,our_rank,connection_count); 
-	  threshold_rank = (int)((double)active_threads * ((double)CONN_TURBO_PERCENTILE / 100.0) );
+	  activet = (double)g_get_active_threadcnt();
+	  threshold_rank = (int)(activet * ((double)CONN_TURBO_PERCENTILE / 100.0));
 
 	  /* adjust threshold_rank according number of connections,
 	     less turbo threads as more connections,
@@ -1986,7 +1988,7 @@
 		if( op_shutdown ) {
 			LDAPDebug( LDAP_DEBUG_TRACE, 
 			"op_thread received shutdown signal\n",	0, 0, 0 );
-			PR_AtomicDecrement(&active_threads);
+			g_decr_active_threadcnt();
 			return;
 		}
 
@@ -2002,7 +2004,7 @@
 				case CONN_SHUTDOWN:
 					LDAPDebug( LDAP_DEBUG_TRACE, 
 					"op_thread received shutdown signal\n", 					0,  0, 0 );
-					PR_AtomicDecrement(&active_threads);
+					g_decr_active_threadcnt();
 					return;
 				case CONN_FOUND_WORK_TO_DO:
 				default:
@@ -2065,7 +2067,7 @@
 			case CONN_SHUTDOWN:
 				LDAPDebug( LDAP_DEBUG_TRACE, 
 				"op_thread received shutdown signal\n", 					0,  0, 0 );
-				PR_AtomicDecrement(&active_threads);
+				g_decr_active_threadcnt();
 				return;
 			default:
 				break;
@@ -2296,7 +2298,7 @@
 #ifdef _WIN32 
     LDAPDebug( LDAP_DEBUG_ANY,
               "slapd shutting down - waiting for %d threads to terminate\n",
-              active_threads, 0, 0 );
+              g_get_active_threadcnt(), 0, 0 );
     /* kill off each worker waiting on GetQueuedCompletionStatus */
     for ( i = 0; i < max_threads; ++ i )
     {


Index: daemon.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/daemon.c,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -u -r1.6 -r1.6.2.1
--- daemon.c	19 Apr 2005 22:07:36 -0000	1.6
+++ daemon.c	11 Jan 2008 01:09:15 -0000	1.6.2.1
@@ -695,15 +695,16 @@
 	housekeeping_stop(); /* Run this after op_thread_cleanup() logged sth */
 
 #ifndef _WIN32
-	if ( active_threads > 0 ) {
+	threads = g_get_active_threadcnt();
+	if ( threads > 0 ) {
 		LDAPDebug( LDAP_DEBUG_ANY,
 			"slapd shutting down - waiting for %d thread%s to terminate\n",
-			active_threads, ( active_threads > 1 ) ? "s" : "", 0 );
+			threads, ( threads > 1 ) ? "s" : "", 0 );
 	}
 #endif
 
-	threads = active_threads;
-	while ( active_threads > 0 ) {
+	threads = g_get_active_threadcnt();
+	while ( threads > 0 ) {
 		PRPollDesc xpd;
 		char x;
 		int spe = 0;
@@ -733,11 +734,11 @@
 		    /* no data */
 		}
 		DS_Sleep(PR_INTERVAL_NO_WAIT);
-		if ( threads != active_threads )  {
+		if ( threads != g_get_active_threadcnt() )  {
 			LDAPDebug( LDAP_DEBUG_TRACE,
 					"slapd shutting down - waiting for %d threads to terminate\n",
-					active_threads, 0, 0 );
-			threads = active_threads;
+					g_get_active_threadcnt(), 0, 0 );
+			threads = g_get_active_threadcnt();
 		}
 	}
 
@@ -1096,7 +1097,7 @@
 		snmp_collator_update();
 
 		prevtime = curtime;
-		num_active_threads = active_threads;
+		num_active_threads = g_get_active_threadcnt();
 		if ( (num_active_threads == 0)  || 
 			(difftime(curtime, housekeeping_fire_time) >= 
 		slapd_housekeeping_timer*3) ) {


Index: task.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/task.c,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- task.c	19 Apr 2005 22:07:37 -0000	1.7
+++ task.c	11 Jan 2008 01:09:15 -0000	1.7.2.1
@@ -585,6 +585,7 @@
     int count;
     Slapi_Task *task = pb->pb_task;
 
+    g_incr_active_threadcnt();
     for (count = 0, inp = instance_names; *inp; inp++, count++)
         ;
     task->task_work = count;
@@ -684,6 +685,7 @@
     task->task_exitcode = rv;
     task->task_state = SLAPI_TASK_FINISHED;
     slapi_task_status_changed(task);
+    g_decr_active_threadcnt();
 }
 
 static int task_export_add(Slapi_PBlock *pb, Slapi_Entry *e,
@@ -925,6 +927,7 @@
     Slapi_Task *task = pb->pb_task;
     int rv;
 
+    g_incr_active_threadcnt();
     task->task_work = 1;
     task->task_progress = 0;
     task->task_state = SLAPI_TASK_RUNNING;
@@ -953,6 +956,7 @@
 
     slapi_ch_free((void **)&pb->pb_seq_val);
     slapi_pblock_destroy(pb);
+    g_decr_active_threadcnt();
 }
 
 static int task_backup_add(Slapi_PBlock *pb, Slapi_Entry *e,
@@ -1068,6 +1072,7 @@
     Slapi_Task *task = pb->pb_task;
     int rv;
 
+    g_incr_active_threadcnt();
     task->task_work = 1;
     task->task_progress = 0;
     task->task_state = SLAPI_TASK_RUNNING;
@@ -1096,6 +1101,7 @@
 
     slapi_ch_free((void **)&pb->pb_seq_val);
     slapi_pblock_destroy(pb);
+    g_decr_active_threadcnt();
 }
 
 static int task_restore_add(Slapi_PBlock *pb, Slapi_Entry *e,
@@ -1219,6 +1225,7 @@
     Slapi_Task *task = pb->pb_task;
     int rv;
 
+    g_incr_active_threadcnt();
     task->task_work = 1;
     task->task_progress = 0;
     task->task_state = SLAPI_TASK_RUNNING;
@@ -1239,6 +1246,7 @@
     charray_free(pb->pb_db2index_attrs);
     slapi_ch_free((void **)&pb->pb_instance_name);
     slapi_pblock_destroy(pb);
+    g_decr_active_threadcnt();
 }
 
 static int task_index_add(Slapi_PBlock *pb, Slapi_Entry *e,


Index: monitor.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/monitor.c,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- monitor.c	19 Apr 2005 22:07:36 -0000	1.5
+++ monitor.c	11 Jan 2008 01:09:15 -0000	1.5.2.1
@@ -81,7 +81,7 @@
 	attrlist_replace( &e->e_attrs, "version", vals );
 	slapi_ch_free( (void **) &val.bv_val );
 
-	sprintf( buf, "%d", active_threads );
+	sprintf( buf, "%d", g_get_active_threadcnt() );
 	val.bv_val = buf;
 	val.bv_len = strlen( buf );
 	attrlist_replace( &e->e_attrs, "threads", vals );


Index: psearch.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/psearch.c,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- psearch.c	19 Apr 2005 22:07:36 -0000	1.5
+++ psearch.c	11 Jan 2008 01:09:15 -0000	1.5.2.1
@@ -290,7 +290,7 @@
 	char **pbattrs = NULL;
 	int conn_acq_flag = 0;
     
-    PR_AtomicIncrement( &active_threads );
+    g_incr_active_threadcnt();
 
     /* need to acquire a reference to this connection so that it will not
        be released or cleaned up out from under us */
@@ -438,7 +438,7 @@
 		pe_ch_free( &peq );
 	}
     slapi_ch_free((void **) &ps );
-    PR_AtomicDecrement(&active_threads);	
+    g_decr_active_threadcnt();
 }
 
 


Index: fe.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/fe.h,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- fe.h	19 Apr 2005 22:07:36 -0000	1.4
+++ fe.h	11 Jan 2008 01:09:15 -0000	1.4.2.1
@@ -51,7 +51,6 @@
 #endif /* DONT_DECLARE_SLAPD_LDAP_DEBUG */
 #endif
 #endif
-extern int active_threads;
 extern PRInt32 ops_initiated;
 extern PRInt32 ops_completed;
 extern PRLock *ops_mutex;


Index: globals.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/globals.c,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- globals.c	19 Apr 2005 22:07:36 -0000	1.4
+++ globals.c	11 Jan 2008 01:09:15 -0000	1.4.2.1
@@ -86,14 +86,12 @@
 /*
  * global variables that need mutex protection
  */
-int		active_threads;
 PRInt32		ops_initiated;
 PRInt32		ops_completed;
 PRLock		*ops_mutex;
 int		num_conns;
 PRLock		*num_conns_mutex;
 
-
 /*
   DEC/COMPAQ has released a patch for 4.0d (e?) which will speed up
   malloc/free considerably in multithreaded multiprocessor




More information about the Fedora-directory-commits mailing list