Why not remove UNIX domain socket before bind

2016-11-29 Thread Shuxin Yang
Hi, There: Is there any reason not to delete UNIX domain socket before bind? It is bit inconvenient when : 1). debugging: previous debugging session quit prematurely without erasing the UNIX domain socket, and the subsequent debugging session only see "address already in use" error messa

Re: Why not remove UNIX domain socket before bind

2016-11-29 Thread Datong Sun via nginx-devel
Hello Shuxin, I have seen the same issue before. As far as I can tell this is simply a bug instead of by design (correct me if I'm wrong). I can also confirm that nginx will leave behind the listening socket file when terminated with SIGQUIT. There has been a bug report opened more than a year ago

Re: Why not remove UNIX domain socket before bind

2016-11-29 Thread Shuxin Yang
Hi, Datong: I don't think fixing #753 resolves all the trouble: it does not help for scenario 1 at all. For scenario 2, it only help if nginx is terminated by SIGQUIT; however, Nginx could be killed by other signals, say SIGKILL. Thanks Shuxin On 11/29/2016 11:11 PM, Datong Sun via ngin

Re: Why not remove UNIX domain socket before bind

2016-11-30 Thread Maxim Dounin
Hello! On Tue, Nov 29, 2016 at 01:30:25PM -0800, Shuxin Yang wrote: > Is there any reason not to delete UNIX domain socket before bind? To name a few, deleting a socket implies that: a) any file can be accidentally deleted due to a typo in the listen directive; b) attempts to do dupl

Re: Why not remove UNIX domain socket before bind

2016-11-30 Thread Shuxin Yang
Hi, Maxim: Thank you very much ! I think b) is good reason, a) is pretty weak: The /the/path/to/unix/domain/socket is a constant string instead of a variable; IMHO, it's unlikely to accidentally delete a wrong file due to typo. Thanks Shuxin On 11/30/16 6:57 AM, Maxim Dounin wrote: H

Re: Why not remove UNIX domain socket before bind

2016-12-01 Thread Datong Sun via nginx-devel
Hi Maxim, Thanks for the explanation. Regarding a), what about checking and making sure the type of file is actually a socket before removing? Obviously it does not prevent NGINX from deleting sockets created by other processes but it's a much smaller issue compared to deleting arbitrary file. Th

Re: Why not remove UNIX domain socket before bind

2016-12-01 Thread Alexey Ivanov
Why not just use `flock(2)` there? > On Nov 30, 2016, at 6:57 AM, Maxim Dounin wrote: > > Hello! > > On Tue, Nov 29, 2016 at 01:30:25PM -0800, Shuxin Yang wrote: > >> Is there any reason not to delete UNIX domain socket before bind? > > To name a few, deleting a socket implies that: > >

Re: Why not remove UNIX domain socket before bind

2016-12-01 Thread Maxim Dounin
Hello! On Thu, Dec 01, 2016 at 01:20:43AM -0800, Alexey Ivanov wrote: > Why not just use `flock(2)` there? It won't work if the socket is used by a different server. -- Maxim Dounin http://nginx.org/ ___ nginx-devel mailing list nginx-devel@nginx.or