[CRIU] Re: [PATCH 4/8] util-net: Add send_fds and recv_fds

Cyrill Gorcunov gorcunov at openvz.org
Sat Mar 24 13:09:22 EDT 2012


On Sat, Mar 24, 2012 at 08:58:39PM +0400, Pavel Emelyanov wrote:
...
> > +int recv_fds(int sock, int *fds, int nr_fds)
> > +{
> > +	struct scm_fdset fdset;
> > +	int *fds_rx, i, min_fd;
> > +
> > +	fds_rx = scm_fdset_init(&fdset, NULL, 0);
> > +
> > +	for (i = min_fd = 0; i < nr_fds; i += min_fd) {
> > +		min_fd = min(CR_SCM_MAX_FD, nr_fds - i);
> > +		scm_fdset_init_chunk(&fdset, min_fd);
> > +
> > +		min_fd = scm_fdset_recv(sock, &fdset);
> > +		if (min_fd < 0)
> > +			return min_fd;
> > +
> > +		builtin_memcpy(&fds[i], fds_rx, sizeof(int) * min_fd);
> 
> We should make sure, that the descriptor set received coincides the
> descriptor set we expected to receive. I don't see anything about it
> here.

Letme clarify, you mean we need to make sure the 1:1 map between descriptors
requested and received is valid? If so, the kernel picks up fds in-order,
so we simply can't get out of order results where, the question is can
we received out-of-order 'set' of descriptors -- yes, I fear we can,
to eliminate this problem we will need kind of sync points between
parasite code and crtools itself. Do I understand you right?

	Cyrill


More information about the CRIU mailing list