Class: Net::SSH::Connection::Channel

Inherits:
Object
  • Object
show all
Defined in:
lib/net-ssh-open3.rb

Overview

All methods in this class were created for private use of Net::SSH::Open3. You probably won’t need to call them directly.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args, &block) ⇒ Channel

Overridden version of initialize which creates synchronization objects.



528
529
530
531
532
533
534
# File 'lib/net-ssh-open3.rb', line 528

def initialize(*args, &block)
  initialize_without_open3(*args, &block)
  @open3_close_semaphore = ConditionVariable.new

  @open3_open_mutex = Mutex.new
  @open3_open_semaphore = ConditionVariable.new
end

Instance Attribute Details

#open3_close_semaphoreObject (readonly)

A semaphore to flag this channel as closed.



518
519
520
# File 'lib/net-ssh-open3.rb', line 518

def open3_close_semaphore
  @open3_close_semaphore
end

#open3_exceptionObject (readonly)

An exception tracked during channel opening, if any.



521
522
523
# File 'lib/net-ssh-open3.rb', line 521

def open3_exception
  @open3_exception
end

#open3_waiter_threadObject

Waiter thread that watches this channel.



524
525
526
# File 'lib/net-ssh-open3.rb', line 524

def open3_waiter_thread
  @open3_waiter_thread
end

Instance Method Details

#do_close(*args) ⇒ Object

Overridden version of do_close which tracks exceptions and sync.



538
539
540
541
542
543
544
# File 'lib/net-ssh-open3.rb', line 538

def do_close(*args)
  do_close_without_open3(*args)
rescue
  @open3_exception = $!
ensure
  open3_signal_close
end

#do_open_confirmation(*args) ⇒ Object

Overridden version of do_open_confirmation which tracks exceptions.



548
549
550
551
552
553
# File 'lib/net-ssh-open3.rb', line 548

def do_open_confirmation(*args)
  do_open_confirmation_without_open3(*args)
  # Do not signal right now: we will signal as soon as PID arrives.
rescue
  @open3_exception = $!
end

#do_open_failed(*args) ⇒ Object

Overridden version of do_open_failed which tracks exceptions and sync.



557
558
559
560
561
562
563
564
# File 'lib/net-ssh-open3.rb', line 557

def do_open_failed(*args)
  do_open_failed_without_open3(*args)
rescue
  @open3_exception = $!
ensure
  open3_signal_open
  open3_signal_close
end

#open3_signal_closeObject

Flag this channel as closed and deliver signals. Should be called from within session’s mutex.



592
593
594
# File 'lib/net-ssh-open3.rb', line 592

def open3_signal_close
  @open3_close_semaphore.signal
end

#open3_signal_openObject

Flag this channel as opened and deliver signals.



586
587
588
# File 'lib/net-ssh-open3.rb', line 586

def open3_signal_open
  @open3_open_mutex.synchronize { @open3_open_semaphore.signal }
end

#open3_wait_openObject

Suspend current thread execution until this channel is opened. Raises an exception if tracked during opening.



573
574
575
576
577
# File 'lib/net-ssh-open3.rb', line 573

def open3_wait_open
  @open3_open_mutex.synchronize { @open3_open_semaphore.wait(@open3_open_mutex) }
  raise *open3_exception if open3_exception
  self
end

#waitObject

Wait for this channel to be closed.



580
581
582
583
# File 'lib/net-ssh-open3.rb', line 580

def wait
  @open3_waiter_thread.join
  self
end