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

fix_share_tls_block #1156

Merged
merged 2 commits into from
Jul 21, 2020
Merged

fix_share_tls_block #1156

merged 2 commits into from
Jul 21, 2020

Conversation

zyearn
Copy link
Member

@zyearn zyearn commented Jul 8, 2020

No description provided.

new_block = b;
while (new_block && new_block->full()) {
IOBuf::Block* const saved_next = new_block->portal_next;
new_block->dec_ref();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里为啥引用减1,它对应的inc_ref是哪里了?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Block的构造函数会把ref初始化成1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

出现new_block->full的场景是什么?可以补充UT么?

Copy link
Member Author

@zyearn zyearn Jul 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一个可能的场景是:
1)不断调IOBuf::push_back(c),它的实现是拿到tls head block,然后在下一个位置将c写进入,假设当前的c写入后使得该block变满
2)某处调用release_tls_block或者release_tls_block_chain,把某个block b2还给tls,此时tls的数据是b2 -> b(之前那块满的)
3)继续调IOBuf::push_back,写到了b2后面,b2满后,会拿b2的next block返回,此时没有判断full,就把b返回了
4)IOBuf::push_back往一个满的block中写入数据

对应的UT加好了,这个UT在原来的代码上跑会挂

@jamesge jamesge merged commit 5d0512d into apache:master Jul 21, 2020
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