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.



473
474
475
476
477
478
479
# File 'lib/net-ssh-open3.rb', line 473

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.



463
464
465
# File 'lib/net-ssh-open3.rb', line 463

def open3_close_semaphore
  @open3_close_semaphore
end

#open3_exceptionObject (readonly)

An exception tracked during channel opening, if any.



466
467
468
# File 'lib/net-ssh-open3.rb', line 466

def open3_exception
  @open3_exception
end

#open3_waiter_threadObject

Waiter thread that watches this channel.



469
470
471
# File 'lib/net-ssh-open3.rb', line 469

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.



483
484
485
486
487
488
489
# File 'lib/net-ssh-open3.rb', line 483

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.



493
494
495
496
497
498
# File 'lib/net-ssh-open3.rb', line 493

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.



502
503
504
505
506
507
508
509
# File 'lib/net-ssh-open3.rb', line 502

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.



537
538
539
# File 'lib/net-ssh-open3.rb', line 537

def open3_signal_close
  @open3_close_semaphore.signal
end

#open3_signal_openObject

Flag this channel as opened and deliver signals.



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

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.



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

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.



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

def wait
  @open3_waiter_thread.join
  self
end