@@ -162,26 +162,26 @@ public IRubyObject initialize(final ThreadContext context, final IRubyObject[] a
162
162
final Ruby runtime = context .runtime ;
163
163
164
164
if (Arity .checkArgumentCount (runtime , args , 1 , 2 ) == 1 ) {
165
- sslContext = new SSLContext (runtime ).initializeImpl ();
165
+ this . sslContext = new SSLContext (runtime ).initializeImpl ();
166
166
} else {
167
167
if (!(args [1 ] instanceof SSLContext )) {
168
168
throw runtime .newTypeError (args [1 ], "OpenSSL::SSL::SSLContext" );
169
169
}
170
- sslContext = (SSLContext ) args [1 ];
170
+ this . sslContext = (SSLContext ) args [1 ];
171
171
}
172
172
173
173
if (!(args [0 ] instanceof RubyIO )) {
174
174
throw runtime .newTypeError ("IO expected but got " + args [0 ].getMetaClass ().getName ());
175
175
}
176
- setInstanceVariable ("@context" , this .sslContext ); // only compat (we do not use @context)
177
- setInstanceVariable ("@io" , this .io = (RubyIO ) args [0 ]);
176
+ setInstanceVariable ("@io" , this .io = (RubyIO ) args [0 ]); // RubyBasicSocket extends RubyIO
178
177
set_io_nonblock_checked (context , runtime .getTrue ());
179
178
// This is a bit of a hack: SSLSocket should share code with
180
179
// RubyBasicSocket, which always sets sync to true.
181
180
// Instead we set it here for now.
182
181
set_sync (context , runtime .getTrue ()); // io.sync = true
183
182
setInstanceVariable ("@sync_close" , runtime .getFalse ()); // self.sync_close = false
184
183
sslContext .setup (context );
184
+ setInstanceVariable ("@context" , sslContext ); // only compat (we do not use @context)
185
185
186
186
this .initializeTime = System .currentTimeMillis ();
187
187
@@ -471,8 +471,8 @@ else if ((operations & SelectionKey.OP_WRITE) != 0) {
471
471
writeWouldBlock (runtime , exception , result );
472
472
}
473
473
}
474
- }
475
- catch ( IOException ioe ) {
474
+ } catch ( IOException ioe ) {
475
+ debugStackTrace ( runtime , "SSLSocket.waitSelect" , ioe );
476
476
throw runtime .newRuntimeError ("Error with selector: " + ioe .getMessage ());
477
477
}
478
478
} else {
@@ -483,6 +483,7 @@ public void run() throws InterruptedException {
483
483
result [0 ] = selector .select ();
484
484
}
485
485
catch (IOException ioe ) {
486
+ debugStackTrace (runtime , "SSLSocket.waitSelect" , ioe );
486
487
throw runtime .newRuntimeError ("Error with selector: " + ioe .getMessage ());
487
488
}
488
489
}
@@ -505,32 +506,27 @@ public void wakeup() {
505
506
//JRuby <= 9.1.2.0 that makes this not always the case, so we have to check
506
507
return selector .selectedKeys ().contains (key ) ? Boolean .TRUE : Boolean .FALSE ;
507
508
}
508
- }
509
- catch (InterruptedException interrupt ) { return Boolean .FALSE ; }
510
- finally {
511
- // Note: I don't like ignoring these exceptions, but it's
512
- // unclear how likely they are to happen or what damage we
513
- // might do by ignoring them. Note that the pieces are separate
514
- // so that we can ensure one failing does not affect the others
515
- // running.
509
+ } catch (InterruptedException interrupt ) {
510
+ debug (runtime , "SSLSocket.waitSelect" , interrupt );
511
+ return Boolean .FALSE ;
512
+ } finally {
513
+ // Note: I don't like ignoring these exceptions, but it's unclear how likely they are to happen or what
514
+ // damage we might do by ignoring them. Note that the pieces are separate so that we can ensure one failing
515
+ // does not affect the others running.
516
516
517
517
// clean up the key in the selector
518
518
try {
519
519
if ( key != null ) key .cancel ();
520
520
if ( selector != null ) selector .selectNow ();
521
- }
522
- catch (Exception e ) { // ignore
523
- debugStackTrace (runtime , e );
521
+ } catch (Exception e ) { // ignore
522
+ debugStackTrace (runtime , "SSLSocket.waitSelect (ignored)" , e );
524
523
}
525
524
526
525
// shut down and null out the selector
527
526
try {
528
- if ( selector != null ) {
529
- runtime .getSelectorPool ().put (selector );
530
- }
531
- }
532
- catch (Exception e ) { // ignore
533
- debugStackTrace (runtime , e );
527
+ if ( selector != null ) runtime .getSelectorPool ().put (selector );
528
+ } catch (Exception e ) { // ignore
529
+ debugStackTrace (runtime , "SSLSocket.waitSelect (ignored)" , e );
534
530
}
535
531
536
532
if (blocking ) {
@@ -810,8 +806,11 @@ private void doShutdown() throws IOException {
810
806
flushData (true );
811
807
}
812
808
813
- private IRubyObject sysreadImpl (final ThreadContext context ,
814
- IRubyObject len , IRubyObject buff , final boolean blocking , final boolean exception ) {
809
+ /**
810
+ * @return the (@link RubyString} buffer or :wait_readable / :wait_writeable {@link RubySymbol}
811
+ */
812
+ private IRubyObject sysreadImpl (final ThreadContext context , final IRubyObject len , final IRubyObject buff ,
813
+ final boolean blocking , final boolean exception ) {
815
814
final Ruby runtime = context .runtime ;
816
815
817
816
final int length = RubyNumeric .fix2int (len );
0 commit comments