Title: [1142] trunk/jopenssl/src/java/org/jruby/ext/openssl/SSLSocket.java:
Fix for JRUBY-3288: jruby-openssl: SSLSocket.syswrite error for big (>16k)
data
- Revision
- 1142
- Author
- headius
- Date
- 2009-02-10 22:59:27 -0500 (Tue, 10 Feb 2009)
Log Message
Fix for JRUBY-3288: jruby-openssl: SSLSocket.syswrite error for big (>16k) data
Modified Paths
Diff
Modified: trunk/jopenssl/src/java/org/jruby/ext/openssl/SSLSocket.java (1141 => 1142)
--- trunk/jopenssl/src/java/org/jruby/ext/openssl/SSLSocket.java 2009-02-08 17:11:57 UTC (rev 1141)
+++ trunk/jopenssl/src/java/org/jruby/ext/openssl/SSLSocket.java 2009-02-11 03:59:27 UTC (rev 1142)
@@ -268,7 +268,7 @@
private boolean flushData() throws IOException {
try {
- c.write(netData);
+ writeToChannel(c, netData);
} catch (IOException ioe) {
netData.position(netData.limit());
throw ioe;
@@ -279,6 +279,14 @@
return true;
}
}
+
+ private int writeToChannel(SocketChannel channel, ByteBuffer buffer) throws IOException {
+ int totalWritten = 0;
+ while (buffer.hasRemaining()) {
+ totalWritten += channel.write(buffer);
+ }
+ return totalWritten;
+ }
private void finishInitialHandshake() {
initialHandshake = false;
@@ -428,13 +436,14 @@
waitSelect(wsel);
byte[] bls = arg.convertToString().getBytes();
ByteBuffer b1 = ByteBuffer.wrap(bls);
+ int written;
if(engine == null) {
- c.write(b1);
+ written = writeToChannel(c, b1);
} else {
- write(b1);
+ written = write(b1);
}
((RubyIO)api.callMethod(this,"io")).flush();
- return getRuntime().newFixnum(bls.length);
+ return getRuntime().newFixnum(written);
}
private void close() throws Exception {
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel