zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ph...@apache.org
Subject zookeeper git commit: ZOOKEEPER-2905: Don't include `config.h` in `zookeeper.h`
Date Wed, 27 Sep 2017 22:26:57 GMT
Repository: zookeeper
Updated Branches:
  refs/heads/branch-3.4 2d096b480 -> bd526c11a


ZOOKEEPER-2905: Don't include `config.h` in `zookeeper.h`

In ZOOKEEPER-2841 I fixed the inclusion of project-specific porting code
that were included in the public headers, which then broke upstream
projects (in my case, Mesos).

Unfortunately, I inadvertently created a very similar problem, and it
wasn't evident until the build was coupled with another project with the
same bug. More specifically, when including ZooKeeper in Mesos, and
including Google's Glog in Mesos, both projects define the macros
`VERSION`, `PACKAGE_VERSION`, and `PACKAGE_TARNAME`, and do so publicly.
This is commonly defined in `config.h` by Autotools (and by CMake for
ZooKeeper for compatibility), and is not a problem unless included
publicly, such as in `zookeeper.h`, and by more than one project.

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`. I erroneously added `#include "config.h"` and guarded
the includes "properly" with a feature guard. However, configuration
files such as `config.h` and `winconfig.h` etc. must never be included
in publicly in `zookeeper.h`, for the reasons given above.

This patch reverts the bug, and instead includes `config.h` in
`zookeeper.c`, where it is not exposed to other projects.

Author: Andrew Schwartzmeyer <andrew@schwartzmeyer.com>

Reviewers: Patrick Hunt <phunt@apache.org>

Closes #381 from andschwa/ZOOKEEPER-2905

Change-Id: I150b09839e8de993f68c03b4e28dec241f61e343


Project: http://git-wip-us.apache.org/repos/asf/zookeeper/repo
Commit: http://git-wip-us.apache.org/repos/asf/zookeeper/commit/bd526c11
Tree: http://git-wip-us.apache.org/repos/asf/zookeeper/tree/bd526c11
Diff: http://git-wip-us.apache.org/repos/asf/zookeeper/diff/bd526c11

Branch: refs/heads/branch-3.4
Commit: bd526c11a33bbe0bcb2a56ddbe09055c6bca70fc
Parents: 2d096b4
Author: Andrew Schwartzmeyer <andrew@schwartzmeyer.com>
Authored: Wed Sep 27 15:26:19 2017 -0700
Committer: Patrick Hunt <phunt@apache.org>
Committed: Wed Sep 27 15:26:19 2017 -0700

----------------------------------------------------------------------
 src/c/include/zookeeper.h | 8 ++------
 src/c/src/zookeeper.c     | 1 +
 2 files changed, 3 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zookeeper/blob/bd526c11/src/c/include/zookeeper.h
----------------------------------------------------------------------
diff --git a/src/c/include/zookeeper.h b/src/c/include/zookeeper.h
index 2503d69..aee865b 100644
--- a/src/c/include/zookeeper.h
+++ b/src/c/include/zookeeper.h
@@ -21,13 +21,9 @@
 
 #include <stdlib.h>
 
-#include "config.h"
-
-#ifdef HAVE_SYS_SOCKET_H
+/* we must not include config.h as a public header */
+#ifndef WIN32
 #include <sys/socket.h>
-#endif
-
-#ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
 #endif
 

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/bd526c11/src/c/src/zookeeper.c
----------------------------------------------------------------------
diff --git a/src/c/src/zookeeper.c b/src/c/src/zookeeper.c
index a8fef67..f8d42ff 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 <zookeeper.h>
 #include <zookeeper.jute.h>
 #include <proto.h>


Mime
View raw message