From 35cfc01fa2e395111f7d629f00dc06eecf35a709 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Thu, 26 Jul 2018 13:07:04 +0000 Subject: build: rename event.h to gf-event.h Newer FreeBSD versions (noticed with 10.3-RELEASE) provide a event.h file that on occasion gets included instead of the libglusterfs file. When this happens, 'struct event_pool' will not be defined and building will fail with errors like: autoscale-threads.c:18:55: error: incomplete definition of type 'struct event_pool' int thread_count = pool->eventthreadcount; ~~~~^ autoscale-threads.c:17:16: note: forward declaration of 'struct event_pool' struct event_pool *pool = ctx->event_pool; ^ This problem is caused by 'pkg-config --cflags uuid' that adds /usr/local/include to the GF_CPPFLAGS. The use of libuuid is preferred so that the contrib/uuid/ directory can be removed. By renaming event.h to gf-event.h there is no conflict between the different event.h files anymore and compiling on FreeBSD works without issues. Change-Id: Ie69f6b8a4f8f8e9630d39a86693eb74674f0f763 Updates: bz#1607319 Signed-off-by: Niels de Vos --- api/src/glfs-mgmt.c | 2 +- api/src/glfs-resolve.c | 2 +- api/src/glfs.c | 2 +- cli/src/cli-rl.c | 2 +- cli/src/cli.c | 2 +- configure.ac | 3 + glusterfsd/src/glusterfsd-mgmt.c | 2 +- glusterfsd/src/glusterfsd.c | 2 +- libglusterfs/src/Makefile.am | 2 +- libglusterfs/src/event-epoll.c | 2 +- libglusterfs/src/event-poll.c | 2 +- libglusterfs/src/event.c | 2 +- libglusterfs/src/event.h | 119 --------------------- libglusterfs/src/gf-event.h | 119 +++++++++++++++++++++ rpc/rpc-lib/src/autoscale-threads.c | 2 +- rpc/rpc-lib/src/rpcsvc.h | 2 +- rpc/rpc-transport/rdma/src/rdma.h | 2 +- rpc/rpc-transport/socket/src/socket.h | 2 +- .../features/changelog/src/changelog-rpc-common.h | 2 +- xlators/features/quota/src/quota.h | 2 +- xlators/protocol/client/src/client.c | 2 +- xlators/protocol/server/src/server.c | 2 +- 22 files changed, 141 insertions(+), 138 deletions(-) delete mode 100644 libglusterfs/src/event.h create mode 100644 libglusterfs/src/gf-event.h diff --git a/api/src/glfs-mgmt.c b/api/src/glfs-mgmt.c index 26b8538e38..911a733051 100644 --- a/api/src/glfs-mgmt.c +++ b/api/src/glfs-mgmt.c @@ -19,7 +19,7 @@ #include "glusterfs.h" #include "glfs.h" #include "dict.h" -#include "event.h" +#include "gf-event.h" #include "defaults.h" #include "rpc-clnt.h" diff --git a/api/src/glfs-resolve.c b/api/src/glfs-resolve.c index 4b764d9412..e7dd7dca10 100644 --- a/api/src/glfs-resolve.c +++ b/api/src/glfs-resolve.c @@ -19,7 +19,7 @@ #include "glusterfs.h" #include "logging.h" #include "stack.h" -#include "event.h" +#include "gf-event.h" #include "glfs-mem-types.h" #include "common-utils.h" #include "syncop.h" diff --git a/api/src/glfs.c b/api/src/glfs.c index 694e5e6f94..652520c41e 100644 --- a/api/src/glfs.c +++ b/api/src/glfs.c @@ -38,7 +38,7 @@ #include "glusterfs.h" #include "logging.h" #include "stack.h" -#include "event.h" +#include "gf-event.h" #include "glfs-mem-types.h" #include "common-utils.h" #include "syncop.h" diff --git a/cli/src/cli-rl.c b/cli/src/cli-rl.c index 4745cf4936..1bb9bf07c5 100644 --- a/cli/src/cli-rl.c +++ b/cli/src/cli-rl.c @@ -17,7 +17,7 @@ #include "cli-cmd.h" #include "cli-mem-types.h" -#include "event.h" +#include "gf-event.h" #include diff --git a/cli/src/cli.c b/cli/src/cli.c index 1ae56e8f53..025f72c974 100644 --- a/cli/src/cli.c +++ b/cli/src/cli.c @@ -54,7 +54,7 @@ #include "stack.h" #include "revision.h" #include "common-utils.h" -#include "event.h" +#include "gf-event.h" #include "syscall.h" #include "call-stub.h" #include diff --git a/configure.ac b/configure.ac index 627a7a939a..3c9602033e 100644 --- a/configure.ac +++ b/configure.ac @@ -1658,6 +1658,9 @@ AC_SUBST([GF_CPPFLAGS]) AM_CONDITIONAL([GF_LINUX_HOST_OS], test "${GF_HOST_OS}" = "GF_LINUX_HOST_OS") AM_CONDITIONAL([GF_DARWIN_HOST_OS], test "${GF_HOST_OS}" = "GF_DARWIN_HOST_OS") AM_CONDITIONAL([GF_BSD_HOST_OS], test "${GF_HOST_OS}" = "GF_BSD_HOST_OS") +if test "${GF_HOST_OS}" = "GF_BSD_HOST_OS"; then + AC_DEFINE(GF_BSD_HOST_OS, 1, [This is a BSD compatible OS.]) +fi AC_SUBST(GLUSTERD_WORKDIR) AM_CONDITIONAL([GF_INSTALL_GLUSTERD_WORKDIR], test ! -d ${GLUSTERD_WORKDIR} && test -d ${sysconfdir}/glusterd ) diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c index 1e9015440a..e954c1f3d3 100644 --- a/glusterfsd/src/glusterfsd-mgmt.c +++ b/glusterfsd/src/glusterfsd-mgmt.c @@ -15,7 +15,7 @@ #include "glusterfs.h" #include "dict.h" -#include "event.h" +#include "gf-event.h" #include "defaults.h" #include "rpc-clnt.h" diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index c16d2b6b90..d4b3a1139a 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -64,7 +64,7 @@ #include "glusterfsd.h" #include "revision.h" #include "common-utils.h" -#include "event.h" +#include "gf-event.h" #include "statedump.h" #include "latency.h" #include "glusterfsd-mem-types.h" diff --git a/libglusterfs/src/Makefile.am b/libglusterfs/src/Makefile.am index fc7cb8fd01..bfe0900e54 100644 --- a/libglusterfs/src/Makefile.am +++ b/libglusterfs/src/Makefile.am @@ -49,7 +49,7 @@ protocol-common.h: $(top_srcdir)/rpc/rpc-lib/src/protocol-common.h libglusterfs_la_HEADERS = common-utils.h defaults.h default-args.h \ dict.h glusterfs.h hashfn.h timespec.h logging.h xlator.h \ stack.h timer.h list.h inode.h call-stub.h compat.h fd.h \ - revision.h compat-errno.h event.h mem-pool.h byte-order.h \ + revision.h compat-errno.h gf-event.h mem-pool.h byte-order.h \ gf-dirent.h locking.h syscall.h iobuf.h globals.h statedump.h \ checksum.h daemon.h store.h rbthash.h iatt.h latency.h \ mem-types.h syncop.h cluster-syncop.h graph-utils.h trie.h \ diff --git a/libglusterfs/src/event-epoll.c b/libglusterfs/src/event-epoll.c index c1474c8bc6..ed58899caa 100644 --- a/libglusterfs/src/event-epoll.c +++ b/libglusterfs/src/event-epoll.c @@ -17,7 +17,7 @@ #include #include "logging.h" -#include "event.h" +#include "gf-event.h" #include "mem-pool.h" #include "common-utils.h" #include "syscall.h" diff --git a/libglusterfs/src/event-poll.c b/libglusterfs/src/event-poll.c index da69866fbf..797649f11b 100644 --- a/libglusterfs/src/event-poll.c +++ b/libglusterfs/src/event-poll.c @@ -17,7 +17,7 @@ #include #include "logging.h" -#include "event.h" +#include "gf-event.h" #include "mem-pool.h" #include "common-utils.h" #include "syscall.h" diff --git a/libglusterfs/src/event.c b/libglusterfs/src/event.c index 6562d86a99..61006c100f 100644 --- a/libglusterfs/src/event.c +++ b/libglusterfs/src/event.c @@ -17,7 +17,7 @@ #include #include "logging.h" -#include "event.h" +#include "gf-event.h" #include "mem-pool.h" #include "common-utils.h" #include "libglusterfs-messages.h" diff --git a/libglusterfs/src/event.h b/libglusterfs/src/event.h deleted file mode 100644 index c60b14ad04..0000000000 --- a/libglusterfs/src/event.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - Copyright (c) 2008-2012 Red Hat, Inc. - This file is part of GlusterFS. - - This file is licensed to you under your choice of the GNU Lesser - General Public License, version 3 or any later version (LGPLv3 or - later), or the GNU General Public License, version 2 (GPLv2), in all - cases as published by the Free Software Foundation. -*/ - -#ifndef _EVENT_H_ -#define _EVENT_H_ - -#include - -struct event_pool; -struct event_ops; -struct event_slot_poll; -struct event_slot_epoll; -struct event_data { - int idx; - int gen; -} __attribute__ ((__packed__, __may_alias__)); - - -typedef int (*event_handler_t) (int fd, int idx, int gen, void *data, - int poll_in, int poll_out, int poll_err); - -#define EVENT_EPOLL_TABLES 1024 -#define EVENT_EPOLL_SLOTS 1024 -#define EVENT_MAX_THREADS 1024 - -struct event_pool { - struct event_ops *ops; - - int fd; - int breaker[2]; - - int count; - struct event_slot_poll *reg; - struct event_slot_epoll *ereg[EVENT_EPOLL_TABLES]; - int slots_used[EVENT_EPOLL_TABLES]; - - int used; - int changed; - - pthread_mutex_t mutex; - pthread_cond_t cond; - - void *evcache; - int evcache_size; - - /* NOTE: Currently used only when event processing is done using - * epoll. */ - int eventthreadcount; /* number of event threads to execute. */ - pthread_t pollers[EVENT_MAX_THREADS]; /* poller thread_id store, - * and live status */ - int destroy; - int activethreadcount; - - /* - * Number of threads created by auto-scaling, *in addition to* the - * configured number of threads. This is only applicable on the - * server, where we try to keep the number of threads around the number - * of bricks. In that case, the configured number is just "extra" - * threads to handle requests in excess of one per brick (including - * requests on the GlusterD connection). For clients or GlusterD, this - * number will always be zero, so the "extra" is all we have. - * - * TBD: consider auto-scaling for clients as well - */ - int auto_thread_count; - -}; - -struct event_destroy_data { - int readfd; - struct event_pool *pool; -}; - -struct event_ops { - struct event_pool * (*new) (int count, int eventthreadcount); - - int (*event_register) (struct event_pool *event_pool, int fd, - event_handler_t handler, - void *data, int poll_in, int poll_out); - - int (*event_select_on) (struct event_pool *event_pool, int fd, int idx, - int poll_in, int poll_out); - - int (*event_unregister) (struct event_pool *event_pool, int fd, int idx); - - int (*event_unregister_close) (struct event_pool *event_pool, int fd, - int idx); - - int (*event_dispatch) (struct event_pool *event_pool); - - int (*event_reconfigure_threads) (struct event_pool *event_pool, - int newcount); - int (*event_pool_destroy) (struct event_pool *event_pool); - int (*event_handled) (struct event_pool *event_pool, int fd, int idx, - int gen); -}; - -struct event_pool *event_pool_new (int count, int eventthreadcount); -int event_select_on (struct event_pool *event_pool, int fd, int idx, - int poll_in, int poll_out); -int event_register (struct event_pool *event_pool, int fd, - event_handler_t handler, - void *data, int poll_in, int poll_out); -int event_unregister (struct event_pool *event_pool, int fd, int idx); -int event_unregister_close (struct event_pool *event_pool, int fd, int idx); -int event_dispatch (struct event_pool *event_pool); -int event_reconfigure_threads (struct event_pool *event_pool, int value); -int event_pool_destroy (struct event_pool *event_pool); -int event_dispatch_destroy (struct event_pool *event_pool); -int event_handled (struct event_pool *event_pool, int fd, int idx, int gen); - -#endif /* _EVENT_H_ */ diff --git a/libglusterfs/src/gf-event.h b/libglusterfs/src/gf-event.h new file mode 100644 index 0000000000..55a74ed17c --- /dev/null +++ b/libglusterfs/src/gf-event.h @@ -0,0 +1,119 @@ +/* + Copyright (c) 2008-2012 Red Hat, Inc. + This file is part of GlusterFS. + + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. +*/ + +#ifndef _GF_EVENT_H_ +#define _GF_EVENT_H_ + +#include + +struct event_pool; +struct event_ops; +struct event_slot_poll; +struct event_slot_epoll; +struct event_data { + int idx; + int gen; +} __attribute__ ((__packed__, __may_alias__)); + + +typedef int (*event_handler_t) (int fd, int idx, int gen, void *data, + int poll_in, int poll_out, int poll_err); + +#define EVENT_EPOLL_TABLES 1024 +#define EVENT_EPOLL_SLOTS 1024 +#define EVENT_MAX_THREADS 1024 + +struct event_pool { + struct event_ops *ops; + + int fd; + int breaker[2]; + + int count; + struct event_slot_poll *reg; + struct event_slot_epoll *ereg[EVENT_EPOLL_TABLES]; + int slots_used[EVENT_EPOLL_TABLES]; + + int used; + int changed; + + pthread_mutex_t mutex; + pthread_cond_t cond; + + void *evcache; + int evcache_size; + + /* NOTE: Currently used only when event processing is done using + * epoll. */ + int eventthreadcount; /* number of event threads to execute. */ + pthread_t pollers[EVENT_MAX_THREADS]; /* poller thread_id store, + * and live status */ + int destroy; + int activethreadcount; + + /* + * Number of threads created by auto-scaling, *in addition to* the + * configured number of threads. This is only applicable on the + * server, where we try to keep the number of threads around the number + * of bricks. In that case, the configured number is just "extra" + * threads to handle requests in excess of one per brick (including + * requests on the GlusterD connection). For clients or GlusterD, this + * number will always be zero, so the "extra" is all we have. + * + * TBD: consider auto-scaling for clients as well + */ + int auto_thread_count; + +}; + +struct event_destroy_data { + int readfd; + struct event_pool *pool; +}; + +struct event_ops { + struct event_pool * (*new) (int count, int eventthreadcount); + + int (*event_register) (struct event_pool *event_pool, int fd, + event_handler_t handler, + void *data, int poll_in, int poll_out); + + int (*event_select_on) (struct event_pool *event_pool, int fd, int idx, + int poll_in, int poll_out); + + int (*event_unregister) (struct event_pool *event_pool, int fd, int idx); + + int (*event_unregister_close) (struct event_pool *event_pool, int fd, + int idx); + + int (*event_dispatch) (struct event_pool *event_pool); + + int (*event_reconfigure_threads) (struct event_pool *event_pool, + int newcount); + int (*event_pool_destroy) (struct event_pool *event_pool); + int (*event_handled) (struct event_pool *event_pool, int fd, int idx, + int gen); +}; + +struct event_pool *event_pool_new (int count, int eventthreadcount); +int event_select_on (struct event_pool *event_pool, int fd, int idx, + int poll_in, int poll_out); +int event_register (struct event_pool *event_pool, int fd, + event_handler_t handler, + void *data, int poll_in, int poll_out); +int event_unregister (struct event_pool *event_pool, int fd, int idx); +int event_unregister_close (struct event_pool *event_pool, int fd, int idx); +int event_dispatch (struct event_pool *event_pool); +int event_reconfigure_threads (struct event_pool *event_pool, int value); +int event_pool_destroy (struct event_pool *event_pool); +int event_dispatch_destroy (struct event_pool *event_pool); +int event_handled (struct event_pool *event_pool, int fd, int idx, int gen); + +#endif /* _GF_EVENT_H_ */ diff --git a/rpc/rpc-lib/src/autoscale-threads.c b/rpc/rpc-lib/src/autoscale-threads.c index 33ba58c490..4840fd4e97 100644 --- a/rpc/rpc-lib/src/autoscale-threads.c +++ b/rpc/rpc-lib/src/autoscale-threads.c @@ -8,7 +8,7 @@ cases as published by the Free Software Foundation. */ -#include "event.h" +#include "gf-event.h" #include "rpcsvc.h" void diff --git a/rpc/rpc-lib/src/rpcsvc.h b/rpc/rpc-lib/src/rpcsvc.h index 7ed0dca2ad..c6efa4f536 100644 --- a/rpc/rpc-lib/src/rpcsvc.h +++ b/rpc/rpc-lib/src/rpcsvc.h @@ -11,7 +11,7 @@ #ifndef _RPCSVC_H #define _RPCSVC_H -#include "event.h" +#include "gf-event.h" #include "rpc-transport.h" #include "logging.h" #include "dict.h" diff --git a/rpc/rpc-transport/rdma/src/rdma.h b/rpc/rpc-transport/rdma/src/rdma.h index 7ca0ead1f7..39f7f45046 100644 --- a/rpc/rpc-transport/rdma/src/rdma.h +++ b/rpc/rpc-transport/rdma/src/rdma.h @@ -19,7 +19,7 @@ #include "rpc-clnt.h" #include "rpc-transport.h" #include "xlator.h" -#include "event.h" +#include "gf-event.h" #include #include #include diff --git a/rpc/rpc-transport/socket/src/socket.h b/rpc/rpc-transport/socket/src/socket.h index fdfc20774a..4e65489f98 100644 --- a/rpc/rpc-transport/socket/src/socket.h +++ b/rpc/rpc-transport/socket/src/socket.h @@ -21,7 +21,7 @@ #include #endif -#include "event.h" +#include "gf-event.h" #include "rpc-transport.h" #include "logging.h" #include "dict.h" diff --git a/xlators/features/changelog/src/changelog-rpc-common.h b/xlators/features/changelog/src/changelog-rpc-common.h index 95c850c940..1a63053692 100644 --- a/xlators/features/changelog/src/changelog-rpc-common.h +++ b/xlators/features/changelog/src/changelog-rpc-common.h @@ -13,7 +13,7 @@ #include "rpcsvc.h" #include "rpc-clnt.h" -#include "event.h" +#include "gf-event.h" #include "call-stub.h" #include "changelog-xdr.h" diff --git a/xlators/features/quota/src/quota.h b/xlators/features/quota/src/quota.h index b99ca820e7..9fe0e3e0a5 100644 --- a/xlators/features/quota/src/quota.h +++ b/xlators/features/quota/src/quota.h @@ -19,7 +19,7 @@ #include "compat.h" #include "logging.h" #include "dict.h" -#include "event.h" +#include "gf-event.h" #include "rpcsvc.h" #include "rpc-clnt.h" #include "byte-order.h" diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c index bc1322573e..cd30ed9637 100644 --- a/xlators/protocol/client/src/client.c +++ b/xlators/protocol/client/src/client.c @@ -15,7 +15,7 @@ #include "glusterfs.h" #include "statedump.h" #include "compat-errno.h" -#include "event.h" +#include "gf-event.h" #include "xdr-rpc.h" #include "glusterfs3.h" diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c index e4a5bdac1f..8ff51a1c16 100644 --- a/xlators/protocol/server/src/server.c +++ b/xlators/protocol/server/src/server.c @@ -20,7 +20,7 @@ #include "statedump.h" #include "defaults.h" #include "authenticate.h" -#include "event.h" +#include "gf-event.h" #include "events.h" #include "server-messages.h" #include "rpc-clnt.h" -- cgit