diff options
author | Martin Willi <martin@revosec.ch> | 2013-01-14 15:32:12 +0100 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2013-01-15 17:43:05 +0100 |
commit | c43e8fdec400626f3d153527fcfaba9bf33cfe4f (patch) | |
tree | e367b791643b6616f0ea8c3d109604cbd42f439b | |
parent | 9191e5e11ad21409df782326ad25f6c5317f5a4d (diff) | |
download | strongswan-c43e8fdec400626f3d153527fcfaba9bf33cfe4f.tar.bz2 strongswan-c43e8fdec400626f3d153527fcfaba9bf33cfe4f.tar.xz |
Block TLS read when sending data, but have to wait for the handshake data first
-rw-r--r-- | src/libtls/tls_socket.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/libtls/tls_socket.c b/src/libtls/tls_socket.c index 131bada96..db12d1d8b 100644 --- a/src/libtls/tls_socket.c +++ b/src/libtls/tls_socket.c @@ -111,7 +111,6 @@ METHOD(tls_application_t, process, status_t, { return FAILED; } - memcpy(this->in.ptr + this->in_done, data.ptr, data.len); this->in_done += data.len; } @@ -145,7 +144,7 @@ static bool exchange(private_tls_socket_t *this, bool wr, bool block) { char buf[CRYPTO_BUF_SIZE], *pos; ssize_t len, out; - int round = 0; + int round = 0, flags; for (round = 0; TRUE; round++) { @@ -191,8 +190,16 @@ static bool exchange(private_tls_socket_t *this, bool wr, bool block) return TRUE; } } - len = recv(this->fd, buf, sizeof(buf), - !block || this->app.in_done || round ? MSG_DONTWAIT : 0); + + flags = 0; + if (this->app.out_done == this->app.out.len) + { + if (!block || this->app.in_done) + { + flags |= MSG_DONTWAIT; + } + } + len = recv(this->fd, buf, sizeof(buf), flags); if (len < 0) { if (errno == EAGAIN || errno == EWOULDBLOCK) |