unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* alive.chmod(Time.now.to_i) raises Errno::EINVAL on OpenBSD
@ 2009-10-08 23:57 Jeremy Evans
  2009-10-09  3:22 ` Eric Wong
  0 siblings, 1 reply; 2+ messages in thread
From: Jeremy Evans @ 2009-10-08 23:57 UTC (permalink / raw)
  To: mongrel-unicorn

On OpenBSD:

$ ruby -e "File.new('TODO').chmod(Time.now.to_i)"
-e:1:in `chmod': Invalid argument - TODO (Errno::EINVAL)
        from -e:1

This is explained in the man page:

     int
     fchmod(int fd, mode_t mode);

    ...

     [EINVAL]      mode contains bits other than the file type and those de-
                   scribed above.

I think 04777 is the highest allowed mode on OpenBSD.  Time.now.to_i
is obviously higher than that.

Here's a diff that should fix the problem.  At the very least it
allows the workers to start without crashing:

diff --git a/lib/unicorn.rb b/lib/unicorn.rb
index ddec8e9..092f500 100644
--- a/lib/unicorn.rb
+++ b/lib/unicorn.rb
@@ -579,13 +579,13 @@ module Unicorn
         # changes with chmod doesn't update ctime on all filesystems; so
         # we change our counter each and every time (after process_client
         # and before IO.select).
-        t == (ti = Time.now.to_i) or alive.chmod(t = ti)
+        t == (ti = Time.now.to_i) or (t = ti;
alive.chmod(alive.stat.mode ^ 0100))

         ready.each do |sock|
           begin
             process_client(sock.accept_nonblock)
             nr += 1
-            t == (ti = Time.now.to_i) or alive.chmod(t = ti)
+            t == (ti = Time.now.to_i) or (t = ti;
alive.chmod(alive.stat.mode ^ 0100))
           rescue Errno::EAGAIN, Errno::ECONNABORTED
           end
           break if nr < 0

There are definitely other ways that will work, as long as the mode is
kept between 0 and 04777.

Jeremy

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-10-09  3:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-08 23:57 alive.chmod(Time.now.to_i) raises Errno::EINVAL on OpenBSD Jeremy Evans
2009-10-09  3:22 ` Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).