yahns Ruby server user/dev discussion
 help / color / mirror / code / Atom feed
blob 17bfc6e571f6cc32b7adb1638e921b2b5314c54c 887 bytes (raw)
name: lib/yahns/worker.rb 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 
# -*- encoding: binary -*-
# Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors
# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
class Yahns::Worker # :nodoc:
  attr_accessor :nr
  attr_reader :to_io

  def initialize(nr, sig_queue)
    @nr = nr
    @sig_queue = sig_queue
    @to_io, @wr = Kgio::Pipe.new
  end

  def atfork_child
    @wr = @wr.close # nil @wr to save space in worker process
  end

  def atfork_parent
    @sig_queue = nil
    @to_io = @to_io.close
    self
  end

  # used in the worker process.
  # This causes the worker to gracefully exit if the master
  # dies unexpectedly.
  def yahns_step
    if @to_io.kgio_tryread(11) == nil
      @sig_queue << :QUIT
      @to_io.close
    end
    :ignore
  end

  # worker objects may be compared to just plain Integers
  def ==(other_nr) # :nodoc:
    @nr == other_nr
  end
end

debug log:

solving 17bfc6e ...
found 17bfc6e in https://yhbt.net/yahns-public/20140509010526.GA25397@dcvr.yhbt.net/
found 9b1bb8a in https://yhbt.net/yahns.git/
preparing index
index prepared:
100644 9b1bb8a680dce2debed865ce2edd70f7a0740cfc	lib/yahns/worker.rb

applying [1/1] https://yhbt.net/yahns-public/20140509010526.GA25397@dcvr.yhbt.net/
diff --git a/lib/yahns/worker.rb b/lib/yahns/worker.rb
index 9b1bb8a..17bfc6e 100644

Checking patch lib/yahns/worker.rb...
Applied patch lib/yahns/worker.rb cleanly.

index at:
100644 17bfc6e571f6cc32b7adb1638e921b2b5314c54c	lib/yahns/worker.rb

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

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

	https://yhbt.net/yahns.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).