Background jobs with #fork

paddor paddor at gmail.com
Fri Apr 13 12:11:02 UTC 2012


> No problem.  I've also pushed it out as a commit + test case:
>
>  http://bogomips.org/unicorn.git/patch?id=b26d3e2c4387707c

Thank you (and Hongli Lai) so much. It works like a charm :-)


> If a kernel were implemented in Ruby, close() would be something like
> this, showing how shutdown() can get called automatically:
>
>  def SYS_close(fd)
>    # assume @fd_map is an array mapping fd to file/socket objects
>    io_object = @fd_map[fd]
>
>    return Errno::EBADF if io_object.nil?
>
>    # allow +fd+ to be reused immediately
>    @fd_map[fd] = nil
>
>    io_object.refcount -= 1
>
>    # if there are no more references, do other work:
>    if io_object.refcount == 0
>      if io_object.kind_of?(Socket)
>        # assume this is idempotent
>        SYS_shutdown(fd, SHUT_RDWR)
>      end
>
>      # free memory and any other resources allocated
>      io_object.destroy!
>    end
>  end

Thanks for this explanation. I understand now. :-)


--
paddor


More information about the mongrel-unicorn mailing list