View | Details | Raw Unified | Return to bug 59797
Collapse All | Expand All

(-)file_not_specified_in_diff (-10 / +86 lines)
Line  Link Here
0
-- a/java/org/apache/catalina/core/StandardThreadExecutor.java
0
++ b/java/org/apache/catalina/core/StandardThreadExecutor.java
Lines 18-23 Link Here
18
package org.apache.catalina.core;
18
package org.apache.catalina.core;
19
import java.util.concurrent.RejectedExecutionException;
19
import java.util.concurrent.RejectedExecutionException;
20
import java.util.concurrent.ThreadFactory;
20
import java.util.concurrent.TimeUnit;
21
import java.util.concurrent.TimeUnit;
21
import org.apache.catalina.Executor;
22
import org.apache.catalina.Executor;
Lines 27-36 import org.apache.catalina.util.LifecycleMBeanBase; Link Here
27
import org.apache.tomcat.util.threads.ResizableExecutor;
28
import org.apache.tomcat.util.threads.ResizableExecutor;
28
import org.apache.tomcat.util.threads.TaskQueue;
29
import org.apache.tomcat.util.threads.TaskQueue;
29
import org.apache.tomcat.util.threads.TaskThreadFactory;
30
import org.apache.tomcat.util.threads.TaskThreadFactory;
31
import org.apache.tomcat.util.threads.ThreadCreator;
30
import org.apache.tomcat.util.threads.ThreadPoolExecutor;
32
import org.apache.tomcat.util.threads.ThreadPoolExecutor;
31
public class StandardThreadExecutor extends LifecycleMBeanBase
33
public class StandardThreadExecutor extends LifecycleMBeanBase
32
        implements Executor, ResizableExecutor {
34
        implements Executor, ResizableExecutor, ThreadCreator {
33
    // ---------------------------------------------- Properties
35
    // ---------------------------------------------- Properties
34
    /**
36
    /**
Lines 319-324 public class StandardThreadExecutor extends Link Here
319
        return false;
321
        return false;
320
    }
322
    }
323
    @Override
324
    public ThreadFactory getThreadFactory() {
325
        return executor.getThreadFactory();
326
    }
321
    @Override
327
    @Override
322
    protected String getDomainInternal() {
328
    protected String getDomainInternal() {
323
-- a/java/org/apache/tomcat/jni/SSL.java
329
++ b/java/org/apache/tomcat/jni/SSL.java
Lines 388-391 public final class SSL { Link Here
388
     * @return true if all SSL_OP_* are supported by OpenSSL library.
388
     * @return true if all SSL_OP_* are supported by OpenSSL library.
389
     */
389
     */
390
    public static native boolean hasOp(int op);
390
    public static native boolean hasOp(int op);
391
392
    /**
393
     * Cleanup thread specific data structures. This needs to be
394
     * has completed ssl operations.
395
     */
396
    public static native void threadCleanup();
391
}
397
}
392
-- a/java/org/apache/tomcat/util/net/AprEndpoint.java
398
++ b/java/org/apache/tomcat/util/net/AprEndpoint.java
Lines 29-34 import java.util.concurrent.ConcurrentHashMap; Link Here
29
import java.util.concurrent.ConcurrentLinkedQueue;
29
import java.util.concurrent.ConcurrentLinkedQueue;
30
import java.util.concurrent.Executor;
30
import java.util.concurrent.Executor;
31
import java.util.concurrent.RejectedExecutionException;
31
import java.util.concurrent.RejectedExecutionException;
32
import java.util.concurrent.ThreadFactory;
32
import java.util.concurrent.atomic.AtomicInteger;
33
import java.util.concurrent.atomic.AtomicInteger;
33
import org.apache.juli.logging.Log;
34
import org.apache.juli.logging.Log;
Lines 50-55 import org.apache.tomcat.util.ExceptionUtils; Link Here
50
import org.apache.tomcat.util.net.AbstractEndpoint.Acceptor.AcceptorState;
51
import org.apache.tomcat.util.net.AbstractEndpoint.Acceptor.AcceptorState;
51
import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
52
import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
52
import org.apache.tomcat.util.security.PrivilegedSetTccl;
53
import org.apache.tomcat.util.security.PrivilegedSetTccl;
54
import org.apache.tomcat.util.threads.TaskThreadFactory;
55
import org.apache.tomcat.util.threads.ThreadCreator;
53
/**
56
/**
Lines 670-675 public class AprEndpoint extends AbstractEndpoint<Long> { Link Here
670
                createExecutor();
673
                createExecutor();
671
            }
674
            }
675
            Executor executor = getExecutor();
676
            if (isSSLEnabled() && executor instanceof ThreadCreator) {
677
                ThreadFactory tf = ((ThreadCreator)
678
                if (tf instanceof TaskThreadFactory) {
679
                    ((TaskThreadFactory) tf).addCleanupTask(SSL_CLEANUP);
680
                }
681
            }
682
672
            initializeConnectionLatch();
683
            initializeConnectionLatch();
673
            // Start poller thread
684
            // Start poller thread
Lines 1024-1029 public class AprEndpoint extends AbstractEndpoint<Long> { Link Here
1024
        return log;
1035
        return log;
1025
    }
1036
    }
1037
    private static final Runnable SSL_CLEANUP = new Runnable() {
1038
        @Override
1039
        public void run() {
1040
            SSL.threadCleanup();
1041
        }
1042
    };
1043
1026
    // --------------------------------------------------- Acceptor Inner Class
1044
    // --------------------------------------------------- Acceptor Inner Class
1027
    /**
1045
    /**
1028
     * The background thread that listens for incoming TCP/IP connections and
1046
     * The background thread that listens for incoming TCP/IP connections and
1029
-- a/java/org/apache/tomcat/util/threads/TaskThreadFactory.java
1047
++ b/java/org/apache/tomcat/util/threads/TaskThreadFactory.java
Lines 16-21 Link Here
16
 */
16
 */
17
package org.apache.tomcat.util.threads;
17
package org.apache.tomcat.util.threads;
18
import java.util.Collection;
19
import java.util.concurrent.CopyOnWriteArrayList;
18
import java.util.concurrent.ThreadFactory;
20
import java.util.concurrent.ThreadFactory;
19
import java.util.concurrent.atomic.AtomicInteger;
21
import java.util.concurrent.atomic.AtomicInteger;
20
/**
22
/**
Lines 29-34 public class TaskThreadFactory implements ThreadFactory { Link Here
29
    private final String namePrefix;
31
    private final String namePrefix;
30
    private final boolean daemon;
32
    private final boolean daemon;
31
    private final int threadPriority;
33
    private final int threadPriority;
34
    private final Collection<Runnable> cleanupTasks = new
35
32
    public TaskThreadFactory(String namePrefix, boolean daemon, int priority) {
36
    public TaskThreadFactory(String namePrefix, boolean daemon, int priority) {
33
        SecurityManager s = System.getSecurityManager();
37
        SecurityManager s = System.getSecurityManager();
34
        group = (s != null) ? s.getThreadGroup() :
38
        group = (s != null) ? s.getThreadGroup() :
Lines 38-48 public class TaskThreadFactory implements ThreadFactory { Link Here
38
    }
42
    }
39
    @Override
43
    @Override
40
    public Thread newThread(Runnable r) {
44
    public Thread newThread(final Runnable r) {
41
        TaskThread t = new TaskThread(group, r, namePrefix +
45
        Runnable wrapped = new Runnable() {
46
            @Override
47
            public void run() {
48
                try {
49
                    r.run();
50
                } finally {
51
                    for (Runnable task : cleanupTasks) {
52
                        task.run();
53
                    }
54
                }
55
            }
56
        };
57
        TaskThread t = new TaskThread(group, wrapped, namePrefix +
42
        t.setDaemon(daemon);
58
        t.setDaemon(daemon);
43
        t.setPriority(threadPriority);
59
        t.setPriority(threadPriority);
44
        return t;
60
        return t;
45
    }
61
    }
62
    public void addCleanupTask(Runnable task) {
63
        synchronized (cleanupTasks) {
64
            if (!cleanupTasks.contains(task)) {
65
                cleanupTasks.add(task);
66
            }
67
        }
68
    }
69
70
    public boolean removeCleanupTask(Runnable task) {
71
        synchronized (cleanupTasks) {
72
            return cleanupTasks.remove(task);
73
        }
74
    }
46
}
75
}
47
-- /dev/null
76
++ b/java/org/apache/tomcat/util/threads/ThreadCreator.java
Line 0 Link Here
0
-- a/java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java
1
/*
2
 * ========================================================================
3
 *
4
 * Copyright (c) by Hitachi Data Systems, 2016. All rights reserved.
5
 *
6
 * ========================================================================
7
 */
8
package org.apache.tomcat.util.threads;
9
10
import java.util.concurrent.ThreadFactory;
11
12
public interface ThreadCreator {
13
    /**
14
     * @return The {@link ThreadFactory} used by this instance
15
     */
16
    ThreadFactory getThreadFactory();
17
}
18
++ b/java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java
Lines 34-40 import org.apache.tomcat.util.res.StringManager; Link Here
34
 * @author fhanik
34
 * @author fhanik
35
 *
35
 *
36
 */
36
 */
37
public class ThreadPoolExecutor extends
37
public class ThreadPoolExecutor extends
38
    /**
38
    /**
39
     * The string manager for this package.
39
     * The string manager for this package.
40
     */
40
     */

Return to bug 59797