From d4b1e13b71896a51fe8c08aec6adc0ee0a2d21ff Mon Sep 17 00:00:00 2001 From: Jordan Sissel Date: Fri, 7 Sep 2012 21:54:12 -0700 Subject: [PATCH] Move sleep min/max defs to a header --- Makefile | 38 ++++++++++++++++++-------------------- emitter.c | 3 +-- harvester.c | 4 +--- proto.c | 3 +-- sleepdefs.h | 5 +++++ 5 files changed, 26 insertions(+), 27 deletions(-) create mode 100644 sleepdefs.h diff --git a/Makefile b/Makefile index 85cc3a7..350b229 100644 --- a/Makefile +++ b/Makefile @@ -49,39 +49,40 @@ rpm deb: | build-all # install -d -m 755 build/bin/* $(PREFIX)/bin/lumberjack # install -d build/lib/* $(PREFIX)/lib -backoff.c: backoff.h -harvester.c: harvester.h proto.h str.h -emitter.c: emitter.h ring.h -lumberjack.c: backoff.h harvester.h emitter.h -str.c: str.h -proto.c: proto.h str.h -ring.c: ring.h -harvester.c: build/include/insist.h -lumberjack.c: build/include/insist.h +backoff.o: backoff.c backoff.h +harvester.o: harvester.c harvester.h proto.h str.h sleepdefs.h +emitter.o: emitter.c emitter.h ring.h sleepdefs.h +lumberjack.o: lumberjack.c backoff.h harvester.h emitter.h +str.o: str.c str.h +proto.o: proto.c proto.h str.h sleepdefs.h +ring.o: ring.c ring.h + +harvester.o: build/include/insist.h +lumberjack.o: build/include/insist.h # Vendor'd dependencies # If VENDOR contains 'zeromq' download and build it. ifeq ($(filter zeromq,$(VENDOR)),zeromq) -emitter.c: build/include/zmq.h -harvester.c: build/include/zmq.h -lumberjack.c: build/include/zmq.h +emitter.o: build/include/zmq.h +harvester.o: build/include/zmq.h +lumberjack.o: build/include/zmq.h build/bin/lumberjack: | build/bin build/lib/libzmq.$(LIBEXT) endif # zeromq ifeq ($(filter jemalloc,$(VENDOR)),jemalloc) -harvester.c lumberjack.c ring.c str.c: build/include/jemalloc/jemalloc.h +harvester.o lumberjack.o ring.o str.o: build/include/jemalloc/jemalloc.h build/bin/lumberjack: | build/lib/libjemalloc.$(LIBEXT) endif # jemalloc ifeq ($(filter openssl,$(VENDOR)),openssl) -proto.c: build/include/openssl/ssl.h -lumberjack.c: build/include/openssl/ssl.h +proto.o: build/include/openssl/ssl.h +lumberjack.o: build/include/openssl/ssl.h build/bin/lumberjack: | build/lib/libssl.$(LIBEXT) build/bin/lumberjack: | build/lib/libcrypto.$(LIBEXT) endif # openssl ifeq ($(filter zlib,$(VENDOR)),zlib) -proto.c: build/include/zlib.h +proto.o: build/include/zlib.h build/bin/lumberjack: | build/lib/libz.$(LIBEXT) endif # zlib @@ -90,13 +91,10 @@ test: | build/test/test_ring build/test/test_ring # Tests -test_ring.c: ring.h build/include/jemalloc/jemalloc.h build/include/insist.h +test_ring.o: ring.h build/include/jemalloc/jemalloc.h build/include/insist.h build/test/test_ring: test_ring.o ring.o | build/test $(CC) $(LDFLAGS) -o $@ $^ -ljemalloc -proto.o: proto.c - $(CC) $(CFLAGS) -c -o $@ $^ - build/bin/lumberjack.sh: lumberjack.sh | build/bin install -m 755 $^ $@ diff --git a/emitter.c b/emitter.c index 7509186..05c152f 100644 --- a/emitter.c +++ b/emitter.c @@ -12,8 +12,7 @@ #include -static struct timespec MIN_SLEEP = { 0, 10000000 }; /* 10ms */ -static struct timespec MAX_SLEEP = { 15, 0 }; /* 15 */ +#include "sleepdefs.h" void *emitter(void *arg) { struct emitter_config *config = arg; diff --git a/harvester.c b/harvester.c index 0f040bf..d0f17c4 100644 --- a/harvester.c +++ b/harvester.c @@ -14,6 +14,7 @@ #include "harvester.h" #include "backoff.h" #include "insist.h" +#include "sleepdefs.h" #ifdef __MACH__ /* OS X is dumb, or I am dumb, or we are both dumb. I don't know anymore, @@ -26,9 +27,6 @@ extern int gethostname(char *name, size_t namelen); #define EMITTER_SOCKET "inproc://emitter" #define BUFFERSIZE 16384 -static struct timespec MIN_SLEEP = { 0, 10000000 }; /* 10ms */ -static struct timespec MAX_SLEEP = { 15, 0 }; /* 15 */ - /* A free function that simply calls free(3) for zmq_msg */ //static inline void free2(void *data, void __attribute__((__unused__)) *hint) { //free(data); diff --git a/proto.c b/proto.c index bd4a2f6..dd588ba 100644 --- a/proto.c +++ b/proto.c @@ -20,8 +20,7 @@ #include "openssl/ssl.h" #include "openssl/err.h" -static struct timespec MIN_SLEEP = { 0, 10000000 }; /* 10ms */ -static struct timespec MAX_SLEEP = { 15, 0 }; /* 15 */ +#include "sleepdefs.h" static void lumberjack_init(void); static int lumberjack_tcp_connect(struct lumberjack *lumberjack); diff --git a/sleepdefs.h b/sleepdefs.h new file mode 100644 index 0000000..4647d7f --- /dev/null +++ b/sleepdefs.h @@ -0,0 +1,5 @@ +#ifndef _SLEEPDEFS_H_ +#define _SLEEPDEFS_H_ +static struct timespec MIN_SLEEP = { 0, 10000000 }; /* 10ms */ +static struct timespec MAX_SLEEP = { 1, 0 }; /* 15 */ +#endif /* _SLEEPDEFS_H_ */ -- GitLab