File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -76,8 +76,6 @@ namespace Socket
7676 record_size = length - total;
7777 }
7878
79- // const long send_size = ::gnutls_record_send(this->session, reinterpret_cast<const uint8_t *>(buf) + total, record_size);
80-
8179 long send_size = 0 ;
8280
8381 do {
@@ -110,17 +108,18 @@ namespace Socket
110108
111109 long AdapterTls::nonblock_recv (void *buf, const size_t length, const std::chrono::milliseconds &timeout) const noexcept
112110 {
113- // ::gnutls_record_set_timeout(this->session, static_cast<const unsigned int>(timeout.count() ) );
114-
115111 Socket sock (this ->get_handle () );
116112
117113 long result;
118114
119115 do {
120- sock.nonblock_recv_sync (timeout);
116+ if (sock.nonblock_recv_sync (timeout) == false ) {
117+ break ;
118+ }
119+
121120 result = ::gnutls_record_recv (this ->session , buf, length);
122121 }
123- while (result == GNUTLS_E_INTERRUPTED);
122+ while (GNUTLS_E_AGAIN == result || GNUTLS_E_INTERRUPTED == result );
124123
125124 return result;
126125 }
Original file line number Diff line number Diff line change @@ -289,7 +289,7 @@ namespace Socket
289289 return recv_len;
290290 }
291291
292- void Socket::nonblock_recv_sync (const std::chrono::milliseconds &timeout) const noexcept
292+ bool 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 , timeout.count() );
301+ return ::WSAPoll (&event, 1 , timeout.count () ) == 1 ;
302302 #elif POSIX
303303 struct ::pollfd event = {
304304 this ->socket_handle ,
305305 POLLIN,
306306 0
307307 };
308308
309- ::poll (&event, 1 , timeout.count() );
309+ return ::poll (&event, 1 , timeout.count () ) == 1 ;
310310 #else
311311 #error "Undefine platform"
312312 #endif
Original file line number Diff line number Diff 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 std::chrono::milliseconds &timeout) const noexcept ;
54+ bool 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 ;
You can’t perform that action at this time.
0 commit comments