From owner-freebsd-java@FreeBSD.ORG Thu Jun 26 21:07:47 2014 Return-Path: Delivered-To: freebsd-java@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BA57D6F4 for ; Thu, 26 Jun 2014 21:07:47 +0000 (UTC) Received: from mail-lb0-x22d.google.com (mail-lb0-x22d.google.com [IPv6:2a00:1450:4010:c04::22d]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4935B28A1 for ; Thu, 26 Jun 2014 21:07:47 +0000 (UTC) Received: by mail-lb0-f173.google.com with SMTP id s7so3372684lbd.18 for ; Thu, 26 Jun 2014 14:07:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=mWswNvVWwICcxvG3FRh9n9jlwSw3s1ww9PmCpApnuYY=; b=K+G30t6DmkgPnHNZMHUzPQiqwJulBhGgdlAf/AqMmbbVUaZlBNKiBTH2et1fulys8l ezCt2Hr9Sb6XwhmBy5kINKzGGQpsdQ7nzquCFiCnBwvvwc8lf+zzyD59JGnVd5mQBLw4 d7jTzbnMaZ5OBYnkjwdlU7wSRScDGkJOjY7IBoWxU4mvN/Au4CdmLnmD6ifOm8xZge0O 54dfEgVud2aWqSOmj9gqpfOKFal8xc3xHzS41NCSsuDZ/DGnN+LLpfHs2YncpK6eDBNE nIuQLoyJMDobZOsK4AtJQviQQcPi3r+CyofyZY2UhIN1AnjZyJcSK9HyD0M6kq5RNv1+ orHQ== X-Received: by 10.112.136.73 with SMTP id py9mr2962lbb.100.1403816864042; Thu, 26 Jun 2014 14:07:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.114.245.161 with HTTP; Thu, 26 Jun 2014 14:07:13 -0700 (PDT) From: Dawid Weiss Date: Thu, 26 Jun 2014 23:07:13 +0200 Message-ID: Subject: A call to ServerSocketChannel.accept() cannot be interrupted. To: freebsd-java@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Jun 2014 21:07:47 -0000 Hi there, I am an Apache Lucene committer. We've encountered a problem on one of our test machines and I wondered if it's something known. The machine is: FreeBSD 9.1-RELEASE-p3 FreeBSD 9.1-RELEASE-p3 #0 r250118: Tue Apr 30 22:06:26 UTC 2013 running: openjdk version "1.7.0_60" OpenJDK Runtime Environment (build 1.7.0_60-b19) OpenJDK 64-Bit Server VM (build 24.60-b09, mixed mode) The problem is actually with Jetty; it creates a connector with a thread pool, where each thread calls a blocking ServerSocketChannel#accept(). Once you close the pool it attempts to terminate those threads and fails to do so -- and indeed, you can't break out from accept, not via interrupt(), not via closing the acquired ServerSocketChannel. The documentation of accept() states ClosedByInterruptException should be thrown if the thread is interrupted and indeed, this is the behavior on Linux and Windows. A test case and more verbose problem description is here: https://issues.apache.org/jira/browse/SOLR-6204 >From what I've diagnosed so far this seems to be an incomplete implementation problem. ServerSocketChannel attempts to signal the thread waiting on the socket (on Linux) via NativeThread.java, but in the native code (the only one I could find in ports) it's defined as: JNIEXPORT jlong JNICALL Java_sun_nio_ch_NativeThread_current(JNIEnv *env, jclass cl) { #ifdef __linux__ return (long)pthread_self(); #else return -1; #endif } JNIEXPORT void JNICALL Java_sun_nio_ch_NativeThread_signal(JNIEnv *env, jclass cl, jlong thread) { #ifdef __linux__ if (pthread_kill((pthread_t)thread, INTERRUPT_SIGNAL)) JNU_ThrowIOExceptionWithLastError(env, "Thread signal failed"); #endif Which would indicate a no-op call. And indeed, I recompiled ServerSocketChannel with some debugging sysouts and the NativeThread.current() call returns -1. Thoughts? Dawid