Skip to content

Commit 2da3eb6

Browse files
committed
This one is stable and ran in prod for a long time
- replace keylist with libavl - allow any number of RE capture groups in proc_line() - don't close stderr when running external programs - replace syslog() with logw() - added TODO
1 parent 2e62e90 commit 2da3eb6

File tree

12 files changed

+1229
-379
lines changed

12 files changed

+1229
-379
lines changed

Makefile

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CFLAGS = -pipe -ggdb
22

33
PROGS = reactd
4-
TESTS = test_reset_list test_ring
4+
TESTS = test_reset_list test_ring test_hash test_btree
55

66
all: $(PROGS)
77
tests: $(TESTS)
@@ -11,18 +11,27 @@ debug: CFLAGS += -DDEBUG -ggdb
1111
debug: all
1212
@true
1313

14+
ifneq ($(STATIC),)
15+
LDFLAGS+=-static
16+
PKGCONFIG_ARGS+=--static
17+
endif
18+
# LDFLAGS_pcre = $(shell pcre-config --libs)
19+
LDFLAGS_pcre = $(shell pkg-config --libs $(PKGCONFIG_ARGS) libpcre)
20+
1421
ifeq ($(DEBUG),)
1522
CFLAGS += -ggdb -O3 -std=gnu99
1623
else
17-
CFLAGS += -ggdb -std=gnu99 -DDEBUG -DDEBUG_RESET_LIST -DDEBUG_RING
24+
CFLAGS += -ggdb -std=gnu99 -DDEBUG -DDEBUG_RESET_LIST -DDEBUG_RING -DDEBUG_HASH -DDEBUG_BTREE
1825
endif
1926

20-
objects_reactd = reactd_conf.tab.o reactd_conf.lex.yy.o reactd.o keylist.o pcre_subst.o debug.o log.o ring.o reset_list.o
21-
objects_keylist_test = keylist_test.o keylist.o debug.o
22-
objects_threshold_test = threshold_test.o threshold.o keylist.o debug.o
27+
objects_reactd = reactd_conf.tab.o reactd_conf.lex.yy.o reactd.o avl.o pcre_subst.o debug.o log.o ring.o reset_list.o
2328
objects_subst_test = subst_test.o pcre_subst.o debug.o
2429
objects_reset_list_test = test_reset_list Test_reset_list.o reset_list_test.o reset_list.o Test_reset_list.c
25-
objects_ring_test = test_ring Test_ring.o ring_test.o ring.o Test_ring.c
30+
objects_ring_test = test_ring ring_test.o Test_ring.o ring.o Test_ring.c
31+
# objects_keylist_test = keylist_test.o keylist.o debug.o
32+
# objects_threshold_test = threshold_test.o threshold.o keylist.o debug.o
33+
# objects_hash_test = test_hash Test_hash.o hash.o Test_hash.c
34+
# objects_btree_test = test_btree Test_btree.o btree.o Test_btree.c
2635

2736
%.o: %.c %.h
2837
$(CC) -c $(CFLAGS) $*.c -o $*.o
@@ -34,19 +43,19 @@ reactd_conf.lex.yy.c: reactd_conf.l reactd_conf.tab.h
3443
flex -o reactd_conf.lex.yy.c reactd_conf.l
3544

3645
reactd: $(objects_reactd)
37-
$(CC) $(CFLAGS) $(objects_reactd) -lfl -lpcre -lm -o reactd
46+
$(CC) $(LDFLAGS) $(CFLAGS) $(objects_reactd) -lfl $(LDFLAGS_pcre) -lm -o reactd
3847

39-
keylist_test: $(objects_keylist_test)
40-
$(CC) $(CFLAGS) $(objects_keylist_test) -o keylist_test
41-
42-
threshold_test: $(objects_threshold_test)
43-
$(CC) $(CFLAGS) $(objects_threshold_test) -o threshold_test -lpthread
48+
# keylist_test: $(objects_keylist_test)
49+
# $(CC) $(CFLAGS) $(objects_keylist_test) -o keylist_test
50+
51+
# threshold_test: $(objects_threshold_test)
52+
# $(CC) $(CFLAGS) $(objects_threshold_test) -o threshold_test -lpthread
4453

4554
subst_test: $(objects_subst_test)
4655
$(CC) $(CFLAGS) $(objects_subst_test) -lpcre -o subst_test
4756

4857
clean:
49-
rm -f reactd reactd_conf.tab.c reactd_conf.tab.h reactd_conf.lex.yy.c $(objects_reactd) keylist_test $(objects_keylist_test) threshold_test $(objects_threshold_test) subst_test $(objects_subst_test) $(objects_reset_list_test) $(objects_ring_test)
58+
rm -f reactd reactd_conf.tab.c reactd_conf.tab.h reactd_conf.lex.yy.c $(objects_reactd) keylist_test $(objects_keylist_test) threshold_test $(objects_threshold_test) subst_test $(objects_subst_test) $(objects_reset_list_test) $(objects_ring_test) $(objects_btree_test)
5059

5160
# Unit Tests
5261
Test_reset_list.c: reset_list_test.c
@@ -60,3 +69,15 @@ Test_ring.c: ring_test.c
6069

6170
test_ring: CuTest.c Test_ring.o ring_test.o ring.o
6271
$(CC) $(CFLAGS) -o $@ $^
72+
73+
# Test_hash.c: hash_test.c
74+
# ./make-tests.sh $< > $@
75+
#
76+
# test_hash: CuTest.c Test_hash.o hash_test.o hash.o
77+
# $(CC) $(CFLAGS) -o $@ $^
78+
79+
# Test_btree.c: btree_test.c
80+
# ./make-tests.sh $< > $@
81+
#
82+
# test_btree: CuTest.c Test_btree.o btree_test.o btree.o
83+
# $(CC) $(CFLAGS) -o $@ $^

TODO

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- Add lexer keys for logging targets (eg: stderr, stdout), and log levels
2+
- Allow arguments to commands, replace capture groups in arguments/commands
3+
- Create test unit for subst library

0 commit comments

Comments
 (0)