This commit is contained in:
Chinsyo 2020-11-05 19:12:51 +08:00
parent d6829263fe
commit c5a17fb8b5

13
ikcp.c
View File

@ -35,8 +35,8 @@ const IUINT32 IKCP_ASK_TELL = 2; // need to send IKCP_CMD_WINS
const IUINT32 IKCP_WND_SND = 32; const IUINT32 IKCP_WND_SND = 32;
const IUINT32 IKCP_WND_RCV = 128; // must >= max fragment size const IUINT32 IKCP_WND_RCV = 128; // must >= max fragment size
const IUINT32 IKCP_MTU_DEF = 1400; const IUINT32 IKCP_MTU_DEF = 1400;
const IUINT32 IKCP_ACK_FAST = 3; const IUINT32 IKCP_ACK_FAST = 3;
const IUINT32 IKCP_INTERVAL = 100; const IUINT32 IKCP_INTERVAL = 100;
const IUINT32 IKCP_OVERHEAD = 24; const IUINT32 IKCP_OVERHEAD = 24;
const IUINT32 IKCP_DEADLINK = 20; const IUINT32 IKCP_DEADLINK = 20;
const IUINT32 IKCP_THRESH_INIT = 2; const IUINT32 IKCP_THRESH_INIT = 2;
@ -296,7 +296,7 @@ ikcpcb* ikcp_create(IUINT32 conv, void *user)
//--------------------------------------------------------------------- //---------------------------------------------------------------------
// release a new kcpcb // release a kcpcb
//--------------------------------------------------------------------- //---------------------------------------------------------------------
void ikcp_release(ikcpcb *kcp) void ikcp_release(ikcpcb *kcp)
{ {
@ -718,7 +718,7 @@ void ikcp_parse_data(ikcpcb *kcp, IKCPSEG *newseg)
#endif #endif
// move available data from rcv_buf -> rcv_queue // move available data from rcv_buf -> rcv_queue
while (! iqueue_is_empty(&kcp->rcv_buf)) { while (!iqueue_is_empty(&kcp->rcv_buf)) {
IKCPSEG *seg = iqueue_entry(kcp->rcv_buf.next, IKCPSEG, node); IKCPSEG *seg = iqueue_entry(kcp->rcv_buf.next, IKCPSEG, node);
if (seg->sn == kcp->rcv_nxt && kcp->nrcv_que < kcp->rcv_wnd) { if (seg->sn == kcp->rcv_nxt && kcp->nrcv_que < kcp->rcv_wnd) {
iqueue_del(&seg->node); iqueue_del(&seg->node);
@ -1175,7 +1175,7 @@ void ikcp_update(ikcpcb *kcp, IUINT32 current)
// Determine when should you invoke ikcp_update: // Determine when should you invoke ikcp_update:
// returns when you should invoke ikcp_update in millisec, if there // returns when you should invoke ikcp_update in millisec, if there
// is no ikcp_input/_send calling. you can call ikcp_update in that // is no ikcp_input/_send calling. you can call ikcp_update in that
// time, instead of call update repeatly. // time, instead of call update repeatedly.
// Important to reduce unnacessary ikcp_update invoking. use it to // Important to reduce unnacessary ikcp_update invoking. use it to
// schedule ikcp_update (eg. implementing an epoll-like mechanism, // schedule ikcp_update (eg. implementing an epoll-like mechanism,
// or optimize ikcp_update when handling massive kcp connections) // or optimize ikcp_update when handling massive kcp connections)
@ -1218,8 +1218,6 @@ IUINT32 ikcp_check(const ikcpcb *kcp, IUINT32 current)
return current + minimal; return current + minimal;
} }
int ikcp_setmtu(ikcpcb *kcp, int mtu) int ikcp_setmtu(ikcpcb *kcp, int mtu)
{ {
char *buffer; char *buffer;
@ -1268,7 +1266,6 @@ int ikcp_nodelay(ikcpcb *kcp, int nodelay, int interval, int resend, int nc)
return 0; return 0;
} }
int ikcp_wndsize(ikcpcb *kcp, int sndwnd, int rcvwnd) int ikcp_wndsize(ikcpcb *kcp, int sndwnd, int rcvwnd)
{ {
if (kcp) { if (kcp) {