We got nominated! Help us out and vote for GitHub as Best Bootstrapped Startup of 2008. (You can vote once a day.) [ hide ]

public
Description: Phusion Passenger (mod_rails)
Homepage: http://www.modrails.com/
Clone URL: git://github.com/FooBarWidget/passenger.git
Click here to lend your support to: passenger and make a donation at www.pledgie.com !
Fix file descriptor passing on 64-bit FreeBSD 7.
Hongli Lai (Phusion) (author)
Thu Jul 24 06:49:53 -0700 2008
commit  2de5e1c93be18d167b69d0a1b95ca76e4fccece5
tree    4b98847ba3f424bfab042a06cc8b0dc1c9e00272
parent  bfd852160637394ebab4699c2b12c170e4f39a0a
...
351
352
353
 
 
 
 
 
 
 
354
355
356
357
358
359
 
360
361
362
...
364
365
366
367
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
368
369
370
...
377
378
379
380
...
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
 
366
367
368
369
...
371
372
373
 
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
...
400
401
402
 
0
@@ -351,12 +351,19 @@ class ConditionVariable
0
 end
0
 
0
 class IO
0
+ # ApplicationSpawner/FrameworkSpawner might temporarily undefine
0
+ # the 'Passenger' module in order to avoid namespace collissions
0
+ # with the spawned application. So we save the NativeSupport
0
+ # module in a constant so that we can access it whether
0
+ # our 'Passenger' module is defined or not.
0
+ NATIVE_SUPPORT = Passenger::NativeSupport
0
+
0
   # Send an IO object (i.e. a file descriptor) over this IO channel.
0
   # This only works if this IO channel is a Unix socket.
0
   #
0
   # Raises SystemCallError if something went wrong.
0
   def send_io(io)
0
- Passenger::NativeSupport.send_fd(self.fileno, io.fileno)
0
+ NATIVE_SUPPORT.send_fd(self.fileno, io.fileno)
0
   end
0
   
0
   # Receive an IO object (i.e. a file descriptor) from this IO channel.
0
@@ -364,7 +371,23 @@ class IO
0
   #
0
   # Raises SystemCallError if something went wrong.
0
   def recv_io
0
- return IO.new(Passenger::NativeSupport.recv_fd(self.fileno))
0
+ return IO.new(NATIVE_SUPPORT.recv_fd(self.fileno))
0
+ end
0
+end
0
+
0
+# Ruby's implementation of UNIXSocket#recv_io and UNIXSocket#send_io
0
+# are broken on 64-bit FreeBSD 7. So we override them with our own
0
+# implementation.
0
+if RUBY_PLATFORM =~ /freebsd/
0
+ require 'socket'
0
+ UNIXSocket.class_eval do
0
+ def recv_io
0
+ super
0
+ end
0
+
0
+ def send_io(io)
0
+ super
0
+ end
0
   end
0
 end
0
 
0
@@ -377,4 +400,3 @@ module GC
0
     end
0
   end
0
 end
0
-

Comments

    No one has commented yet.