Return-Path: X-Original-To: apmail-hadoop-common-dev-archive@www.apache.org Delivered-To: apmail-hadoop-common-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A811EC1E8 for ; Thu, 11 Dec 2014 13:21:59 +0000 (UTC) Received: (qmail 77241 invoked by uid 500); 11 Dec 2014 13:21:57 -0000 Delivered-To: apmail-hadoop-common-dev-archive@hadoop.apache.org Received: (qmail 77166 invoked by uid 500); 11 Dec 2014 13:21:57 -0000 Mailing-List: contact common-dev-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-dev@hadoop.apache.org Received: (qmail 77155 invoked by uid 99); 11 Dec 2014 13:21:57 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Dec 2014 13:21:57 +0000 X-ASF-Spam-Status: No, hits=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of malcolm.kavalsky@oracle.com designates 141.146.126.69 as permitted sender) Received: from [141.146.126.69] (HELO aserp1040.oracle.com) (141.146.126.69) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Dec 2014 13:21:29 +0000 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id sBBDKRDD012996 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 11 Dec 2014 13:20:28 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by ucsinet22.oracle.com (8.14.5+Sun/8.14.5) with ESMTP id sBBDKQP0028599 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 11 Dec 2014 13:20:27 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userz7022.oracle.com (8.14.5+Sun/8.14.4) with ESMTP id sBBDKQub028565 for ; Thu, 11 Dec 2014 13:20:26 GMT Received: from [10.100.102.12] (/93.173.21.245) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Dec 2014 05:20:25 -0800 Message-ID: <54899A17.5020708@oracle.com> Date: Thu, 11 Dec 2014 15:20:23 +0200 From: malcolm User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: common-dev@hadoop.apache.org Subject: Re: Solaris Port References: <54858BDF.3030206@oracle.com> <54868426.5010206@oracle.com> <548820ED.2080105@oracle.com> <54892DC7.5010909@oracle.com> In-Reply-To: <54892DC7.5010909@oracle.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Source-IP: ucsinet22.oracle.com [156.151.31.94] X-Virus-Checked: Checked by ClamAV on apache.org FYI, there are a couple more files that reference sys_errlist directly (not just terror within exception.c) , but also hdfs_http_client.c and NativeiO.c On 12/11/2014 07:38 AM, malcolm wrote: > Hi Colin, > > Exactly, as you noticed, the problem is the thread-local buffer needed > to return from terror. > Currently, terror just returns a static string from an array, this is > fast, simple and error-proof. > > In order to use strerror_r inside terror, would require allocating a > buffer inside terror and depend on the caller to free the buffer > after using it, or to pass a buffer to terrror (which is basically the > same as strerror_r, rendering terror redundant). > Both cases require modification outside terror itself, as far as I can > tell, no simple fix. Unless you have an alternative which I haven't > thought of ? > > As far as I can tell, we have two choices: > > 1. Remove terror and replace calls with strerror_r, passing a buffer > from the callee. > Advantage: a more modern portable interface. > Disadvantage: All calls to terror need to be modified, though all > seem to be in a few files as far as I can tell. > > 2. Adding a sys_errlist array (ifdeffed for Solaris) > Advantage: no change to any calls to terror > Disadvantage: 2 additional files added to source tree (.c and .h) > and some minor ifdefs only used for Solaris. > > I think it is more a question of style than anything else, so I leave > you to make the call. > > Thanks for your patience, > Malcolm > > > > > > On 12/10/2014 09:54 PM, Colin McCabe wrote: >> On Wed, Dec 10, 2014 at 2:31 AM, malcolm >> wrote: >>> Hi Colin, >>> >>> Thanks for the hints around JIRAs. >>> >>> You are correct errno still exists, however sys_errlist does not. >>> >>> Hadoop uses a function terror (defined in exception.c) which indexes >>> sys_errlist by errno to return the error message from the array. This >>> function is called 26 times in various places (in 2.2) >>> >>> Originally, I thought to replace all calls to terror with strerror, but >>> there can be issues with multi-threading (it returns a buffer which >>> can be >>> overwritten), so it seemed simpler just to recreate the sys_errlist >>> message >>> array. >>> >>> There is also a multi-threaded version strerror_r where you pass the >>> buffer >>> as a parameter, but this would necessitate changing every call to >>> terror >>> with mutiple lines of code. >> Why don't you just use strerror_r inside terror()? >> >> I wrote that code originally. The reason I didn't want to use >> strerror_r there is because GNU libc provides a non-POSIX definition >> of strerror_r, and forcing it to use the POSIX one is a pain. But you >> can do it. You also will require a thread-local buffer to hold the >> return from strerror_r, since it is not guaranteed to be static >> (although in practice it is 99% of the time-- another annoyance with >> the API). >> >> >