Skip to content

Conversation

Fangliding
Copy link
Member

今天刚好聊到了(

@patterniha

This comment was marked as outdated.

@patterniha
Copy link
Collaborator

patterniha commented Aug 14, 2025

I fix that. also because "return 0, err" may not correct on your code(we may send some data and then get error)

@Fangliding
Copy link
Member Author

能不能别乱动 这样不行 会出问题的

@patterniha
Copy link
Collaborator

Can you please stop moving around? It will cause problems.

although it has no practical effect,
but we should return total-success-send-bytes, err instead of return 0, err.

@Fangliding
Copy link
Member Author

Fangliding commented Aug 14, 2025

Can you please stop moving around? It will cause problems.

although it has no practical effect, but we should return total-success-send-bytes, err instead of return 0, err.

首先这不是我写的

第一个buffer.Write 那是写buffer 预处理 并没有东西写入底层连接
第二个WriteMultiBuffer 只给了一个err

@patterniha
Copy link
Collaborator

patterniha commented Aug 14, 2025

i talk about WriteMultiBuffer,

suppose after buffer.Write(b), buffer is equal to [b0, b1].

and in for loop WriteMultiBuffer(buf.MultiBuffer{b0}) return no error,
but WriteMultiBuffer(buf.MultiBuffer{b1}) return error.

so we should return b0.Len(), err instead of 0, err, even if it has no practical effect.

From annoying request
@patterniha
Copy link
Collaborator

thx.

@RPRX
Copy link
Member

RPRX commented Aug 15, 2025

我看改后似乎没啥问题,可以合了吗

@Fangliding
Copy link
Member Author

没啥问题 第一个commit就是好的 后面都无关紧要

@patterniha
Copy link
Collaborator

I think there is no problem after the modification. Can we merge it?

instead of number of bytes-sent, it always return 0 on error, it is OK now.

this PR, and #5006 fixes important issues and should be merged for next version.

then I release serverless-for-iran-anti-sanction.

I hope I don't find any new bugs while testing this time, It was really strange, as if someone had intentionally put some hidden bugs in Xray-core.

@RPRX
Copy link
Member

RPRX commented Aug 15, 2025

感觉你的 serverless-for-iran-anti-sanction 像我的 REALITY 文章、Switch、GUI 客户端、Rust core 等大饼一样遥遥无期

@patterniha
Copy link
Collaborator

patterniha commented Aug 15, 2025

I worked hard for it, I hope it will be well received this time.

At least it caused many bugs to be fixed in Xray-core :)

@Fangliding
Copy link
Member Author

没看出来 fix 了个啥important 绑在你那个pr催合并吗 还跑到这底下提一嘴你的玩意 喊得到大声。。

@RPRX
Copy link
Member

RPRX commented Aug 15, 2025

你们不要再打了啦 这样是打不死人的

怕非中文母语者不懂:玩梗,无恶意

@RPRX
Copy link
Member

RPRX commented Aug 15, 2025

我看得出来这个 PR 修了个 bug,但我想梳理清 read/write 间的关系,半年没写 XHTTP 竟一时看不懂了卧槽,当时没留太多注释

我算是明白了,原来注释主要是给半年后的自己看的,方便快速恢复记忆

@patterniha
Copy link
Collaborator

I have fulfilled all your requests without any expectations until now.

I have a goal and I fight for it. No harash word can upset me. at least I think @RPRX appreciated my efforts like a father, thank you very much again.

@RPRX
Copy link
Member

RPRX commented Aug 15, 2025

不需要为无意义的东西争吵,@patterniha 你那个 PR 我等下也看看吧

@patterniha
Copy link
Collaborator

patterniha commented Aug 15, 2025

No need to argue over meaningless things.@patternihaI'll take a look at your PR later.

i hope before release next-version.

@RPRX RPRX merged commit 6fc0a40 into main Aug 15, 2025
78 checks passed
@RPRX RPRX deleted the xhttp-packet-fix branch August 15, 2025 18:01
@RPRX RPRX changed the title 修复 XHTTP Packet write 丢失字节问题 XHTTP client: Fix edge-case issue for packet-up mode Aug 15, 2025
@RPRX
Copy link
Member

RPRX commented Aug 15, 2025

不过谈到 Write() 的 err,在 TCP 上返回 n 没有意义,因为都 err 了你也不能确定对端收了多少,也不敢重新 Write(),而是会放弃整条连接,所以其实返回 0 就够了(除非像 buffer 这些内部函数),我写的 encryption 就全返回 0,Read() 的 err 的话 n 还有点意义

@patterniha
Copy link
Collaborator

I also said it has no practical effect, I was just saying it in terms of programming logic: #5020 (comment)

Also, the main problem was something else, and this was just a side issue.

@RPRX
Copy link
Member

RPRX commented Aug 15, 2025

不过在原生 UDP 上 Write() err 时返回 n 更没啥意义,操作系统估计都只会返回 0,不同之处只在于 UDP 上敢重新 Write()

@patterniha
Copy link
Collaborator

But for debugging and correct-calculation-of-traffic-statistics we must return exact value.

maoxikun pushed a commit to maoxikun/Xray-core that referenced this pull request Aug 23, 2025
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.

3 participants