Marek Vavruša [Thu, 11 Jan 2018 01:09:04 +0000 (17:09 -0800)]
build: support `make lint-c` with clang-tidy
This supports linting of C code using clang-tidy to fix common
security and code quality issues early in the development workflow.
The benefit is that less time has to be spent in code reviews to
point out obvious problems, and ideally when the outstanding issues
are fixed, clang-tidy (and clang-format) can also be used to to
automatically fix basic problems and enforce common code style,
similarly to `go vet && go fmt` workflow.
Tomas Krizek [Thu, 11 Jan 2018 15:13:01 +0000 (16:13 +0100)]
systemd: add knot-resolver alias
The `knot-resolver` name is used for paths and user name. Creating a
systemd alias with the same name is user-friendly to end users who won't
have to remember another name (`kresd`).
Note: Systemd Alias is only created after service is enabled. Packagers
are thus advised to create symlinks for unit files during package installation
so users can use `knot-resolver` name right from the start.
systemd: drop WantedBy directive from kresd.service
This directive is unnecessary in the .service file, and it also causes
a dependency cycle that systemd is obliged to break.
Since kresd is socket-activated, there is no need for the WantedBy
directive in the .service file itself. As long as the .socket files
are installed, the service will run when it is used.
Marek Vavruša [Fri, 29 Dec 2017 03:25:57 +0000 (19:25 -0800)]
daemon: unified query completion callback with trace callback in resolve
This is a followup on addition of trace callbacks in the resolver library,
to get rid of the Lua/C interfacing in daemon and unify it with the log tracing.
All modules can now install completion callback on the kr_request object that
will be called after the resolution is done.
Marek Vavruša [Thu, 21 Dec 2017 06:22:36 +0000 (22:22 -0800)]
daemon/worker: allow large responses for outbound over TCP
By default the reassembly packet buffer is set to EDNS buffer size,
which is correct for UDP, but not for TCP which may accept any
allowed response size. This should be only used for responses to
outbound queries over TCP, not for inbound TCP queries.
Marek Vavruša [Wed, 6 Dec 2017 00:52:40 +0000 (16:52 -0800)]
Implement worker coroutines for asynchronous background processing
This implements worker coroutines in Lua to perform non-blocking I/O and do many things concurrently.
For example a file watcher can be now implemented as:
```
local watcher = notify.opendir('/etc')
watcher:add('hosts')
-- Watch changes to /etc/hosts
worker.coroutine(function ()
for flags, name in watcher:changes() do
for flag in notify.flags(flags) do
print(name, notify[flag])
end
end
end)
```
In order to make this work, the runtime uses the cqueues library which
can run coroutines concurrently, and return a file descriptor to poll on
if it's blocked. The worker takes that file descriptor and calls
`event.socket(pollfd, resume_callback)` so that libuv can wake up
the worker when its ready again.
The cqueues library is still optional, but if it's not present following stuff
won't work:
Marek Vavruša [Thu, 4 Jan 2018 00:07:35 +0000 (16:07 -0800)]
allow access to cache object through context
this surfaces the struct kr_cache through context variable,
it doesn't implement any API or documented interface for it,
so I just added a tests for the struct presence and introspection
Petr Špaček [Wed, 3 Jan 2018 16:56:39 +0000 (17:56 +0100)]
CI: publish coverage only for master branch (on web)
Non-master branches must not overwrite results from master branch.
From now only master branch publishes results on Gitlab Pages.
Results for other branches can be downloaded from artifacts.
Petr Špaček [Fri, 22 Dec 2017 12:21:24 +0000 (13:21 +0100)]
CI coverage: merge test coverage data from parallel runs
We run tests in paralell so have to make sure that coverage tools
do not overwrite results from each run.
This is hacky because lcov tool insists on having gcno and gcda files
in the same place as original source, so we have to copy files
to workaround this.
Petr Špaček [Thu, 21 Dec 2017 09:09:11 +0000 (10:09 +0100)]
CI coverage: add missing Lua files to the report
Luacov does not know about files which were not loaded at all.
Script luacov_gen_empty.sh generates empty luacov stats for all files
which forces luacov to show all files.
Petr Špaček [Wed, 20 Dec 2017 11:47:10 +0000 (12:47 +0100)]
CI coverage: handle Lua code coverage properly
Luacov statistics contained paths to installed files instead of source
files that it was a mess. The stats are now rewritten using hacky
mapping (created from install commands produced by make).
Also, branch and function coverage for Lua was always zero so now it is
turned off not to confuse users.
kresd config for respdiff now enables luacov as well.