diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-07-21 02:46:01 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-07-21 02:46:01 -0700 |
| commit | 537e2eda8d9fda2001295c835a4720def6a237f1 (patch) | |
| tree | 615d05096e0fe4c8bfbccf31f37c7256381ccd8e /src/platform | |
| parent | 07078e1cf761cb6e56e46bde3ade6f792368d7dd (diff) | |
| download | nng-537e2eda8d9fda2001295c835a4720def6a237f1.tar.gz nng-537e2eda8d9fda2001295c835a4720def6a237f1.tar.bz2 nng-537e2eda8d9fda2001295c835a4720def6a237f1.zip | |
Simpler taskq API.
The queue is bound at initialization time of the task, and we call
entries just tasks, so we don't have to pass around a taskq pointer
across all the calls. Further, nni_task_dispatch is now guaranteed
to succeed.
Diffstat (limited to 'src/platform')
| -rw-r--r-- | src/platform/posix/posix_resolv_gai.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/platform/posix/posix_resolv_gai.c b/src/platform/posix/posix_resolv_gai.c index cc27b213..5852f34c 100644 --- a/src/platform/posix/posix_resolv_gai.c +++ b/src/platform/posix/posix_resolv_gai.c @@ -1,5 +1,6 @@ // // Copyright 2017 Garrett D'Amore <garrett@damore.org> +// Copyright 2017 Capitar IT Group BV <info@capitar.com> // // This software is supplied under the terms of the MIT License, a // copy of which should be located in the distribution where this @@ -41,13 +42,13 @@ static nni_mtx nni_posix_resolv_mtx; typedef struct nni_posix_resolv_item nni_posix_resolv_item; struct nni_posix_resolv_item { - int family; - int passive; - const char * name; - const char * serv; - int proto; - nni_aio * aio; - nni_taskq_ent tqe; + int family; + int passive; + const char *name; + const char *serv; + int proto; + nni_aio * aio; + nni_task task; }; static void @@ -72,7 +73,7 @@ nni_posix_resolv_cancel(nni_aio *aio) } aio->a_prov_data = NULL; nni_mtx_unlock(&nni_posix_resolv_mtx); - nni_taskq_cancel(nni_posix_resolv_tq, &item->tqe); + nni_task_cancel(&item->task); NNI_FREE_STRUCT(item); } @@ -230,7 +231,8 @@ nni_posix_resolv_ip(const char *host, const char *serv, int passive, return; } - nni_taskq_ent_init(&item->tqe, nni_posix_resolv_task, item); + nni_task_init( + nni_posix_resolv_tq, &item->task, nni_posix_resolv_task, item); switch (family) { case NNG_AF_INET: @@ -257,11 +259,7 @@ nni_posix_resolv_ip(const char *host, const char *serv, int passive, NNI_FREE_STRUCT(item); return; } - if ((rv = nni_taskq_dispatch(nni_posix_resolv_tq, &item->tqe)) != 0) { - nni_posix_resolv_finish(item, rv); - nni_mtx_unlock(&nni_posix_resolv_mtx); - return; - } + nni_task_dispatch(&item->task); nni_mtx_unlock(&nni_posix_resolv_mtx); } |
