diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-04-20 05:29:11 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-04-20 05:29:11 +0200 |
commit | 7adeb6e88196a594ec3d36ffc1c658340ffcd7bc (patch) | |
tree | 6a6bfb84387141bf39d573ef9fa47f2c993d1923 /src/async.c | |
parent | b9c8603931203f5d94091f7a05a5967304b62fbd (diff) | |
download | fastd-7adeb6e88196a594ec3d36ffc1c658340ffcd7bc.tar fastd-7adeb6e88196a594ec3d36ffc1c658340ffcd7bc.zip |
Make ctx global
Diffstat (limited to 'src/async.c')
-rw-r--r-- | src/async.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/async.c b/src/async.c index 0c37842..144a82c 100644 --- a/src/async.c +++ b/src/async.c @@ -28,26 +28,26 @@ #include "fastd.h" -void fastd_async_init(fastd_context_t *ctx) { - fastd_open_pipe(ctx, &ctx->async_rfd, &ctx->async_wfd); +void fastd_async_init(void) { + fastd_open_pipe(&ctx.async_rfd, &ctx.async_wfd); } -static void handle_resolve_return(fastd_context_t *ctx) { +static void handle_resolve_return(void) { fastd_async_resolve_return_t resolve_return; - while (read(ctx->async_rfd, &resolve_return, sizeof(resolve_return)) < 0) { + while (read(ctx.async_rfd, &resolve_return, sizeof(resolve_return)) < 0) { if (errno != EINTR) - exit_errno(ctx, "handle_resolve_return: read"); + exit_errno("handle_resolve_return: read"); } fastd_peer_address_t addresses[resolve_return.n_addr]; - while (read(ctx->async_rfd, &addresses, sizeof(addresses)) < 0) { + while (read(ctx.async_rfd, &addresses, sizeof(addresses)) < 0) { if (errno != EINTR) - exit_errno(ctx, "handle_resolve_return: read"); + exit_errno("handle_resolve_return: read"); } size_t i; - for (i = 0; i < VECTOR_LEN(ctx->peers); i++) { - fastd_peer_t *peer = VECTOR_INDEX(ctx->peers, i); + for (i = 0; i < VECTOR_LEN(ctx.peers); i++) { + fastd_peer_t *peer = VECTOR_INDEX(ctx.peers, i); if (!peer->config) continue; @@ -61,7 +61,7 @@ static void handle_resolve_return(fastd_context_t *ctx) { if (!remote) continue; - fastd_peer_handle_resolve(ctx, peer, remote, resolve_return.n_addr, addresses); + fastd_peer_handle_resolve(peer, remote, resolve_return.n_addr, addresses); break; } @@ -69,30 +69,30 @@ static void handle_resolve_return(fastd_context_t *ctx) { fastd_remote_unref(resolve_return.remote); } -void fastd_async_handle(fastd_context_t *ctx) { +void fastd_async_handle(void) { fastd_async_type_t type; - while (read(ctx->async_rfd, &type, sizeof(type)) < 0) { + while (read(ctx.async_rfd, &type, sizeof(type)) < 0) { if (errno != EINTR) - exit_errno(ctx, "fastd_async_handle: read"); + exit_errno("fastd_async_handle: read"); } switch (type) { case ASYNC_TYPE_RESOLVE_RETURN: - handle_resolve_return(ctx); + handle_resolve_return(); break; default: - exit_bug(ctx, "fastd_async_handle: unknown type"); + exit_bug("fastd_async_handle: unknown type"); } } -void fastd_async_enqueue(fastd_context_t *ctx, fastd_async_type_t type, const void *data, size_t len) { +void fastd_async_enqueue(fastd_async_type_t type, const void *data, size_t len) { struct iovec vec[2] = { { .iov_base = &type, .iov_len = sizeof(type) }, { .iov_base = (void *)data, .iov_len = len }, }; - if (writev(ctx->async_wfd, vec, 2) < 0) - pr_error_errno(ctx, "fastd_async_enqueue"); + if (writev(ctx.async_wfd, vec, 2) < 0) + pr_error_errno("fastd_async_enqueue"); } |