]> git.ipfire.org Git - thirdparty/knot-resolver.git/commit
layer: refactor and better describe the API
authorVladimír Čunát <vladimir.cunat@nic.cz>
Tue, 8 Nov 2016 16:02:43 +0000 (17:02 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Tue, 8 Nov 2016 17:12:23 +0000 (18:12 +0100)
commitcc47973e392f3f7494821ae8ccaaa563bfa64694
tree3fbde9a5199bd7255d96a58b3f8b315d4ca154af
parent4ad98bff3a03337544d790673c65e1c58701093b
layer: refactor and better describe the API

- The API and ABI for modules changes slightly (details below).
  KR_MODULE_API is bumped to avoid loading incompatible code.
  We have bumped libkres ABIVER since the last release 1.1.1,
  so leaving that one intact.

- Make KR_STATE_YIELD not reuse 0 value anymore.
  It's easy to e.g. return kr_ok() by mistake.
- struct kr_layer_t:
  * ::mm was unused, uninitialized, etc.
  * Make ::state an int, as it was everywhere else.
  * void *data was ugly and always containing struct kr_request *
- struct kr_layer_api:
  * Drop the void* parameter from ::begin, as it was only used
    for the request which is available as ctx->req anyway
    (formerly ctx->data).
  * Drop ::fail.  It wasn't even called.  Modules can watch for
    KR_STATE_FAIL in ::finish.
- Document the apparent meaning of the layer interface, deduced mainly
  from the way it's used in the code.  Caveats:
  * enum knot_layer_state handling seems to assume that it holds exactly
    one of the possibilities at a time.  The cookie module does NOT
    follow that (intentionally), apparently depending on the exact
    implementation of the handling at that moment.  It feels fragile.
  * I was unable to deduce a plausible description of when ::reset is
    called.  It's practically unused in modules, too.
14 files changed:
daemon/ffimodule.c
daemon/lua/kres.lua
lib/README.rst
lib/layer.h
lib/layer/iterate.c
lib/layer/pktcache.c
lib/layer/rrcache.c
lib/layer/validate.c
lib/module.h
lib/resolve.c
modules/cookies/cookiemonster.c
modules/cookies/cookiemonster.h
modules/hints/hints.c
modules/stats/stats.c