drbssh 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@ require 'rake'
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "drbssh"
7
- s.version = "0.5.1"
7
+ s.version = "0.5.2"
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = %w(kvs)
10
10
  s.email = %w(kvs@binarysolutions.dk)
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'drb'
4
4
  require 'socket'
5
+ require 'timeout'
5
6
 
6
7
  # DRb protocol handler for using a persistent SSH connection to a remote server. Creates a duplex
7
8
  # connection so DRbUndumped objects can contact the initiating machine back through the same link.
@@ -70,7 +71,13 @@ module DRb
70
71
  end
71
72
 
72
73
  def recv_reply
73
- @receiveq.pop
74
+ reply = @receiveq.pop
75
+ if reply.is_a? Exception
76
+ self.close
77
+ raise reply
78
+ else
79
+ reply
80
+ end
74
81
  end
75
82
 
76
83
  def alive?
@@ -134,8 +141,8 @@ module DRb
134
141
  def close
135
142
  # Closing the filedescriptors should trigger an IOError in the server-thread
136
143
  # waiting, which makes it close the client attached.
137
- self.read_fd.close
138
- self.write_fd.close
144
+ self.read_fd.close unless self.read_fd.closed?
145
+ self.write_fd.close unless self.write_fd.closed?
139
146
  end
140
147
  end
141
148
 
@@ -218,7 +225,8 @@ module DRb
218
225
  end
219
226
  end
220
227
  rescue
221
- client.close
228
+ client.receiveq.push($!)
229
+ @srv_requestq.push($!)
222
230
  end
223
231
  end
224
232
 
@@ -239,19 +247,32 @@ module DRb
239
247
  end
240
248
  end
241
249
  rescue
242
- client.close
250
+ client.receiveq.push($!)
251
+ @srv_requestq.push($!)
243
252
  end
244
253
  end
245
254
  end
246
255
 
247
256
  # Delegate shutdown to client.
248
257
  def close
258
+ return unless @client.alive?
259
+
260
+ Timeout::timeout(15) do
261
+ sleep 0.1 until @client.sendq.empty?
262
+ end rescue nil
263
+
249
264
  @client.close
250
265
  end
251
266
 
252
267
  # Wait for a request to appear on the request-queue
253
268
  def recv_request
254
- @srv_requestq.pop
269
+ reply = @srv_requestq.pop
270
+ if reply.is_a? Exception
271
+ self.close
272
+ raise reply
273
+ else
274
+ reply
275
+ end
255
276
  end
256
277
 
257
278
  # Queue client-reply
@@ -71,8 +71,21 @@ describe DRb::DRbSSHProtocol do
71
71
  drb.eval("`hostname`").should eq "vagrant-ubuntu-oneiric\n"
72
72
  pid = drb.eval('$$')
73
73
 
74
- expect { drb.eval('Kernel.exit! 0') }.to raise_exception IOError
74
+ expect { drb.eval('Kernel.exit! 0') }.to raise_exception(DRb::DRbConnError)
75
75
 
76
76
  drb.eval('$$').should_not eq pid # should create new connection
77
+
78
+ DRb.stop_service
79
+ end
80
+
81
+ it "handles eval-errors correctly" do
82
+ DRb.start_service("drbssh://")
83
+
84
+ drb = DRbObject.new_with_uri("drbssh://vagrant-drbssh/")
85
+ expect { drb.eval("raise 'test'") }.to raise_exception "test"
86
+
87
+ expect { drb.eval('Invalid') }.to raise_exception NameError
88
+
89
+ DRb.stop_service
77
90
  end
78
91
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drbssh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70111189214280 !ruby/object:Gem::Requirement
16
+ requirement: &70174137095020 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.8.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70111189214280
24
+ version_requirements: *70174137095020
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: guard-rspec
27
- requirement: &70111189213240 !ruby/object:Gem::Requirement
27
+ requirement: &70174137094240 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70111189213240
35
+ version_requirements: *70174137094240
36
36
  description: Allows DRb to create and use an SSH-connection.
37
37
  email:
38
38
  - kvs@binarysolutions.dk