<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -316,7 +316,7 @@ private:
 	string appRoot;
 	pid_t pid;
 	string listenSocketName;
-	bool usingAbstractNamespace;
+	string listenSocketType;
 	int ownerPipe;
 
 public:
@@ -328,18 +328,17 @@ public:
 	 *             This must be a valid directory, but the path does not have to be absolute.
 	 * @param pid The process ID of this application instance.
 	 * @param listenSocketName The name of the listener socket of this application instance.
-	 * @param usingAbstractNamespace Whether &lt;tt&gt;listenSocketName&lt;/tt&gt; refers to a Unix
-	 *        socket on the abstract namespace. Note that listenSocketName must not
-	 *        contain the leading null byte, even if it's an abstract namespace socket.
+	 * @param listenSocketType The type of the listener socket, e.g. &quot;unix&quot; for Unix
+	 *                         domain sockets.
 	 * @param ownerPipe The owner pipe of this application instance.
 	 * @post getAppRoot() == theAppRoot &amp;&amp; getPid() == pid
 	 */
 	Application(const string &amp;theAppRoot, pid_t pid, const string &amp;listenSocketName,
-	            bool usingAbstractNamespace, int ownerPipe) {
+	            const string &amp;listenSocketType, int ownerPipe) {
 		appRoot = theAppRoot;
 		this-&gt;pid = pid;
 		this-&gt;listenSocketName = listenSocketName;
-		this-&gt;usingAbstractNamespace = usingAbstractNamespace;
+		this-&gt;listenSocketType = listenSocketType;
 		this-&gt;ownerPipe = ownerPipe;
 		P_TRACE(3, &quot;Application &quot; &lt;&lt; this &lt;&lt; &quot;: created.&quot;);
 	}
@@ -353,7 +352,7 @@ public:
 				ret = close(ownerPipe);
 			} while (ret == -1 &amp;&amp; errno == EINTR);
 		}
-		if (!usingAbstractNamespace) {
+		if (listenSocketType == &quot;unix&quot;) {
 			do {
 				ret = unlink(listenSocketName.c_str());
 			} while (ret == -1 &amp;&amp; errno == EINTR);
@@ -425,6 +424,10 @@ public:
 	 * @throws IOException Something went wrong during the connection process.
 	 */
 	SessionPtr connect(const function&lt;void()&gt; &amp;closeCallback) const {
+		if (listenSocketType != &quot;unix&quot;) {
+			throw &quot;TODO: implement support for socket types other than 'unix'&quot;;
+		}
+		
 		TRACE_POINT();
 		int fd, ret;
 		
@@ -437,12 +440,7 @@ public:
 		
 		struct sockaddr_un addr;
 		addr.sun_family = AF_UNIX;
-		if (usingAbstractNamespace) {
-			strncpy(addr.sun_path + 1, listenSocketName.c_str(), sizeof(addr.sun_path) - 1);
-			addr.sun_path[0] = '\0';
-		} else {
-			strncpy(addr.sun_path, listenSocketName.c_str(), sizeof(addr.sun_path));
-		}
+		strncpy(addr.sun_path, listenSocketName.c_str(), sizeof(addr.sun_path));
 		addr.sun_path[sizeof(addr.sun_path) - 1] = '\0';
 		do {
 			ret = ::connect(fd, (const sockaddr *) &amp;addr, sizeof(addr));</diff>
      <filename>ext/apache2/Application.h</filename>
    </modified>
    <modified>
      <diff>@@ -314,10 +314,9 @@ private:
 		}
 		
 		pid_t pid = atoi(args[0]);
-		bool usingAbstractNamespace = args[2] == &quot;true&quot;;
 		
 		UPDATE_TRACE_POINT();
-		if (!usingAbstractNamespace) {
+		if (args[2] == &quot;unix&quot;) {
 			int ret;
 			do {
 				ret = chmod(args[1].c_str(), S_IRUSR | S_IWUSR);
@@ -327,7 +326,7 @@ private:
 			} while (ret == -1 &amp;&amp; errno == EINTR);
 		}
 		return ApplicationPtr(new Application(spawnOptions.appRoot,
-			pid, args[1], usingAbstractNamespace, ownerPipe));
+			pid, args[1], args[2], ownerPipe));
 	}
 	
 	/**</diff>
      <filename>ext/apache2/SpawnManager.h</filename>
    </modified>
    <modified>
      <diff>@@ -39,21 +39,6 @@ module Passenger
 # administrator maintenance overhead. These decisions are documented
 # in this section.
 #
-# === Abstract namespace Unix sockets
-#
-# AbstractRequestHandler listens on a Unix socket for incoming requests. If possible,
-# AbstractRequestHandler will try to create a Unix socket on the _abstract namespace_,
-# instead of on the filesystem. If the RoR application crashes (segfault),
-# or if it gets killed by SIGKILL, or if the system loses power, then there
-# will be no stale socket files left on the filesystem.
-# Unfortunately, abstract namespace Unix sockets are only supported by Linux.
-# On systems that do not support abstract namespace Unix sockets,
-# AbstractRequestHandler will automatically fallback to using regular Unix socket files.
-#
-# It is possible to force AbstractRequestHandler to use regular Unix socket files by
-# setting the environment variable PASSENGER_NO_ABSTRACT_NAMESPACE_SOCKETS
-# to 1.
-#
 # === Owner pipes
 #
 # Because only the web server communicates directly with a request handler,
@@ -111,15 +96,16 @@ class AbstractRequestHandler
 	X_POWERED_BY        = 'X-Powered-By'        # :nodoc:
 	
 	# The name of the socket on which the request handler accepts
-	# new connections. This is either a Unix socket filename, or
-	# the name for an abstract namespace Unix socket.
+	# new connections. At this moment, this value is always the filename
+	# of a Unix domain socket.
 	#
-	# If +socket_name+ refers to an abstract namespace Unix socket,
-	# then the name does _not_ contain a leading null byte.
-	#
-	# See also using_abstract_namespace?
+	# See also #socket_type.
 	attr_reader :socket_name
 	
+	# The type of socket that #socket_name refers to. At the moment, the
+	# value is always 'unix', which indicates a Unix domain socket.
+	attr_reader :socket_type
+	
 	# Specifies the maximum allowed memory usage, in MB. If after having processed
 	# a request AbstractRequestHandler detects that memory usage has risen above
 	# this limit, then it will gracefully exit (that is, exit after having processed
@@ -142,14 +128,8 @@ class AbstractRequestHandler
 	# Additionally, the following options may be given:
 	# - memory_limit: Used to set the +memory_limit+ attribute.
 	def initialize(owner_pipe, options = {})
-		if abstract_namespace_sockets_allowed?
-			@using_abstract_namespace = create_unix_socket_on_abstract_namespace
-		else
-			@using_abstract_namespace = false
-		end
-		if !@using_abstract_namespace
-			create_unix_socket_on_filesystem
-		end
+		@socket_type = 'unix'
+		create_unix_socket_on_filesystem
 		@socket.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
 		@owner_pipe = owner_pipe
 		@previous_signal_handlers = {}
@@ -174,14 +154,7 @@ class AbstractRequestHandler
 		end
 		@socket.close rescue nil
 		@owner_pipe.close rescue nil
-		if !using_abstract_namespace?
-			File.unlink(@socket_name) rescue nil
-		end
-	end
-	
-	# Returns whether socket_name refers to an abstract namespace Unix socket.
-	def using_abstract_namespace?
-		return @using_abstract_namespace
+		File.unlink(@socket_name) rescue nil
 	end
 	
 	# Check whether the main loop's currently running.
@@ -268,33 +241,6 @@ class AbstractRequestHandler
 private
 	include Utils
 
-	def create_unix_socket_on_abstract_namespace
-		while true
-			begin
-				# I have no idea why, but using base64-encoded IDs
-				# don't pass the unit tests. I couldn't find the cause
-				# of the problem. The system supports base64-encoded
-				# names for abstract namespace unix sockets just fine.
-				@socket_name = generate_random_id(:hex)
-				@socket_name = @socket_name.slice(0, NativeSupport::UNIX_PATH_MAX - 2)
-				fd = NativeSupport.create_unix_socket(&quot;\x00#{socket_name}&quot;, BACKLOG_SIZE)
-				@socket = IO.new(fd)
-				@socket.instance_eval do
-					def accept
-						fd = NativeSupport.accept(fileno)
-						return IO.new(fd)
-					end
-				end
-				return true
-			rescue Errno::EADDRINUSE
-				# Do nothing, try again with another name.
-			rescue Errno::ENOENT
-				# Abstract namespace sockets not supported on this system.
-				return false
-			end
-		end
-	end
-	
 	def create_unix_socket_on_filesystem
 		done = false
 		while !done
@@ -432,11 +378,6 @@ private
 		return data
 	end
 	
-	def abstract_namespace_sockets_allowed?
-		value = ENV['PASSENGER_NO_ABSTRACT_NAMESPACE_SOCKETS']
-		return value.nil? || value.empty?
-	end
-
 	def self.determine_passenger_version
 		rakefile = &quot;#{File.dirname(__FILE__)}/../../Rakefile&quot;
 		if File.exist?(rakefile)</diff>
      <filename>lib/passenger/abstract_request_handler.rb</filename>
    </modified>
    <modified>
      <diff>@@ -29,10 +29,16 @@ class Application
 	# The process ID of this application instance.
 	attr_reader :pid
 	
-	# The name of the Unix socket on which the application instance will accept
-	# new connections.
+	# The name of the socket on which the application instance will accept
+	# new connections. See #listen_socket_type on how one should interpret
+	# this value.
 	attr_reader :listen_socket_name
 	
+	# The type of socket that #listen_socket_name refers to. Currently this
+	# is always 'unix', which means that #listen_socket_name refers to the
+	# filename of a Unix domain socket.
+	attr_reader :listen_socket_type
+	
 	# The owner pipe of the application instance (an IO object). Please see
 	# RequestHandler for a description of the owner pipe.
 	attr_reader :owner_pipe
@@ -80,23 +86,14 @@ class Application
 
 	# Creates a new instance of Application. The parameters correspond with the attributes
 	# of the same names. No exceptions will be thrown.
-	def initialize(app_root, pid, listen_socket_name, using_abstract_namespace, owner_pipe)
+	def initialize(app_root, pid, listen_socket_name, listen_socket_type, owner_pipe)
 		@app_root = app_root
 		@pid = pid
 		@listen_socket_name = listen_socket_name
-		@using_abstract_namespace = using_abstract_namespace
+		@listen_socket_type = listen_socket_type
 		@owner_pipe = owner_pipe
 	end
 	
-	# Whether _listen_socket_name_ refers to a Unix socket in the abstract namespace.
-	# In any case, _listen_socket_name_ does *not* contain the leading null byte.
-	#
-	# Note that at the moment, only Linux seems to support abstract namespace Unix
-	# sockets.
-	def using_abstract_namespace?
-		return @using_abstract_namespace
-	end
-	
 	# Close the connection with the application instance. If there are no other
 	# processes that have connections to this application instance, then it will
 	# shutdown as soon as possible.</diff>
      <filename>lib/passenger/application.rb</filename>
    </modified>
    <modified>
      <diff>@@ -65,13 +65,13 @@ class ApplicationSpawner
 		unmarshal_and_raise_errors(channel, &quot;rack&quot;)
 		
 		# No exception was raised, so spawning succeeded.
-		pid, socket_name, using_abstract_namespace = channel.read
+		pid, socket_name, socket_type = channel.read
 		if pid.nil?
 			raise IOError, &quot;Connection closed&quot;
 		end
 		owner_pipe = channel.recv_io
 		return Application.new(@app_root, pid, socket_name,
-			using_abstract_namespace == &quot;true&quot;, owner_pipe)
+			socket_type, owner_pipe)
 	end
 
 private
@@ -94,7 +94,7 @@ private
 			begin
 				handler = RequestHandler.new(reader, app, options)
 				channel.write(Process.pid, handler.socket_name,
-					handler.using_abstract_namespace?)
+					handler.socket_type)
 				channel.send_io(writer)
 				writer.close
 				channel.close</diff>
      <filename>lib/passenger/rack/application_spawner.rb</filename>
    </modified>
    <modified>
      <diff>@@ -108,13 +108,13 @@ class ApplicationSpawner &lt; AbstractServer
 	# - ApplicationSpawner::Error: The ApplicationSpawner server exited unexpectedly.
 	def spawn_application
 		server.write(&quot;spawn_application&quot;)
-		pid, socket_name, using_abstract_namespace = server.read
+		pid, socket_name, socket_type = server.read
 		if pid.nil?
 			raise IOError, &quot;Connection closed&quot;
 		end
 		owner_pipe = server.recv_io
 		return Application.new(@app_root, pid, socket_name,
-			using_abstract_namespace == &quot;true&quot;, owner_pipe)
+			socket_type, owner_pipe)
 	rescue SystemCallError, IOError, SocketError =&gt; e
 		raise Error, &quot;The application spawner server exited unexpectedly&quot;
 	end
@@ -171,13 +171,13 @@ class ApplicationSpawner &lt; AbstractServer
 		unmarshal_and_raise_errors(channel)
 		
 		# No exception was raised, so spawning succeeded.
-		pid, socket_name, using_abstract_namespace = channel.read
+		pid, socket_name, socket_type = channel.read
 		if pid.nil?
 			raise IOError, &quot;Connection closed&quot;
 		end
 		owner_pipe = channel.recv_io
 		return Application.new(@app_root, pid, socket_name,
-			using_abstract_namespace == &quot;true&quot;, owner_pipe)
+			socket_type, owner_pipe)
 	end
 	
 	# Overrided from AbstractServer#start.
@@ -316,7 +316,7 @@ private
 			reader.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
 			handler = RequestHandler.new(reader, @options)
 			channel.write(Process.pid, handler.socket_name,
-				handler.using_abstract_namespace?)
+				handler.socket_type)
 			channel.send_io(writer)
 			writer.close
 			channel.close</diff>
      <filename>lib/passenger/railz/application_spawner.rb</filename>
    </modified>
    <modified>
      <diff>@@ -171,13 +171,13 @@ class FrameworkSpawner &lt; AbstractServer
 				end
 				raise e
 			else
-				pid, listen_socket_name, using_abstract_namespace = server.read
+				pid, listen_socket_name, socket_type = server.read
 				if pid.nil?
 					raise IOError, &quot;Connection closed&quot;
 				end
 				owner_pipe = server.recv_io
 				return Application.new(app_root, pid, listen_socket_name,
-					using_abstract_namespace == &quot;true&quot;, owner_pipe)
+					socket_type, owner_pipe)
 			end
 		rescue SystemCallError, IOError, SocketError =&gt; e
 			raise Error, &quot;The framework spawner server exited unexpectedly&quot;
@@ -317,7 +317,7 @@ private
 			end
 		end
 		client.write('success')
-		client.write(app.pid, app.listen_socket_name, app.using_abstract_namespace?)
+		client.write(app.pid, app.listen_socket_name, app.listen_socket_type)
 		client.send_io(app.owner_pipe)
 		app.close
 	end</diff>
      <filename>lib/passenger/railz/framework_spawner.rb</filename>
    </modified>
    <modified>
      <diff>@@ -330,7 +330,8 @@ private
 		if app
 			begin
 				client.write('ok')
-				client.write(app.pid, app.listen_socket_name, app.using_abstract_namespace?)
+				client.write(app.pid, app.listen_socket_name,
+					app.listen_socket_type)
 				client.send_io(app.owner_pipe)
 			rescue Errno::EPIPE
 				# The Apache module may be interrupted during a spawn command,</diff>
      <filename>lib/passenger/spawn_manager.rb</filename>
    </modified>
    <modified>
      <diff>@@ -54,13 +54,13 @@ class ApplicationSpawner
 		Process.waitpid(pid) rescue nil
 		
 		channel = MessageChannel.new(a)
-		pid, socket_name, using_abstract_namespace = channel.read
+		pid, socket_name, socket_type = channel.read
 		if pid.nil?
 			raise IOError, &quot;Connection closed&quot;
 		end
 		owner_pipe = channel.recv_io
 		return Application.new(@app_root, pid, socket_name,
-			using_abstract_namespace == &quot;true&quot;, owner_pipe)
+			socket_type, owner_pipe)
 	end
 
 private
@@ -76,7 +76,7 @@ private
 		server = UNIXServer.new(socket_file)
 		begin
 			reader, writer = IO.pipe
-			channel.write(Process.pid, socket_file, &quot;false&quot;)
+			channel.write(Process.pid, socket_file, &quot;unix&quot;)
 			channel.send_io(writer)
 			writer.close
 			channel.close</diff>
      <filename>lib/passenger/wsgi/application_spawner.rb</filename>
    </modified>
    <modified>
      <diff>@@ -8,7 +8,7 @@ include Passenger
 
 describe AbstractRequestHandler do
 	before :each do
-		prepare
+		ENV['PHUSION_PASSENGER_TMP'] = &quot;abstract_request_handler_spec.tmp&quot;
 		@owner_pipe = IO.pipe
 		@request_handler = AbstractRequestHandler.new(@owner_pipe[1])
 		def @request_handler.process_request(*args)
@@ -19,6 +19,8 @@ describe AbstractRequestHandler do
 	after :each do
 		@request_handler.cleanup
 		@owner_pipe[0].close rescue nil
+		ENV.delete('PHUSION_PASSENGER_TMP')
+		FileUtils.rm_rf(&quot;abstract_request_handler_spec.tmp&quot;)
 	end
 	
 	def prepare
@@ -50,21 +52,8 @@ describe AbstractRequestHandler do
 		@request_handler.processed_requests.should == 0
 	end
 	
-	describe &quot;if abstract namespace sockets are not supported on the current platform&quot; do
-		def prepare
-			ENV['PASSENGER_NO_ABSTRACT_NAMESPACE_SOCKETS'] = &quot;true&quot;
-			ENV['PHUSION_PASSENGER_TMP'] = &quot;abstract_request_handler_spec.tmp&quot;
-		end
-		
-		after :each do
-			ENV.delete('PASSENGER_NO_ABSTRACT_NAMESPACE_SOCKETS')
-			ENV.delete('PHUSION_PASSENGER_TMP')
-			FileUtils.rm_rf(&quot;abstract_request_handler_spec.tmp&quot;)
-		end
-		
-		it &quot;creates a socket file in the Phusion Passenger temp folder&quot; do
-			Dir[&quot;abstract_request_handler_spec.tmp/*&quot;].should_not be_empty
-		end
+	it &quot;creates a socket file in the Phusion Passenger temp folder&quot; do
+		Dir[&quot;abstract_request_handler_spec.tmp/*&quot;].should_not be_empty
 	end
 	
 	def wait_until</diff>
      <filename>test/ruby/abstract_request_handler_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>ba851417590bcd7e86fb0b13a438a1186cee15b4</id>
    </parent>
  </parents>
  <author>
    <name>Hongli Lai (Phusion)</name>
    <email>hongli@phusion.nl</email>
  </author>
  <url>http://github.com/FooBarWidget/passenger/commit/8e305273f505214c4f1efe7db1b1633fb29f41e4</url>
  <id>8e305273f505214c4f1efe7db1b1633fb29f41e4</id>
  <committed-date>2008-11-20T10:50:56-08:00</committed-date>
  <authored-date>2008-11-20T10:50:56-08:00</authored-date>
  <message>Get rid of the support for abstract Unix sockets, but add basic infrastructure for supporting other kinds of listener sockets in the future (e.g. TCP sockets).</message>
  <tree>e5498170a742c214bddfe6642022be3a235ed7d0</tree>
  <committer>
    <name>Hongli Lai (Phusion)</name>
    <email>hongli@phusion.nl</email>
  </committer>
</commit>
