Skip to content

Commit 0b6b739

Browse files
authored
Merge pull request #9 from kojo1/connectTimeout
2 parents 9423567 + 7ef5c79 commit 0b6b739

2 files changed

Lines changed: 24 additions & 6 deletions

File tree

native/com_wolfssl_WolfSSLSession.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,9 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLSession_write
749749
break;
750750
}
751751

752+
if (ret >= 0) /* return if it is success */
753+
break;
754+
752755
if (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE) {
753756

754757
sockfd = wolfSSL_get_fd(ssl);

src/java/com/wolfssl/provider/jsse/WolfSSLSocket.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,9 @@ synchronized public void startHandshake() throws IOException {
11501150
try {
11511151
ret = EngineHelper.doHandshake(0, this.getSoTimeout());
11521152
} catch (SocketTimeoutException e) {
1153-
throw new IOException(e);
1153+
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
1154+
"got socket timeout in doHandshake()");
1155+
throw e;
11541156
}
11551157

11561158
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
@@ -1783,8 +1785,15 @@ public int read(byte[] b, int off, int len)
17831785
}
17841786

17851787
/* do handshake if not completed yet, handles synchronization */
1786-
if (socket.handshakeComplete == false) {
1787-
socket.startHandshake();
1788+
try {
1789+
/* do handshake if not completed yet, handles synchronization */
1790+
if (socket.handshakeComplete == false) {
1791+
socket.startHandshake();
1792+
}
1793+
} catch (SocketTimeoutException e) {
1794+
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
1795+
"got socket timeout in read()");
1796+
throw e;
17881797
}
17891798

17901799
if (b.length == 0 || len == 0) {
@@ -1901,9 +1910,15 @@ public void write(byte[] b, int off, int len) throws IOException {
19011910
}
19021911
}
19031912

1904-
/* do handshake if not completed yet, handles synchronization */
1905-
if (socket.handshakeComplete == false) {
1906-
socket.startHandshake();
1913+
try {
1914+
/* do handshake if not completed yet, handles synchronization */
1915+
if (socket.handshakeComplete == false) {
1916+
socket.startHandshake();
1917+
}
1918+
} catch (SocketTimeoutException e) {
1919+
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
1920+
"got socket timeout in write()");
1921+
throw e;
19071922
}
19081923

19091924
if (off < 0 || len < 0 || (off + len) > b.length) {

0 commit comments

Comments
 (0)