[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/5] Add SCM_RIGHTS support to unix socket chara
From: |
Mark McLoughlin |
Subject: |
Re: [Qemu-devel] [PATCH 2/5] Add SCM_RIGHTS support to unix socket character devices |
Date: |
Fri, 14 Aug 2009 07:38:39 +0100 |
On Thu, 2009-08-13 at 10:20 -0600, Cam Macdonell wrote:
> > @@ -1957,6 +2004,10 @@ static void tcp_chr_read(void *opaque)
> > tcp_chr_process_IAC_bytes(chr, s, buf, &size);
> > if (size > 0)
> > qemu_chr_read(chr, buf, size);
> > + if (s->msgfd != -1) {
> > + close(s->msgfd);
> > + s->msgfd = -1;
> > + }
>
> Hi Mark,
>
> I'm trying to understand the intended behaviour here so I can use your
> patch. In your comments for the patch it reads "store the file
> descriptor for use in the chr_read() handler. Close the file descriptor
> if it was not used." It seems that upon returning from the chr_read()
> handler the descriptor is closed if s->msgfd is not set to -1. Does
> this mean the handler should set the fd to -1 after retrieving it if the
> process wants to keep that fd open, otherwise it will be closed when
> chr_read() returns? Should tcp_get_msgfd() perhaps set s->msgfd to -1
> after it is retrieved? Sort of a "read and clear" behaviour?
Yes, that would work and TBH I can't recall why I chose not to do that.
It'd be like popping the fd from a one item queue.
The current caller of get_msgfd() dup()s the fd which achieves the same
thing.
Cheers,
Mark.