Skip to content

Span::CreateClientSpan是否有线程安全问题 #2315

@fausturs

Description

@fausturs

Describe the bug (描述bug)

https://github.com/apache/brpc/blob/master/src/brpc/span.cpp#L133
image

在代码这个位置,如果是在多个bthread中调用的Span::CreateClientSpan,而他们属于同一个Span的child span。此时他们对brpc::Span::_next_client是存在竞态的。
即便认为这个指针的赋值是原子的,似乎也可能导致内存泄漏。

这里是有什么特殊的设计避免了竞态吗?求解答

To Reproduce (复现方法)

Expected behavior (期望行为)

Versions (各种版本)
OS:
Compiler:
brpc:
protobuf:

Additional context/screenshots (更多上下文/截图)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugthe code does not work as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions