From owner-freebsd-java@FreeBSD.ORG Mon Jun 30 09:22:23 2014 Return-Path: Delivered-To: freebsd-java@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 434712B5; Mon, 30 Jun 2014 09:22:23 +0000 (UTC) Received: from mail-lb0-x22e.google.com (mail-lb0-x22e.google.com [IPv6:2a00:1450:4010:c04::22e]) (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 9451220D6; Mon, 30 Jun 2014 09:22:22 +0000 (UTC) Received: by mail-lb0-f174.google.com with SMTP id u10so5591599lbd.5 for ; Mon, 30 Jun 2014 02:22:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=0BLi3WY6QVPCmSw9RHnPBRnhh77ArP5v++k852IrzXk=; b=BpFZht4je0i7gZIhYzLwSj1OB9SaufCGnGV6OsrQ+qMIjDZip794kCDt5g/61iJYLu JsGftRHCwIELo6AJI4v7cYyGn2UqCdAiyJMP+lln0q2C+KZNF5QwtVaOlwUXY2en6aRX Io2cbrX0dTk67iHp5d2QLQ/myZkuTMvT7KGy34h0gmlMge8ci6y6epVPNsDRAPoygVp3 yIGTfV+jVy+CSM+foxAbzeF85071mhGmL+ro+OU3Qr1eLCgcMeoisgZjKybMoJz1wII2 xs3xOFRZjQdPv0wpdA9+IOnuPI6kXtSjS36LaswrgvNxjM5nBlYG/3xKncDCI1Zhh9H3 14Zg== X-Received: by 10.152.234.2 with SMTP id ua2mr28560558lac.34.1404120140191; Mon, 30 Jun 2014 02:22:20 -0700 (PDT) MIME-Version: 1.0 Received: by 10.114.245.161 with HTTP; Mon, 30 Jun 2014 02:21:50 -0700 (PDT) In-Reply-To: References: <53ACACC1.4020102@FreeBSD.org> <53ADBBAC.6060207@FreeBSD.org> From: Dawid Weiss Date: Mon, 30 Jun 2014 11:21:50 +0200 Message-ID: Subject: Re: A call to ServerSocketChannel.accept() cannot be interrupted. To: Jung-uk Kim Content-Type: text/plain; charset=UTF-8 Cc: Uwe Schindler , freebsd-java@freebsd.org 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: Mon, 30 Jun 2014 09:22:23 -0000 Works like a charm, Jung-uk, thanks! Dawid On Fri, Jun 27, 2014 at 9:55 PM, Dawid Weiss wrote: > Ugh, thanks Jung-uk! I didn't have the time to test yet, but we > certainly will. Your patch sounds sensible if it compiles and does > similar thing on the BSD; I'm actually surprised nobody raised this > issue before. > > I'll confirm if it's working as expected once we roll out the patch, > but big thanks for super-fast turnaround! > > Dawid > > On Fri, Jun 27, 2014 at 8:45 PM, Jung-uk Kim wrote: >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> On 2014-06-26 19:29:05 -0400, Jung-uk Kim wrote: >> 2014? 6? 26? 19:29, Jung-uk Kim ? ?:> On 2014-06-26 17:07:13 >> - -0400, Dawid Weiss wrote: >>>> 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? >>> >>> Can you please try this patch? >>> >>> https://svn.redports.org/jkim/java/openjdk7/files/patch-src-solaris-native-sun-nio-ch-NativeThread.c >> >> I >>> >> just committed it. >> >> http://svnweb.freebsd.org/changeset/ports/359595 >> >> At least, it passed your test case in the PR. ;-) >> >> Thanks! >> >> Jung-uk Kim >> -----BEGIN PGP SIGNATURE----- >> Version: GnuPG v2 >> >> iQEcBAEBAgAGBQJTrburAAoJEHyflib82/FGok8H/3Q4uTaQD76zQct7cQSkL6xH >> me42dXU4SgM6sH+VWBPqyi0ZMxvcYPyf4lx3tZSgM6CO9EeC8GEVBUq7w8X8ciQw >> xyIRwOyO3YcaQYJ3b4E6kO55ybRGbfIH+/ZTHwQ8nRVya3s1ZF6jnUKdWypz19h8 >> 9EqqARhIf2g5LqzFR73QibhdMtDlwRe6+pXxv6WaHVijhVmy4wbVC6f8aAyxPycs >> cmGeVnRQa+0pqZGFsbh62HS/7yEW8PrqNC2D0OunwA/hWQwopFOc7QbW0gzTYPv/ >> 74j1krlSpbgxo1LATVUsvpLbVQcIwcFtj0eMfslVmCg9FtZUl52Q2sVA68FAGyU= >> =amiL >> -----END PGP SIGNATURE-----