This commit is contained in:
Chinsyo 2024-07-29 23:54:26 +08:00 committed by GitHub
commit e88fc1b5ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

51
ikcp.c
View File

@ -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)
{ {
@ -547,6 +547,28 @@ int ikcp_send(ikcpcb *kcp, const char *buffer, int len)
//--------------------------------------------------------------------- //---------------------------------------------------------------------
// parse ack // parse ack
//--------------------------------------------------------------------- //---------------------------------------------------------------------
static void ikcp_parse_ack(ikcpcb *kcp, IUINT32 sn)
{
struct IQUEUEHEAD *p, *next;
if (_itimediff(sn, kcp->snd_una) < 0 || _itimediff(sn, kcp->snd_nxt) >= 0)
return;
for (p = kcp->snd_buf.next; p != &kcp->snd_buf; p = next) {
IKCPSEG *seg = iqueue_entry(p, IKCPSEG, node);
next = p->next;
if (sn == seg->sn) {
iqueue_del(p);
ikcp_segment_delete(kcp, seg);
kcp->nsnd_buf--;
break;
}
if (_itimediff(sn, seg->sn) < 0) {
break;
}
}
}
static void ikcp_update_ack(ikcpcb *kcp, IINT32 rtt) static void ikcp_update_ack(ikcpcb *kcp, IINT32 rtt)
{ {
IINT32 rto = 0; IINT32 rto = 0;
@ -575,28 +597,6 @@ static void ikcp_shrink_buf(ikcpcb *kcp)
} }
} }
static void ikcp_parse_ack(ikcpcb *kcp, IUINT32 sn)
{
struct IQUEUEHEAD *p, *next;
if (_itimediff(sn, kcp->snd_una) < 0 || _itimediff(sn, kcp->snd_nxt) >= 0)
return;
for (p = kcp->snd_buf.next; p != &kcp->snd_buf; p = next) {
IKCPSEG *seg = iqueue_entry(p, IKCPSEG, node);
next = p->next;
if (sn == seg->sn) {
iqueue_del(p);
ikcp_segment_delete(kcp, seg);
kcp->nsnd_buf--;
break;
}
if (_itimediff(sn, seg->sn) < 0) {
break;
}
}
}
static void ikcp_parse_una(ikcpcb *kcp, IUINT32 una) static void ikcp_parse_una(ikcpcb *kcp, IUINT32 una)
{ {
struct IQUEUEHEAD *p, *next; struct IQUEUEHEAD *p, *next;
@ -1182,7 +1182,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)
@ -1225,8 +1225,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;
@ -1275,7 +1273,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) {