Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update ssthresh const name #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

acynothia
Copy link

IKCP_THRESH to IKCP_SSTHRESH, it seems better, like linux;

like free and delete. ikcp_release, assert seems not necessary;

IKCP_THRESH to IKCP_SSTHRESH, it seems better;

like free and delete; ikcp_release, assert seems not necessary;
@skywind3000
Copy link
Owner

assert 是有必要的,有些编译器某些编译选项下,assert会不起作用,那么后面的检测代码就可以工作了,而当它起作用的时候,我希望这里的 assert能够拦截错误,及早把调用者的错误暴露出来,而不是掩盖。

@acynothia
Copy link
Author

acynothia commented Dec 3, 2016

free 和 delete 对于 null 的行为都是不做处理.

assert 也只能判断 ikcpcb 为 null 的情况.

如果是多线程的同时 release, assert 无能为力.

如果是 release 之后没有把 ikcpcb 赋值为 null, 又再次 release. assert 同样无能为力.

我能想到的情景就是在一个意外的地方, 刚好意外的把 ikcpcb 赋值为 null, 这种情况实际上出错的位置并不是 release 这里. 这种情况崩溃在任何地方都是有可能.

哦, 还有一种就是 release 之后赋值为 null. 再次 release 的时候会触发. 但这种情况似乎和 free 和 delete 的行为不一致. 而且某些特殊情形, 是希望可以节约一个锁的 (eg.乐观锁).

@skywind3000
Copy link
Owner

断言并不能解决所有问题,但是能防止不少东西,尽可能提早暴露问题,不掩盖问题,我用了好几处断言,就是至少让他们起一部分作用。还有 kcpcb是一个状态机,一般是跑在一个线程里,output之后到别的线程是另外一回事,即便是操作系统(FreeBSD/Linux) tcp协议的单个状态对象,也只是放在一个cpu上维护,没有锁。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants