Return-Path: X-Original-To: apmail-hadoop-common-issues-archive@minotaur.apache.org Delivered-To: apmail-hadoop-common-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D66E11776A for ; Tue, 12 May 2015 00:28:00 +0000 (UTC) Received: (qmail 48713 invoked by uid 500); 12 May 2015 00:28:00 -0000 Delivered-To: apmail-hadoop-common-issues-archive@hadoop.apache.org Received: (qmail 48636 invoked by uid 500); 12 May 2015 00:28:00 -0000 Mailing-List: contact common-issues-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-issues@hadoop.apache.org Delivered-To: mailing list common-issues@hadoop.apache.org Received: (qmail 48287 invoked by uid 99); 12 May 2015 00:28:00 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 May 2015 00:28:00 +0000 Date: Tue, 12 May 2015 00:28:00 +0000 (UTC) From: "Anu Engineer (JIRA)" To: common-issues@hadoop.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (HADOOP-11957) if an IOException error is thrown in DomainSocket.close we go into infinite loop. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HADOOP-11957?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Anu Engineer updated HADOOP-11957: ---------------------------------- Status: Patch Available (was: Open) > if an IOException error is thrown in DomainSocket.close we go into infinite loop. > --------------------------------------------------------------------------------- > > Key: HADOOP-11957 > URL: https://issues.apache.org/jira/browse/HADOOP-11957 > Project: Hadoop Common > Issue Type: Bug > Components: net > Affects Versions: 2.7.1 > Reporter: Anu Engineer > Assignee: Anu Engineer > Attachments: HADOOP-11957.001.patch > > > if an IOException error is thrown in DomainSocket.close we go into infinite loop. > Issue : If the shutdown0(fd) call throws an IOException we break out of the if shutdown call but will continue to loop in the while loop infinitely since we have no way of decrementing the counter. Please scroll down and see the comment marked with Bug Bug to see where the issue is. > {code:title=DomainSocket.java} > @Override > public void close() throws IOException { > // Set the closed bit on this DomainSocket > int count = 0; > try { > count = refCount.setClosed(); > } catch (ClosedChannelException e) { > // Someone else already closed the DomainSocket. > return; > } > // Wait for all references to go away > boolean didShutdown = false; > boolean interrupted = false; > while (count > 0) { > if (!didShutdown) { > try { > // Calling shutdown on the socket will interrupt blocking system > // calls like accept, write, and read that are going on in a > // different thread. > shutdown0(fd); > } catch (IOException e) { > LOG.error("shutdown error: ", e); > } > didShutdown = true; > // *BUG BUG* <-- Here the code will never exit the loop > // if the count is greater then 0. we need to break out > // of the while loop in case of IOException Error > } > try { > Thread.sleep(10); > } catch (InterruptedException e) { > interrupted = true; > } > count = refCount.getReferenceCount(); > } > // At this point, nobody has a reference to the file descriptor, > // and nobody will be able to get one in the future either. > // We now call close(2) on the file descriptor. > // After this point, the file descriptor number will be reused by > // something else. Although this DomainSocket object continues to hold > // the old file descriptor number (it's a final field), we never use it > // again because this DomainSocket is closed. > close0(fd); > if (interrupted) { > Thread.currentThread().interrupt(); > } > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)