Re: [Qemu-devel] [PATCH 2/2] net: take ownership of fd in socket init functions

2011-12-09 Thread Zhi Yong Wu
On Thu, Dec 8, 2011 at 8:57 PM, Stefan Hajnoczi wrote: > On Thu, Dec 8, 2011 at 12:29 PM, Zhi Yong Wu wrote: >> On Wed, Dec 7, 2011 at 11:01 PM, Stefan Hajnoczi >> wrote: >>> Today net/socket.c has no consistent policy for closing the socket file >>> descriptor when initialization fails.  This m

Re: [Qemu-devel] [PATCH 2/2] net: take ownership of fd in socket init functions

2011-12-08 Thread Stefan Hajnoczi
On Thu, Dec 8, 2011 at 12:29 PM, Zhi Yong Wu wrote: > On Wed, Dec 7, 2011 at 11:01 PM, Stefan Hajnoczi > wrote: >> Today net/socket.c has no consistent policy for closing the socket file >> descriptor when initialization fails.  This means we leak the file >> descriptor in some cases or we could

Re: [Qemu-devel] [PATCH 2/2] net: take ownership of fd in socket init functions

2011-12-08 Thread Zhi Yong Wu
On Wed, Dec 7, 2011 at 11:01 PM, Stefan Hajnoczi wrote: > Today net/socket.c has no consistent policy for closing the socket file > descriptor when initialization fails.  This means we leak the file > descriptor in some cases or we could also try to close it twice. > > Make error paths consistent

[Qemu-devel] [PATCH 2/2] net: take ownership of fd in socket init functions

2011-12-07 Thread Stefan Hajnoczi
Today net/socket.c has no consistent policy for closing the socket file descriptor when initialization fails. This means we leak the file descriptor in some cases or we could also try to close it twice. Make error paths consistent by taking ownership of the file descriptor and closing it on error