Skip to content

Commit 4763a10

Browse files
committed
pass the runtime around in SSLSocket's waitSelect instead of calling getRuntime
1 parent e2025e4 commit 4763a10

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

src/main/java/org/jruby/ext/openssl/SSLSocket.java

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -319,27 +319,30 @@ private boolean waitSelect(final int operations, final boolean blocking) throws
319319
thread.executeBlockingTask(new RubyThread.BlockingTask() {
320320
public void run() throws InterruptedException {
321321
try {
322-
if (!blocking) {
322+
if ( ! blocking ) {
323323
result[0] = selector.selectNow();
324-
if (result[0] == 0) {
324+
325+
if ( result[0] == 0 ) {
325326
if ((operations & SelectionKey.OP_READ) != 0 && (operations & SelectionKey.OP_WRITE) != 0) {
326-
if (key.isReadable()) {
327-
writeWouldBlock();
328-
} else if (key.isWritable()) {
329-
readWouldBlock();
327+
if ( key.isReadable() ) {
328+
writeWouldBlock(runtime);
329+
} else if ( key.isWritable() ) {
330+
readWouldBlock(runtime);
330331
} else { //neither, pick one
331-
readWouldBlock();
332+
readWouldBlock(runtime);
332333
}
333334
} else if ((operations & SelectionKey.OP_READ) != 0) {
334-
readWouldBlock();
335+
readWouldBlock(runtime);
335336
} else if ((operations & SelectionKey.OP_WRITE) != 0) {
336-
writeWouldBlock();
337+
writeWouldBlock(runtime);
337338
}
338339
}
339-
} else {
340+
}
341+
else {
340342
result[0] = selector.select();
341343
}
342-
} catch (IOException ioe) {
344+
}
345+
catch (IOException ioe) {
343346
throw runtime.newRuntimeError("Error with selector: " + ioe.getMessage());
344347
}
345348
}
@@ -349,10 +352,9 @@ public void wakeup() {
349352
}
350353
});
351354

352-
if (result[0] >= 1) {
355+
if ( result[0] >= 1 ) {
353356
Set<SelectionKey> keySet = selector.selectedKeys();
354-
355-
if (keySet.iterator().next() == key) {
357+
if ( keySet.iterator().next() == key ) {
356358
return true;
357359
}
358360
}
@@ -396,12 +398,12 @@ public void wakeup() {
396398
}
397399
}
398400

399-
private void readWouldBlock() {
400-
throw newSSLErrorWaitReadable(getRuntime(), "read would block");
401+
private static void readWouldBlock(final Ruby runtime) {
402+
throw newSSLErrorWaitReadable(runtime, "read would block");
401403
}
402404

403-
private void writeWouldBlock() {
404-
throw newSSLErrorWaitWritable(getRuntime(), "write would block");
405+
private static void writeWouldBlock(final Ruby runtime) {
406+
throw newSSLErrorWaitWritable(runtime, "write would block");
405407
}
406408

407409
private void doHandshake(boolean blocking) throws IOException {

0 commit comments

Comments
 (0)