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 96D6D200D1B for ; Thu, 28 Sep 2017 01:32:05 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 955B31609EC; Wed, 27 Sep 2017 23:32:05 +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 DAC701609CA for ; Thu, 28 Sep 2017 01:32:04 +0200 (CEST) Received: (qmail 46118 invoked by uid 500); 27 Sep 2017 23:32:03 -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 46106 invoked by uid 99); 27 Sep 2017 23:32:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Sep 2017 23:32:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 49BE718120A for ; Wed, 27 Sep 2017 23:32:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.201 X-Spam-Level: X-Spam-Status: No, score=-99.201 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 7klQORZX_SpI for ; Wed, 27 Sep 2017 23:32:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id CBD9D610D2 for ; Wed, 27 Sep 2017 23:32: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 22E39E0EE9 for ; Wed, 27 Sep 2017 23:32:01 +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 608C0242BF for ; Wed, 27 Sep 2017 23:32:00 +0000 (UTC) Date: Wed, 27 Sep 2017 23:32:00 +0000 (UTC) From: "ASF GitHub Bot (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: Wed, 27 Sep 2017 23:32:05 -0000 [ https://issues.apache.org/jira/browse/ZOOKEEPER-2905?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16183436#comment-16183436 ] ASF GitHub Bot commented on ZOOKEEPER-2905: ------------------------------------------- Github user andschwa closed the pull request at: https://github.com/apache/zookeeper/pull/382 > 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 > Fix For: 3.5.4, 3.6.0, 3.4.11 > > > 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)