diff options
Diffstat (limited to 'src/skadns/skadns_release.c')
-rw-r--r-- | src/skadns/skadns_release.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/skadns/skadns_release.c b/src/skadns/skadns_release.c new file mode 100644 index 0000000..9fba737 --- /dev/null +++ b/src/skadns/skadns_release.c @@ -0,0 +1,26 @@ +/* ISC license. */ + +#include <errno.h> +#include <skalibs/uint16.h> +#include <skalibs/alloc.h> +#include <skalibs/gensetdyn.h> +#include <s6-dns/skadns.h> + +int skadns_release (skadns_t *a, uint16 id) +{ + register skadnsanswer_t *p = GENSETDYN_P(skadnsanswer_t, &a->q, id) ; + switch (p->status) + { + case 0 : + alloc_free(p->data) ; p->data = 0 ; p->len = 0 ; + break ; + case EAGAIN : + case ECANCELED : + return (errno = EBUSY, 0) ; + case EINVAL : + return (errno = EINVAL, 0) ; + default : break ; + } + p->status = EINVAL ; + return gensetdyn_delete(&a->q, id) ; +} |