Skip to content

Commit 51f8d20

Browse files
committed
Fixed interruption of data reception over HTTPS
1 parent e68d77f commit 51f8d20

File tree

7 files changed

+11
-258
lines changed

7 files changed

+11
-258
lines changed

projects/qt-creator/httpserverapp.qbs.user

Lines changed: 0 additions & 248 deletions
This file was deleted.

src/socket/AdapterTls.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ namespace Socket
8282

8383
do {
8484
sock.nonblock_send_sync();
85+
send_size = ::gnutls_record_send(this->session, reinterpret_cast<const uint8_t *>(buf) + total, record_size);
8586
}
86-
while (GNUTLS_E_AGAIN == (send_size = ::gnutls_record_send(this->session, reinterpret_cast<const uint8_t *>(buf) + total, record_size) ) );
87+
while (GNUTLS_E_AGAIN == send_size);
8788

8889
if (send_size < 0) {
8990
return send_size;
@@ -116,10 +117,10 @@ namespace Socket
116117
long result;
117118

118119
do {
119-
sock.nonblock_recv_sync();
120+
sock.nonblock_recv_sync(timeout);
120121
result = ::gnutls_record_recv(this->session, buf, length);
121122
}
122-
while (result == GNUTLS_E_AGAIN || result == GNUTLS_E_INTERRUPTED);
123+
while (result == GNUTLS_E_INTERRUPTED);
123124

124125
return result;
125126
}

src/socket/List.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
22
#include "List.h"
33

44
#ifdef POSIX

src/socket/List.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#pragma once
1+
#pragma once
22

33
#include "Socket.h"
44

src/socket/Socket.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ namespace Socket
289289
return recv_len;
290290
}
291291

292-
void Socket::nonblock_recv_sync() const noexcept
292+
void Socket::nonblock_recv_sync(const std::chrono::milliseconds &timeout) const noexcept
293293
{
294294
#ifdef WIN32
295295
WSAPOLLFD event = {
@@ -298,15 +298,15 @@ namespace Socket
298298
0
299299
};
300300

301-
::WSAPoll(&event, 1, ~0);
301+
::WSAPoll(&event, 1, timeout.count() );
302302
#elif POSIX
303303
struct ::pollfd event = {
304304
this->socket_handle,
305305
POLLIN,
306306
0
307307
};
308308

309-
::poll(&event, 1, ~0);
309+
::poll(&event, 1, timeout.count() );
310310
#else
311311
#error "Undefine platform"
312312
#endif

src/socket/Socket.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace Socket
5151
long nonblock_recv(std::vector<std::string::value_type> &buf, const std::chrono::milliseconds &timeout) const noexcept;
5252
long nonblock_recv(void *buf, const size_t length, const std::chrono::milliseconds &timeout) const noexcept;
5353

54-
void nonblock_recv_sync() const noexcept;
54+
void nonblock_recv_sync(const std::chrono::milliseconds &timeout) const noexcept;
5555

5656
long send(const std::string &buf) const noexcept;
5757
long send(const void *buf, const size_t length) const noexcept;

src/utils/Event.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace Utils
3232
if (this->signaled.load() == false) {
3333
std::unique_lock<std::mutex> lck(this->mtx);
3434

35-
is_timeout = false == this->cv.wait_for(lck, ms, [this] { return this->notifed(); } );
35+
is_timeout = this->cv.wait_for(lck, ms, [this] { return this->notifed(); } ) == false;
3636
}
3737

3838
if (false == this->manually) {

0 commit comments

Comments
 (0)