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.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel


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:
> 
> a) any file can be accidentally deleted due to a typo in the
>   listen directive;
> 
> b) attempts to do duplicate listen are not detected and silently
>   break service, e.g., if you start duplicate instance of nginx.
> 
> Instead we delete the socket after closing it.
> 
> --
> Maxim Dounin
> http://nginx.org/
> 
> ___
> nginx-devel mailing list
> nginx-devel@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel



signature.asc
Description: Message signed with OpenPGP using GPGMail
___
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel

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.

Thanks,

On Wed, 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:
>
> a) any file can be accidentally deleted due to a typo in the
>listen directive;
>
> b) attempts to do duplicate listen are not detected and silently
>break service, e.g., if you start duplicate instance of nginx.
>
> Instead we delete the socket after closing it.
>
> --
> Maxim Dounin
> http://nginx.org/
>
> ___
> nginx-devel mailing list
> nginx-devel@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel
>



-- 

*Datong Sun*  |  Systems Engineer
dat...@cloudflare.com


1 888 99 FLARE  |  www.cloudflare.com
___
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel

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:

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 duplicate listen are not detected and silently
break service, e.g., if you start duplicate instance of nginx.

Instead we delete the socket after closing it.



___
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel


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 duplicate listen are not detected and silently 
   break service, e.g., if you start duplicate instance of nginx.

Instead we delete the socket after closing it.

-- 
Maxim Dounin
http://nginx.org/

___
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel


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 nginx-devel wrote:

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 (https://trac.nginx.org/nginx/ticket/753) but still not 
being fixed.


Thanks,
Datong

On Tue, Nov 29, 2016 at 1:30 PM, Shuxin Yang > wrote:


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 message, and have
to delete the socket, and launch debugger again.

2). Writing deploy script. We need to make sure UNIX domain
sockets are completely delete before launching Nginx; also care
must be taken to keep the script and config file in sync, which is
sometimes bit annoying.


Thanks

Shuxin



___
nginx-devel mailing list
nginx-devel@nginx.org 
http://mailman.nginx.org/mailman/listinfo/nginx-devel





--

*Datong Sun*  |  Systems Engineer
dat...@cloudflare.com 

1 888 99 FLARE  | www.cloudflare.com 



___
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel


___
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel

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 (
https://trac.nginx.org/nginx/ticket/753) but still not being fixed.

Thanks,
Datong

On Tue, Nov 29, 2016 at 1:30 PM, Shuxin Yang 
wrote:

> 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 message, and have to delete the socket, and
> launch debugger again.
>
> 2). Writing deploy script. We need to make sure UNIX domain sockets are
> completely delete before launching Nginx; also care must be taken to keep
> the script and config file in sync, which is sometimes bit annoying.
>
>
> Thanks
>
> Shuxin
>
>
>
> ___
> nginx-devel mailing list
> nginx-devel@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel
>



-- 

*Datong Sun*  |  Systems Engineer
dat...@cloudflare.com


1 888 99 FLARE  |  www.cloudflare.com
___
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel