[SCM] Samba Shared Repository - branch v3-6-test updated

Volker Lendecke vlendec at samba.org
Tue Apr 26 05:33:51 MDT 2011


The branch, v3-6-test has been updated
       via  218e1fc s3: Fix a typo
       via  efc70fd s3: Allow unlimited parallelism in pthreadpool (cherry picked from commit dbc36befb5459cd59ffe2527261886ec962ea941)
      from  4572b33 s3: Remove unused code

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test


- Log -----------------------------------------------------------------
commit 218e1fc61d91020faf08cfc9f8b0a9b3e483ebb4
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Apr 26 12:40:07 2011 +0200

    s3: Fix a typo
    
    Autobuild-User: Volker Lendecke <vlendec at samba.org>
    Autobuild-Date: Tue Apr 26 13:31:08 CEST 2011 on sn-devel-104
    (cherry picked from commit 77ea148f7fca0b3d19fa5d4ec99010bba55c618d)

commit efc70fd0039302daa97223004d56f8c87f63a0df
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Apr 25 20:05:31 2011 +0200

    s3: Allow unlimited parallelism in pthreadpool
    (cherry picked from commit dbc36befb5459cd59ffe2527261886ec962ea941)

-----------------------------------------------------------------------

Summary of changes:
 source3/lib/pthreadpool/pthreadpool.c |   37 +++++++++++++++++++++++++--------
 source3/lib/pthreadpool/pthreadpool.h |    3 ++
 source3/smbd/vfs.c                    |    2 +-
 3 files changed, 32 insertions(+), 10 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/pthreadpool/pthreadpool.c b/source3/lib/pthreadpool/pthreadpool.c
index 2a75a52..3cf6cb7 100644
--- a/source3/lib/pthreadpool/pthreadpool.c
+++ b/source3/lib/pthreadpool/pthreadpool.c
@@ -85,11 +85,10 @@ struct pthreadpool {
 	int num_idle;
 
 	/*
-	 * An array of threads that require joining, the array has
-	 * "max_threads" elements. It contains "num_exited" ids.
+	 * An array of threads that require joining.
 	 */
 	int			num_exited;
-	pthread_t		exited[1]; /* We alloc more */
+	pthread_t		*exited; /* We alloc more */
 };
 
 static pthread_mutex_t pthreadpools_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -105,13 +104,9 @@ static void pthreadpool_prep_atfork(void);
 int pthreadpool_init(unsigned max_threads, struct pthreadpool **presult)
 {
 	struct pthreadpool *pool;
-	size_t size;
 	int ret;
 
-	size = sizeof(struct pthreadpool)
-		+ (max_threads-1) * sizeof(pthread_t);
-
-	pool = (struct pthreadpool *)malloc(size);
+	pool = (struct pthreadpool *)malloc(sizeof(struct pthreadpool));
 	if (pool == NULL) {
 		return ENOMEM;
 	}
@@ -140,6 +135,7 @@ int pthreadpool_init(unsigned max_threads, struct pthreadpool **presult)
 	pool->jobs = pool->last_job = NULL;
 	pool->num_threads = 0;
 	pool->num_exited = 0;
+	pool->exited = NULL;
 	pool->max_threads = max_threads;
 	pool->num_idle = 0;
 
@@ -215,7 +211,11 @@ static void pthreadpool_child(void)
 		assert(ret == 0);
 
 		pool->num_threads = 0;
+
 		pool->num_exited = 0;
+		free(pool->exited);
+		pool->exited = NULL;
+
 		pool->num_idle = 0;
 
 		while (pool->jobs != NULL) {
@@ -267,6 +267,11 @@ static void pthreadpool_join_children(struct pthreadpool *pool)
 		pthread_join(pool->exited[i], NULL);
 	}
 	pool->num_exited = 0;
+
+	/*
+	 * Deliberately not free and NULL pool->exited. That will be
+	 * re-used by realloc later.
+	 */
 }
 
 /*
@@ -377,6 +382,7 @@ int pthreadpool_destroy(struct pthreadpool *pool)
 	close(pool->sig_pipe[1]);
 	pool->sig_pipe[1] = -1;
 
+	free(pool->exited);
 	free(pool);
 
 	return 0;
@@ -387,7 +393,19 @@ int pthreadpool_destroy(struct pthreadpool *pool)
  */
 static void pthreadpool_server_exit(struct pthreadpool *pool)
 {
+	pthread_t *exited;
+
 	pool->num_threads -= 1;
+
+	exited = (pthread_t *)realloc(
+		pool->exited, sizeof(pthread_t *) * (pool->num_exited + 1));
+
+	if (exited == NULL) {
+		/* lost a thread status */
+		return;
+	}
+	pool->exited = exited;
+
 	pool->exited[pool->num_exited] = pthread_self();
 	pool->num_exited += 1;
 }
@@ -559,7 +577,8 @@ int pthreadpool_add_job(struct pthreadpool *pool, int job_id,
 		return res;
 	}
 
-	if (pool->num_threads >= pool->max_threads) {
+	if ((pool->max_threads != 0) &&
+	    (pool->num_threads >= pool->max_threads)) {
 		/*
 		 * No more new threads, we just queue the request
 		 */
diff --git a/source3/lib/pthreadpool/pthreadpool.h b/source3/lib/pthreadpool/pthreadpool.h
index 2553933..79704ea 100644
--- a/source3/lib/pthreadpool/pthreadpool.h
+++ b/source3/lib/pthreadpool/pthreadpool.h
@@ -39,6 +39,9 @@ struct pthreadpool;
  * @param[in]	max_threads	Maximum parallelism in this pool
  * @param[out]	presult		Pointer to the threadpool returned
  * @return			success: 0, failure: errno
+ *
+ * max_threads=0 means unlimited parallelism. The caller has to take
+ * care to not overload the system.
  */
 int pthreadpool_init(unsigned max_threads, struct pthreadpool **presult);
 
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index 39b30ec..3bde0a3 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -1008,7 +1008,7 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
 			/* fname can't have changed in resolved_path. */
 			const char *p = &resolved_name[rootdir_len];
 
-			/* *p ran be '\0' if fname was "." */
+			/* *p can be '\0' if fname was "." */
 			if (*p == '\0' && ISDOT(fname)) {
 				goto out;
 			}


-- 
Samba Shared Repository


More information about the samba-cvs mailing list