Skip to content

Commit d238258

Browse files
committed
Fixed bug in HTTP: interrupt receiving data
1 parent 0b86e20 commit d238258

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

projects/qt-creator/httpserverapp.qbs.user

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE QtCreatorProject>
3-
<!-- Written by QtCreator 4.3.1, 2017-07-28T00:45:22. -->
3+
<!-- Written by QtCreator 4.4.0, 2017-11-11T18:51:53. -->
44
<qtcreator>
55
<data>
66
<variable>EnvironmentId</variable>
@@ -111,6 +111,7 @@
111111
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Отладка</value>
112112
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
113113
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qbs.QbsBuildConfiguration</value>
114+
<value type="QString" key="Qbs.configName">qtc_Desktop_d1177e0c-debug</value>
114115
</valuemap>
115116
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
116117
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/media/projects/httpserverapp/build</value>
@@ -157,6 +158,7 @@
157158
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Выпуск</value>
158159
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
159160
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qbs.QbsBuildConfiguration</value>
161+
<value type="QString" key="Qbs.configName">qtc_Desktop_d1177e0c-release</value>
160162
</valuemap>
161163
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
162164
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">

src/socket/AdapterTls.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,16 @@ namespace Socket
112112
// ::gnutls_record_set_timeout(this->session, static_cast<const unsigned int>(timeout.count() ) );
113113

114114
Socket sock(this->get_handle() );
115-
sock.nonblock_recv_sync();
116115

117-
return ::gnutls_record_recv(this->session, buf, length);
116+
long result;
117+
118+
do {
119+
sock.nonblock_recv_sync();
120+
result = ::gnutls_record_recv(this->session, buf, length);
121+
}
122+
while (result == GNUTLS_E_AGAIN || result == GNUTLS_E_INTERRUPTED);
123+
124+
return result;
118125
}
119126

120127
long AdapterTls::nonblock_send(const void *buf, const size_t length, const std::chrono::milliseconds &timeout) const noexcept {

src/socket/Socket.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ namespace Socket
294294
#ifdef WIN32
295295
WSAPOLLFD event = {
296296
this->socket_handle,
297-
POLLRDNORM | POLLRDBAND,
297+
POLLIN,
298298
0
299299
};
300300

@@ -344,12 +344,12 @@ namespace Socket
344344
#ifdef WIN32
345345
WSAPOLLFD event = {
346346
socket_handle,
347-
POLLWRNORM,
347+
POLLOUT,
348348
0
349349
};
350350

351351
while (total < length) {
352-
if (1 == ::WSAPoll(&event, 1, static_cast<::INT>(timeout.count() ) ) && event.revents & POLLWRNORM) {
352+
if (1 == ::WSAPoll(&event, 1, static_cast<::INT>(timeout.count() ) ) && event.revents & POLLOUT) {
353353
const long send_size = ::send(socket_handle, reinterpret_cast<const char *>(data) + total, static_cast<const int>(length - total), 0);
354354

355355
if (send_size < 0) {
@@ -402,7 +402,7 @@ namespace Socket
402402
#ifdef WIN32
403403
WSAPOLLFD event = {
404404
this->socket_handle,
405-
POLLWRNORM,
405+
POLLOUT,
406406
0
407407
};
408408

0 commit comments

Comments
 (0)