@@ -316,7 +316,7 @@ io_transport::io_transport(io_channel *ctx, std::shared_ptr<xxsocket> sock) : ct
316316 this ->id_ = ++s_object_id;
317317 this ->socket_ = sock;
318318 this ->kcp_ = ikcp_create (0 , this );
319- ikcp_nodelay (this ->kcp_ , 1 , MAX_WAIT_DURATION / 1000 , 2 , 1 );
319+ ikcp_nodelay (this ->kcp_ , 1 , 16 /* MAX_WAIT_DURATION / 1000*/ , 2 , 1 );
320320 ikcp_setoutput (this ->kcp_ , [](const char *buf, int len, ikcpcb *kcp, void *user) {
321321 io_transport *t = (io_transport *)user;
322322 return t->socket_ ->send_i (buf, len);
@@ -1048,22 +1048,13 @@ bool io_service::do_write(transport_ptr transport)
10481048{
10491049 std::lock_guard<std::recursive_mutex> lck (transport->kcp_mtx_ );
10501050
1051- long long wait_duration = MAX_WAIT_DURATION;
10521051 auto current = static_cast <IUINT32>(highp_clock () / 1000 );
10531052 ikcp_update (transport->kcp_ , current);
10541053
1055- if (ikcp_waitsnd (transport->kcp_ ) > 0 )
1056- {
1057- ikcp_flush (transport->kcp_ );
1058- if (ikcp_waitsnd (transport->kcp_ ) > 0 )
1059- wait_duration = 0 ;
1060- }
1061- else
1062- {
1063- auto expire_time = ikcp_check (transport->kcp_ , current);
1064- wait_duration = (long long )(expire_time - current) * 1000 ;
1065- }
1066-
1054+ auto expire_time = ikcp_check (transport->kcp_ , current);
1055+ long long wait_duration = (long long )(expire_time - current) * 1000 ;
1056+ if (wait_duration < 0 )
1057+ wait_duration = 0 ;
10671058 if (this ->kcp_wait_duration_ > wait_duration)
10681059 this ->kcp_wait_duration_ = wait_duration;
10691060
0 commit comments