Revert "pthreadpool: maintain a global list of orphaned pthreadpool_tevent_jobs"
authorRalph Boehme <slow@samba.org>
Fri, 28 Dec 2018 08:02:54 +0000 (09:02 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 11 Jan 2019 22:11:14 +0000 (23:11 +0100)
This reverts commit 25756425aaf5465e56ea809cd415b6a387848919.

See the discussion in

https://lists.samba.org/archive/samba-technical/2018-December/131731.html

for the reasoning behind this revert.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
lib/pthreadpool/pthreadpool_tevent.c
lib/pthreadpool/pthreadpool_tevent.h

index 3eca605d0c4aa4b3dbcda0dd3b0cdbae14a10591..7fc49ce671e3a69181d89c74bb73654ea5d7bb56 100644 (file)
@@ -82,24 +82,6 @@ static int pthreadpool_tevent_destructor(struct pthreadpool_tevent *pool);
 
 static void pthreadpool_tevent_job_orphan(struct pthreadpool_tevent_job *job);
 
-static struct pthreadpool_tevent_job *orphaned_jobs;
-
-void pthreadpool_tevent_cleanup_orphaned_jobs(void)
-{
-       struct pthreadpool_tevent_job *job = NULL;
-       struct pthreadpool_tevent_job *njob = NULL;
-
-       for (job = orphaned_jobs; job != NULL; job = njob) {
-               njob = job->next;
-
-               /*
-                * The job destructor keeps the job alive
-                * (and in the list) or removes it from the list.
-                */
-               TALLOC_FREE(job);
-       }
-}
-
 static int pthreadpool_tevent_job_signal(int jobid,
                                         void (*job_fn)(void *private_data),
                                         void *job_private_data,
@@ -111,8 +93,6 @@ int pthreadpool_tevent_init(TALLOC_CTX *mem_ctx, unsigned max_threads,
        struct pthreadpool_tevent *pool;
        int ret;
 
-       pthreadpool_tevent_cleanup_orphaned_jobs();
-
        pool = talloc_zero(mem_ctx, struct pthreadpool_tevent);
        if (pool == NULL) {
                return ENOMEM;
@@ -185,8 +165,6 @@ static int pthreadpool_tevent_destructor(struct pthreadpool_tevent *pool)
        }
        pool->pool = NULL;
 
-       pthreadpool_tevent_cleanup_orphaned_jobs();
-
        return 0;
 }
 
@@ -340,18 +318,10 @@ static int pthreadpool_tevent_job_destructor(struct pthreadpool_tevent_job *job)
                /*
                 * state->im still there means, we need to wait for the
                 * immediate event to be triggered or just leak the memory.
-                *
-                * Move it to the orphaned list, if it's not already there.
                 */
                return -1;
        }
 
-       /*
-        * Finally remove from the orphaned_jobs list
-        * and let talloc destroy us.
-        */
-       DLIST_REMOVE(orphaned_jobs, job);
-
        return 0;
 }
 
@@ -393,15 +363,6 @@ static void pthreadpool_tevent_job_orphan(struct pthreadpool_tevent_job *job)
         */
        DLIST_REMOVE(job->pool->jobs, job);
 
-       /*
-        * Add it to the list of orphaned jobs,
-        * which may be cleaned up later.
-        *
-        * The destructor removes it from the list
-        * when possible or it denies the free
-        * and keep it in the list.
-        */
-       DLIST_ADD_END(orphaned_jobs, job);
        TALLOC_FREE(job);
 }
 
@@ -440,8 +401,6 @@ struct tevent_req *pthreadpool_tevent_job_send(
        struct pthreadpool_tevent_job *job = NULL;
        int ret;
 
-       pthreadpool_tevent_cleanup_orphaned_jobs();
-
        req = tevent_req_create(mem_ctx, &state,
                                struct pthreadpool_tevent_job_state);
        if (req == NULL) {
index fdb86e23757af78836b117736b0f83dca2ad6d84..10d3a71c40a7cb358e5c40f0242c41a697b229ec 100644 (file)
@@ -22,8 +22,6 @@
 
 #include <tevent.h>
 
-void pthreadpool_tevent_cleanup_orphaned_jobs(void);
-
 struct pthreadpool_tevent;
 
 int pthreadpool_tevent_init(TALLOC_CTX *mem_ctx, unsigned max_threads,