mailing list of musl libc
 help / color / mirror / code / Atom feed
1e3b7d22d2e2ce7e0467d3d7e9aaef517cada663 blob 1245 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
 
#include <aio.h>
#include <errno.h>
#include "pthread_impl.h"

int __clock_gettime(clockid_t clk, struct timespec *ts);

/* Due to the requirement that aio_suspend be async-signal-safe, we cannot
 * use any locks, wait queues, etc. that would make it more efficient. The
 * only obviously-correct algorithm is to generate a wakeup every time any
 * aio operation finishes and have aio_suspend re-evaluate the completion
 * status of each aiocb it was waiting on. */

static volatile int seq;

void __aio_wake(void)
{
	a_inc(&seq);
	__wake(&seq, -1, 1);
}

int aio_suspend(const struct aiocb *const cbs[], int cnt, const struct timespec *ts)
{
	int i, last, first=1, ret=0;
	struct timespec at;

	if (cnt<0) {
		errno = EINVAL;
		return -1;
	}

	for (;;) {
		last = seq;

		for (i=0; i<cnt; i++) {
			if (cbs[i] && cbs[i]->__err != EINPROGRESS)
				return 0;
		}

		if (first && ts) {
			__clock_gettime(CLOCK_MONOTONIC, &at);
			at.tv_sec += ts->tv_sec;
			if ((at.tv_nsec += ts->tv_nsec) >= 1000000000) {
				at.tv_nsec -= 1000000000;
				at.tv_sec++;
			}
			first = 0;
		}

		ret = __timedwait(&seq, last, CLOCK_MONOTONIC,
			ts ? &at : 0, 0, 0, 1);

		if (ret == ETIMEDOUT) ret = EAGAIN;

		if (ret) {
			errno = ret;
			return -1;
		}
	}
}
debug log:

solving 1e3b7d2 ...
found 1e3b7d2 in https://inbox.vuxu.org/musl/e055ebf55ff719cd25cb1446a642c8c032475223.1409524413.git.Jens.Gustedt@inria.fr/
found 39a1d3a in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 39a1d3a228c8d0611f8fbe51f78d1116a90d200b	src/aio/aio_suspend.c

applying [1/1] https://inbox.vuxu.org/musl/e055ebf55ff719cd25cb1446a642c8c032475223.1409524413.git.Jens.Gustedt@inria.fr/
diff --git a/src/aio/aio_suspend.c b/src/aio/aio_suspend.c
index 39a1d3a..1e3b7d2 100644

Checking patch src/aio/aio_suspend.c...
Applied patch src/aio/aio_suspend.c cleanly.

index at:
100644 1e3b7d22d2e2ce7e0467d3d7e9aaef517cada663	src/aio/aio_suspend.c

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).