修复sockaddr比较结果不符合预期导致kcp无法正常收包问题#749
Merged
ithewei merged 1 commit intoithewei:masterfrom Jul 8, 2025
lfeng1420:master
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
使用memcmp直接比较两个sockaddr可能出现结果不符合预期的情况,如下两个sockaddr结构:


其协议、ip和端口是相同的,但sin_zero填充部分不一致,导致memcmp返回值不符合预期。
由于结果不正确,导致
rudp_get函数意外创建了新的rudp_entry_t,kcp因此也受到影响,无法正常收包。hio_read_kcp->hio_get_kcp->hio_get_rudp->rudp_get