Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2.0.0 #66

Closed
wants to merge 116 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
618b5fb
feat(gencodecs/api/): generate structure and deserializer methods for…
lcsmuller May 3, 2022
5ce2ad5
refactor!: apply 618b5f
lcsmuller May 3, 2022
936a482
refactor!(examples): match to 5ce2ad
lcsmuller May 3, 2022
d5f9360
docs(README.md): update minimalistic examples and showcase slash comm…
lcsmuller May 3, 2022
1ff790a
docs(README.md): update minimalistic examples and showcase slash comm…
lcsmuller May 3, 2022
4099356
docs(README.md): update minimalistic examples and showcase slash comm…
lcsmuller May 3, 2022
6ab2196
docs(README.md): improve documentation for special compilation flags …
lcsmuller May 3, 2022
fda90d8
docs(README.md): match old example with new method counterpart
lcsmuller May 4, 2022
8596fe1
refactor!(test): match to 5ce2ad
lcsmuller May 4, 2022
5225e66
fix(gencodecs/api/gateway.pre.h): wrap fields that shouldn't be sent …
lcsmuller May 4, 2022
046af7d
wip(discord-adapter): requests are sent in order of arrival, need to …
lcsmuller May 4, 2022
da91be1
wip: enforce ratelimiting using the Timer API
lcsmuller May 6, 2022
bd06358
fix: segfault from freeing bogus pointer
lcsmuller May 6, 2022
53ed633
fix: -Wstringop-overread
lcsmuller May 7, 2022
e8c0976
fix: -Wsign-conversion
lcsmuller May 7, 2022
ce9be43
feat: move 'struct discord_refcount' from 'struct discord_adapter' to
lcsmuller May 7, 2022
7c13970
fix(discord-voice): outdated jsmn-find syntax
lcsmuller May 7, 2022
2435f2e
fix(examples): rename voice.c -> voice-join.c to not conflict with th…
lcsmuller May 7, 2022
a9e966c
refactor(gencodecs): make a couple methods public
lcsmuller May 7, 2022
1963048
refactor!(discord-gateway): reduce code duplication, allow passing ev…
lcsmuller May 8, 2022
1e8ba93
chore(test): match 196304
lcsmuller May 8, 2022
a989912
fix(discord-gateway.c): closes #65
lcsmuller May 8, 2022
46521ae
refactor(examples): event data can be now be freely passed around to …
lcsmuller May 8, 2022
b0aea42
fix(discord-gateway): check for DISCORD_EV_NONE, check for NULL fallb…
lcsmuller May 8, 2022
8505b17
fix(jsmn-find.h): update to v1.0.2 (fix key-search bug)
lcsmuller May 8, 2022
5c1689e
fix(jsmn-find.h): initialize allocated memory (update to v1.0.3)
lcsmuller May 8, 2022
1498dc3
feat(discord.h): add discord_request_guild_members(),
lcsmuller May 9, 2022
23f03b7
refactor(discord-gateway): move message commands logic to discord-gat…
lcsmuller May 9, 2022
d3c1e30
chore(test/rest.c): skip test missing channel_id
lcsmuller May 9, 2022
72a45f7
refactor: rename discord-gateway_command.c -> discord-messagecommands…
lcsmuller May 10, 2022
4979d0f
chore(examples/shell.c): match 72a45f
lcsmuller May 10, 2022
7e86432
fix: boundaries check
lcsmuller May 10, 2022
2f5e26e
chore(cog-utils): remove cog_sized_buffer_from_json(), struct sized_b…
lcsmuller May 11, 2022
aabb26e
feat: add discord_config_get_field() and match codebase to 2f5e26e
lcsmuller May 11, 2022
6e3d624
wip: rollback removal of const keyword for event's parameter
lcsmuller May 12, 2022
1f0f959
wip(discord-adapter): rename symbols and improve descriptions
lcsmuller May 13, 2022
877c3e2
fix(discord-loop.c): prevent spurious wakeups
Anotra May 13, 2022
9582453
refactor(discord-loop.c): rename poll_time to sleep_time
Anotra May 13, 2022
9411322
refactor(Makefile): use implicit rules to replace .DEFAULT trick
lcsmuller May 13, 2022
bbb5f73
wip(discord-adapter_request): move 'struct discord_context' logic
lcsmuller May 13, 2022
592d916
refactor(discord-adapter): move asynchronous request handling to disc…
lcsmuller May 15, 2022
f3e9ba5
refactor: rename Adapter -> REST
lcsmuller May 16, 2022
ecca9db
refactor(discord-rest): rename and move discord_context_bucket_insert…
lcsmuller May 16, 2022
ef36167
feat: add discord_claim() and discord_unclaim(), so that the client m…
lcsmuller May 16, 2022
daadd3f
chore(chash): add non-malloc alternatives to chash_init() and chash_f…
lcsmuller May 16, 2022
3bd5a67
wip: match 'struct discord_refcounter' and 'struct discord_message_co…
lcsmuller May 16, 2022
a0c0d1e
refactor: use CONTAINEROF() and CLIENT() macros where possible
lcsmuller May 17, 2022
0020914
chore(test/async.c): test discord_claim() and discord_unclaim()
lcsmuller May 17, 2022
09aff81
feat: add '.keep' field for keeping Concord's parameters and sharing …
lcsmuller May 17, 2022
21c044f
chore(test): match 09aff81e
lcsmuller May 17, 2022
308c64d
refactor!(discord-refcount): move discord_refcount_incr() auto-initia…
lcsmuller May 18, 2022
ff62bc1
fix: match 308c64dc
lcsmuller May 18, 2022
98508a4
chore(examples): match #66 syntax changes
lcsmuller May 18, 2022
2907422
fix(examples/channel.c): print the correct channel
lcsmuller May 19, 2022
424ae3f
wip: fixing race-conditions when using async and sync simultaneously
lcsmuller May 19, 2022
64218cc
fix:(discord-rest.c): make discord rest requests responsive
Anotra May 19, 2022
a2f68d8
refactor(discord-rest.c): reduce discord_rest_async_perform()
lcsmuller May 19, 2022
7096f91
wip(discord-rest): moving logic to a special REST management thread
lcsmuller May 20, 2022
1e5c24c
refactor(discord-rest): add io_poller for REST loop
Anotra May 20, 2022
4e6a506
refactor(discord-internal.h): move discord_timer declarations
Anotra May 20, 2022
d7dece5
refactor(discord-timers): move discord_timers_get_next_trigger to dis…
Anotra May 20, 2022
d721c81
refactor(discord-rest) add timer queue to discord REST thread
Anotra May 20, 2022
a06dbc5
refactor(discord-timer): clean up init and cleanup functions in order…
Anotra May 20, 2022
3c8e3f5
wip(discord-rest): triggers pthread_cond_signal() when request is done
lcsmuller May 20, 2022
612f01e
feat(io_poller): add io_poller_wakeup
Anotra May 20, 2022
5777a1e
refactor(discord-rest_async.c): remove useless enable_perform calls, …
Anotra May 20, 2022
02a0d91
refactor(discord-rest.c): increase poll time to 60 seconds
Anotra May 20, 2022
0ed9322
refactor(discord-rest): move REST io_poller to 'struct discord_async'…
lcsmuller May 20, 2022
44d8e14
fix(io_poller.c): double free in io_poller_create
Anotra May 21, 2022
4903af4
fix(discord-rest.c): restore discord_rest_async_perform call
Anotra May 21, 2022
8663db7
refactor(discord-rest.c): make shutting down REST thread possible
Anotra May 21, 2022
dec0e0a
V2.0.0 rest refactor wip (#67)
lcsmuller May 21, 2022
0d4b39e
wip(discord-rest): finished requests queue that should trigger callba…
lcsmuller May 21, 2022
f426417
refactor(discord-rest): ensure buckets are only handled from the REST…
lcsmuller May 24, 2022
8f3359f
refactor(discord-rest): tidy up codebase by moving functions and structs
lcsmuller May 24, 2022
79c0393
refactor: replace 'discord_request' references with 'discord_attributes'
lcsmuller May 26, 2022
ec8d5ad
refactor(discord-rest): rename discord-rest_async.c ->
lcsmuller May 26, 2022
22ddd81
refactor: move 'struct discord_ratelimiter' field to 'struct discord_…
lcsmuller May 26, 2022
1845d53
refactor(discord-rest): move io_poller from 'struct discord_requestor…
lcsmuller May 26, 2022
5e4996b
fix(discord-rest): field initialization ordering
lcsmuller May 26, 2022
f6ecf3f
fix(discord-rest): move discord_request_dispatch_responses() outside …
lcsmuller May 27, 2022
95c1277
refactor(discord-refcount.c): add locks and make discord_refcounter_c…
lcsmuller May 27, 2022
3e5081a
fix(discord-rest_request.c): lock queues that interface between REST …
lcsmuller May 27, 2022
f1f1b85
refactor(discord-rest_ratelimit.c): remove all ratelimiting-specific …
lcsmuller May 27, 2022
6029e6d
fix(discord-rest_request): add missing recycling queue lock
lcsmuller May 28, 2022
9b34c9c
fix(discord-rest_request): no need to lock entire code chunk once que…
lcsmuller May 28, 2022
3692562
refactor(discord_gateway): use timer to determine when the next ping is
Anotra May 29, 2022
38d5086
refactor(discord-loop.c): eliminate next_run from the main loop allow…
Anotra May 29, 2022
8279e09
fix(discord-gateway_dispatch.c): determine correct interval for next …
Anotra May 29, 2022
c89e782
fix(discord-gateway_dispatch.c): used signed int for difference in _o…
Anotra May 29, 2022
4995d71
feat: add discord_bucket_request_selector(), discord_bucket_request_u…
lcsmuller May 30, 2022
c9e0b32
Merge pull request #69 from Cogmasters/v2.0.0-rest_refactor
lcsmuller May 30, 2022
aafd4c9
fix(discord-timer): delete function should skip callback
Anotra May 30, 2022
7a348ad
refactor(discord-timer): cleanup discord_timers_run
Anotra May 30, 2022
3fef95e
fix: sigint
Anotra May 30, 2022
8789ac2
refactor(discord-gateway): better document timers, move heartbeat log…
lcsmuller May 30, 2022
51f7700
refactor(discord-gateway): 'hbeat_interval' is not a timestamp, chang…
lcsmuller May 30, 2022
4727e0e
fix(discord-gateway): session couldn't be resumed because it was missing
lcsmuller May 30, 2022
44d228f
fix: deal with request retries from the REST thread
lcsmuller May 31, 2022
3d5ebeb
fix(discord-rest_request.c): OpenBSD compliant pthread_cond_t init so…
lcsmuller May 31, 2022
28d3dab
refactor(discord-rest_request.c): replace 3d5ebe with a stackful solu…
lcsmuller May 31, 2022
40db37c
wip: rename and move core/work* -> src/discord-worker.c and include/d…
lcsmuller May 31, 2022
e8b35dc
feat(discord-worker): add discord_worker_join()
lcsmuller May 31, 2022
5d31ab1
refactor!(discord-response.h): rename field high_p -> high_priority a…
lcsmuller May 31, 2022
bf5b82d
fix: wait for client's worker threads completion before cleaning up i…
lcsmuller Jun 1, 2022
5a0b9d8
chore(racecond.c): match latest
lcsmuller Jun 1, 2022
18aebcb
fix(gencodecs): replace 'this' C++ reserved keyword with 'self'
lcsmuller Jun 1, 2022
2ff4fbc
chore: add C extern guards for C++
lcsmuller Jun 1, 2022
2d2327c
refactor(discord-gateway): better modularization
lcsmuller Jun 1, 2022
31e6a37
Merge branch 'dev' into v2.0.0
lcsmuller Jun 1, 2022
1d58ad4
refactor(discord-gateway): merge 'struct discord_gateway_payload' fie…
lcsmuller Jun 2, 2022
8c0aaf6
feat(Makefile): turn Makefile.dynamic into a special target 'shared' …
lcsmuller Jun 5, 2022
fd7a6ab
chore(Makefile): simpler logic for adding custom variables
lcsmuller Jun 5, 2022
5c2e468
fix(examples/discord-voice.c): missing const and passing to wrong poi…
lcsmuller Jun 5, 2022
0a322a1
fix(channel.c): discord_get_channel_pos() must keep track of .keep field
lcsmuller Jun 5, 2022
57a95f3
fix(discord-voice.c): update to latest refactoring and add a build te…
lcsmuller Jun 5, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/test_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:
make examples
echo "Building tests"
make test
echo "Building voice"
make voice

- name: Run Makefile with parallelism
run: |
Expand All @@ -39,3 +41,5 @@ jobs:
make examples -j$(nproc)
echo "Building tests with parallelism"
make test -j$(nproc)
echo "Building voice with parallelism"
make voice -j$(nproc)
63 changes: 38 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,26 @@ COGUTILS_OBJS = $(COGUTILS_DIR)/cog-utils.o \
$(COGUTILS_DIR)/logconf.o \
$(COGUTILS_DIR)/json-build.o \
$(COGUTILS_DIR)/jsmn-find.o
CORE_OBJS = $(CORE_DIR)/work.o \
$(CORE_DIR)/user-agent.o \
CORE_OBJS = $(CORE_DIR)/user-agent.o \
$(CORE_DIR)/websockets.o \
$(CORE_DIR)/io_poller.o
THIRDP_OBJS = $(THIRDP_DIR)/sha1.o \
$(THIRDP_DIR)/curl-websocket.o \
$(THIRDP_DIR)/threadpool.o \
$(THIRDP_DIR)/priority_queue.o
DISCORD_OBJS = $(SRC_DIR)/concord-once.o \
$(SRC_DIR)/discord-adapter.o \
$(SRC_DIR)/discord-adapter_ratelimit.o \
$(SRC_DIR)/discord-adapter_refcount.o \
$(SRC_DIR)/discord-refcount.o \
$(SRC_DIR)/discord-rest.o \
$(SRC_DIR)/discord-rest_request.o \
$(SRC_DIR)/discord-rest_ratelimit.o \
$(SRC_DIR)/discord-client.o \
$(SRC_DIR)/discord-loop.o \
$(SRC_DIR)/discord-loop.o \
$(SRC_DIR)/discord-gateway.o \
$(SRC_DIR)/discord-gateway_dispatch.o \
$(SRC_DIR)/discord-messagecommands.o \
$(SRC_DIR)/discord-timer.o \
$(SRC_DIR)/discord-misc.o \
$(SRC_DIR)/discord-worker.o \
$(SRC_DIR)/application_command.o \
$(SRC_DIR)/interaction.o \
$(SRC_DIR)/audit_log.o \
Expand All @@ -50,31 +53,39 @@ DISCORD_OBJS = $(SRC_DIR)/concord-once.o \
$(SRC_DIR)/invite.o \
$(SRC_DIR)/user.o \
$(SRC_DIR)/voice.o \
$(SRC_DIR)/webhook.o \
$(XOBJ)
$(SRC_DIR)/webhook.o

OBJS := $(COGUTILS_OBJS) $(CORE_OBJS) $(THIRDP_OBJS) $(DISCORD_OBJS) \
$(GENCODECS_OBJ)
OBJS = $(COGUTILS_OBJS) $(CORE_OBJS) $(THIRDP_OBJS) $(DISCORD_OBJS) \
$(GENCODECS_OBJ)

LIB := $(LIBDIR)/libdiscord.a
ARLIB = $(LIBDIR)/libdiscord.a
ARFLAGS = -cqsv

SOLIB = $(LIBDIR)/libdiscord.so
SOFLAGS = -fPIC
LDFLAGS = -lcurl

WFLAGS += -Wall -Wextra -Wshadow -Wdouble-promotion -Wconversion -Wpedantic
CFLAGS += -std=c99 -O0 -g -pthread -D_XOPEN_SOURCE=600 \
-I$(INCLUDE_DIR) -I$(COGUTILS_DIR) -I$(CORE_DIR) -I$(THIRDP_DIR) \
-I$(GENCODECS_DIR) -I$(PREFIX)/include -DLOG_USE_COLOR
WFLAGS += -Wall -Wextra -Wshadow -Wdouble-promotion -Wconversion -Wpedantic

$(SRC_DIR)/%.o: $(SRC_DIR)/%.c
$(CC) $(CFLAGS) $(WFLAGS) $(XFLAGS) -c -o $@ $<
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
$(CC) $(CFLAGS) $(WFLAGS) -c -o $@ $<

all: $(LIB)
all: $(ARLIB)

shared:
@ $(MAKE) clean
@ $(MAKE) CFLAGS="$(SOFLAGS) $(CFLAGS)" $(SOLIB)

voice:
@ $(MAKE) XFLAGS=-DCCORD_VOICE XOBJ=$(SRC_DIR)/discord-voice.o all
@ $(MAKE) CFLAGS="$(CFLAGS) -DCCORD_VOICE" \
OBJS="$(OBJS) $(SRC_DIR)/discord-voice.o" all

debug:
@ $(MAKE) XFLAGS="-DCCORD_DEBUG_WEBSOCKETS -DCCORD_DEBUG_ADAPTER" all
@ $(MAKE) CFLAGS="$(CFLAGS) -DCCORD_DEBUG_WEBSOCKETS -DCCORD_DEBUG_HTTP" \
all

test: all
@ $(MAKE) -C $(TEST_DIR)
Expand All @@ -85,8 +96,10 @@ examples: all
gencodecs:
@ $(MAKE) -C $(GENCODECS_DIR)

$(LIB): $(OBJS) | $(LIBDIR)
$(AR) -cqsv $@ $?
$(ARLIB): $(OBJS) | $(LIBDIR)
$(AR) $(ARFLAGS) $@ $?
$(SOLIB): $(OBJS) | $(LIBDIR)
$(CC) -shared $(LDFLAGS) -o $@ $<

$(LIBDIR):
@ mkdir -p $@
Expand All @@ -96,16 +109,16 @@ $(OBJS): $(GENCODECS_HDR) | $(OBJDIR)
$(GENCODECS_HDR): gencodecs

$(OBJDIR):
@ mkdir -p $@/$(THIRDP_DIR) \
$@/$(COGUTILS_DIR) \
$@/$(SRC_DIR) \
@ mkdir -p $@/$(THIRDP_DIR) $@/$(COGUTILS_DIR) $@/$(SRC_DIR) \
$@/$(GENCODECS_DIR)

.IGNORE:
install:
@ mkdir -p $(PREFIX)/lib/
@ mkdir -p $(PREFIX)/include/concord
install -d $(PREFIX)/lib/
install -m 644 $(LIB) $(PREFIX)/lib/
install -m 644 $(ARLIB) $(PREFIX)/lib/
install -m 644 $(SOLIB) $(PREFIX)/lib/
install -d $(PREFIX)/include/concord/
install -m 644 $(INCLUDE_DIR)/*.h $(COGUTILS_DIR)/*.h $(CORE_DIR)/*.h \
$(THIRDP_DIR)/*.h $(GENCODECS_DIR)/*.h $(PREFIX)/include/concord/
Expand All @@ -124,11 +137,11 @@ echo:

clean:
@ $(RM) $(GENCODECS_OBJS) $(COGUTILS_OBJS) $(CORE_OBJS) $(THIRDP_OBJS) $(DISCORD_OBJS)
@ $(RM) -r $(LIBDIR)
@ $(MAKE) -C $(TEST_DIR) clean
@ $(MAKE) -C $(EXAMPLES_DIR) clean

purge: clean
@ $(RM) -r $(LIBDIR)
@ $(MAKE) -C $(GENCODECS_DIR) clean

.PHONY: test examples install echo clean purge docs gencodecs
135 changes: 0 additions & 135 deletions Makefile.dynamic

This file was deleted.

Loading