[CRIU] Re: [PATCH 23/24] zdtm: Add task_waiter_ helpers v2

Andrew Vagin avagin at parallels.com
Tue Jun 19 00:52:12 EDT 2012


> +void task_waiter_wait(task_waiter_t *t)
> +{
> +	struct timespec req = { .tv_nsec = TASK_WAITER_INITIAL, };
> +	struct timespec rem = { };
> +	int v, attempts = 5;
> +
> +	for (;;) {
> +		if (!attempts--) {
> +			errno = EAGAIN;
> +			goto err;
> +		}
> +		if (read(t->pipes[0], &v, sizeof(v)) !=  sizeof(v))
> +			goto err;
----------------------------------------------
> +		if (v != t->raw + 1) {
> +			if (write(t->pipes[1], &v, sizeof(v)) !=  sizeof(v))
> +				goto err;
> +			nanosleep(&req, &rem);
> +			req.tv_nsec += t->seed;
> +		} else {
> +			t->raw++;
> +			break;
> +		}
----------------------------------------------
Pls explain this part.


More information about the CRIU mailing list