Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 41906200D16 for ; Tue, 26 Sep 2017 01:00:06 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 402171609E9; Mon, 25 Sep 2017 23:00:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 84F9C1609BB for ; Tue, 26 Sep 2017 01:00:05 +0200 (CEST) Received: (qmail 9681 invoked by uid 500); 25 Sep 2017 23:00:04 -0000 Mailing-List: contact dev-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zookeeper.apache.org Delivered-To: mailing list dev@zookeeper.apache.org Received: (qmail 9670 invoked by uid 99); 25 Sep 2017 23:00:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Sep 2017 23:00:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id EFF0D1A13C9 for ; Mon, 25 Sep 2017 23:00:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id 4UvJW-bAdnZQ for ; Mon, 25 Sep 2017 23:00:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 4F25F5FC5D for ; Mon, 25 Sep 2017 23:00:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 88AFBE0041 for ; Mon, 25 Sep 2017 23:00:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 486BF24252 for ; Mon, 25 Sep 2017 23:00:00 +0000 (UTC) Date: Mon, 25 Sep 2017 23:00:00 +0000 (UTC) From: "Andrew Schwartzmeyer (JIRA)" To: dev@zookeeper.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (ZOOKEEPER-2905) Don't include `config.h` in `zookeeper.h` MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 25 Sep 2017 23:00:06 -0000 [ https://issues.apache.org/jira/browse/ZOOKEEPER-2905?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16179917#comment-16179917 ] Andrew Schwartzmeyer commented on ZOOKEEPER-2905: ------------------------------------------------- I didn't catch this sooner as the CMake build on Windows and Linux for Mesos uses a newer version of Glog than our Autotools build, which doesn't have this bug. So it was when my ZooKeeper patch with the bug was combined with an old version of Glog (0.3.3) which also had the bug, that I finally found it. > Don't include `config.h` in `zookeeper.h` > ----------------------------------------- > > Key: ZOOKEEPER-2905 > URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2905 > Project: ZooKeeper > Issue Type: Bug > Environment: Linux-ish environments. > Reporter: Andrew Schwartzmeyer > Assignee: Andrew Schwartzmeyer > > In ZOOKEEPER-2841 I fixed the inclusion of project-specific porting changes that were included in the public headers, which then broke upstream projects (in my case, Mesos). > Unfortunately, I inadvertently created the exact same problem for Linux (or really any system that uses Autotools), and it wasn't evident until the build was coupled with another project with the same problem. More specifically, when including ZooKeeper (with my changes) in Mesos, and including Google's Glog in Mesos, and building both with Autotools (which we also support), both packages define the pre-processor macro {{PACKAGE_VERSION}}, and so so publicly. This is defined in {{config.h}} by Autotools, and is not a problem _unless included publicly_. > When refactoring, I saw two includes in {{zookeeper.h}} that instead of being guarded by e.g. {{#ifdef HAVE_SYS_SOCKET_H}} were guarded by {{#ifndef WIN32}}. Without realizing that I would create the exact same problem I was elsewhere fixing, I erroneously added {{#include "config.h"}} and guarded the includes "properly." But there is _very good reasons_ not to do this (explained above). > The patch to fix this is simple: > {noformat} > diff --git a/src/c/include/zookeeper.h b/src/c/include/zookeeper.h > index d20e70af4..b0bb09e3f 100644 > --- a/src/c/include/zookeeper.h > +++ b/src/c/include/zookeeper.h > @@ -21,13 +21,9 @@ > #include > -#include "config.h" > - > -#ifdef HAVE_SYS_SOCKET_H > +/* we must not include config.h as a public header */ > +#ifndef WIN32 > #include > -#endif > - > -#ifdef HAVE_SYS_TIME_H > #include > #endif > diff --git a/src/c/src/zookeeper.c b/src/c/src/zookeeper.c > index 220c57dc4..9b837f227 100644 > --- a/src/c/src/zookeeper.c > +++ b/src/c/src/zookeeper.c > @@ -24,6 +24,7 @@ > #define USE_IPV6 > #endif > +#include "config.h" > #include > #include > #include > {noformat} > I am opening pull requests in a few minutes to have this applied to branch 3.4 and 3.5. > I'm sorry! -- This message was sent by Atlassian JIRA (v6.4.14#64029)