Permalink
Browse files

Merge pull request #12 from knocte/fix_dispose

 [FastCgi] Don't delete the socket file if it doesn't match the original
  • Loading branch information...
2 parents 6365230 + 7b6cf02 commit 4587438369691b9b3e8415e1f113aa98b57d1fde @grendello grendello committed May 14, 2013
Showing with 40 additions and 3 deletions.
  1. +1 −1 configure.ac
  2. +39 −2 src/Mono.WebServer.FastCgi/UnixSocket.cs
View
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.53])
-AC_INIT([xsp], [2.11], [http://bugzilla.novell.com/])
+AC_INIT([xsp], [3.0], [http://bugzilla.xamarin.com/])
AC_CANONICAL_SYSTEM
AC_CONFIG_MACRO_DIR([build/m4])
AM_INIT_AUTOMAKE([foreign])
@@ -1,11 +1,43 @@
+//
+// UnixSocket.cs: Provides a wrapper around a unix domain socket file.
+//
+// Authors:
+// Brian Nickel (brian.nickel@gmail.com)
+// Andres G. Aragoneses (andres@7digital.com)
+//
+// Copyright (C) 2007 Brian Nickel
+// Copyright (C) 2013 7digital Media Ltd (http://www.7digital.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
using System;
+using Mono.Unix;
using System.Globalization;
namespace Mono.FastCgi
{
internal class UnixSocket : StandardSocket, IDisposable
{
string path = null;
+ long inode;
protected UnixSocket (Mono.Unix.UnixEndPoint localEndPoint)
: base (System.Net.Sockets.AddressFamily.Unix,
@@ -18,6 +50,7 @@ protected UnixSocket (Mono.Unix.UnixEndPoint localEndPoint)
public UnixSocket (string path) : this (CreateEndPoint (path))
{
this.path = path;
+ this.inode = new UnixFileInfo (path).Inode;
}
@@ -57,7 +90,10 @@ public void Dispose ()
if (path != null) {
string f = path;
path = null;
- System.IO.File.Delete (f);
+
+ if (System.IO.File.Exists (f) && this.inode == new UnixFileInfo (f).Inode) {
+ System.IO.File.Delete (f);
+ }
}
}
@@ -66,4 +102,5 @@ public void Dispose ()
Dispose ();
}
}
-}
+}
+

0 comments on commit 4587438

Please sign in to comment.