Project

General

Profile

Feature #15350 ยป 0001-thread_sync.c-queue_sleep-remove-deadlock-checking.patch

normalperson (Eric Wong), 11/27/2018 10:52 PM

View differences:

test/ruby/test_thread_queue.rb
567 567
      puts q.pop
568 568
      puts 'exit'
569 569
    INPUT
570

  
571
    skip 'fork not present' unless Process.respond_to?(:fork)
572
    assert_separately([], <<-INPUT)
573
      q = Queue.new
574
      trap(:CHLD) { q.push :CHLD }
575
      pid = fork { exit!(0) }
576
      q.pop
577
      pid, st = Process.waitpid2(pid)
578
      assert_predicate st, :success?
579
    INPUT
570 580
  end
571 581

  
572 582
  def test_fork_while_queue_waiting
thread_sync.c
862 862
    return queue_do_push(self, queue_ptr(self), obj);
863 863
}
864 864

  
865
static VALUE
866
queue_sleep(VALUE arg)
867
{
868
    rb_thread_sleep_deadly_allow_spurious_wakeup();
869
    return Qnil;
870
}
871

  
872 865
struct queue_waiter {
873 866
    struct sync_waiter w;
874 867
    union {
......
877 870
    } as;
878 871
};
879 872

  
873
static VALUE
874
queue_sleep(VALUE p)
875
{
876
    struct queue_waiter *qw = (struct queue_waiter *)p;
877

  
878
    sleep_forever(qw->w.th, 0);
879

  
880
    return Qnil;
881
}
882

  
880 883
static VALUE
881 884
queue_sleep_done(VALUE p)
882 885
{
......
922 925
	    list_add_tail(&qw.as.q->waitq, &qw.w.node);
923 926
	    qw.as.q->num_waiting++;
924 927

  
925
	    rb_ensure(queue_sleep, self, queue_sleep_done, (VALUE)&qw);
928
	    rb_ensure(queue_sleep, (VALUE)&qw, queue_sleep_done, (VALUE)&qw);
926 929
	}
927 930
    }
928 931

  
......
1162 1165
	    list_add_tail(pushq, &qw.w.node);
1163 1166
	    sq->num_waiting_push++;
1164 1167

  
1165
	    rb_ensure(queue_sleep, self, szqueue_sleep_done, (VALUE)&qw);
1168
	    rb_ensure(queue_sleep, (VALUE)&qw, szqueue_sleep_done, (VALUE)&qw);
1166 1169
	}
1167 1170
    }
1168 1171

  
1169
-