Project

General

Profile

Bug #14171 ยป 0001-Avoid-creating-a-Thread-for-shutting-down-a-DRbServe.patch

Eregon (Benoit Daloze), 12/12/2017 01:27 PM

View differences:

lib/drb/drb.rb
1466 1466
      if  Thread.current['DRb'] && Thread.current['DRb']['server'] == self
1467 1467
        Thread.current['DRb']['stop_service'] = true
1468 1468
      else
1469
        if @protocol.respond_to? :shutdown
1470
          @protocol.shutdown
1471
        else
1472
          [@thread, *@grp.list].each {|thread| thread.kill} # xxx: Thread#kill
1473
        end
1474
        @thread.join
1469
        shutdown
1475 1470
      end
1476 1471
    end
1477 1472

  
......
1490 1485

  
1491 1486
    private
1492 1487

  
1488
    def shutdown
1489
      current = Thread.current
1490
      if @protocol.respond_to? :shutdown
1491
        @protocol.shutdown
1492
      else
1493
        [@thread, *@grp.list].each { |thread|
1494
          thread.kill unless thread == current # xxx: Thread#kill
1495
        }
1496
      end
1497
      @thread.join unless @thread == current
1498
    end
1499

  
1493 1500
    ##
1494 1501
    # Starts the DRb main loop in a new thread.
1495 1502

  
......
1671 1678
            error_print(e) if verbose
1672 1679
          ensure
1673 1680
            client.close unless succ
1674
            if Thread.current['DRb']['stop_service']
1675
              Thread.new { stop_service }
1676
            end
1681
            shutdown if Thread.current['DRb']['stop_service']
1677 1682
            break unless succ
1678 1683
          end
1679 1684
        end
1680
-