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

[core] Added devel support mutex DB #1676

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

ethouris
Copy link
Collaborator

@ethouris ethouris commented Nov 26, 2020

The mutex DB is added that traces every lock and unlock in a stack info form. It adds as an interface two functions:

  1. display_mutex_db() causes printing the mutex names in the order of locking that are currently applied, one per line, to stdout. This function is intended to be called from under the debugger.
  2. show_mutex_db() returns a single-line string with the list of currently locked mutexes. It's intended to be used in the logs, if needed.

@ethouris ethouris marked this pull request as draft November 26, 2020 16:34
CMakeLists.txt Outdated
Comment on lines 428 to 430
if (ENABLE_MUTEX_DB)
add_definitions(-DENABLE_MUTEX_DB=1)
endif()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe better to follow the SRT_DEBUG_* path? Like SRT_DEBUG_TSBPD_DRIFT.
SRT_DEBUG_MUTEXDB

@maxsharabayko
Copy link
Collaborator

  • Removed the passthrough synchro parameter - looks ok
  • Mutex DB - looks also ok. At least it does not impact the code readability. Consider changing the CMake option as suggested above.
  • Remove unlocking of CUDTSocket::m_ControlLock - looks reasonable from what I can tell.

All these changes are independent and should each go in a separate commit to be able to perform backtracking in the future in case of issues.

@ethouris
Copy link
Collaborator Author

First and third change is strictly interconnected. A version that contains only one of these changes would be deadlocking.

@codecov
Copy link

codecov bot commented Nov 27, 2020

Codecov Report

Merging #1676 (ee2a6f1) into master (c42bc13) will increase coverage by 0.21%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1676      +/-   ##
==========================================
+ Coverage   60.40%   60.61%   +0.21%     
==========================================
  Files          78       78              
  Lines       17440    17455      +15     
==========================================
+ Hits        10535    10581      +46     
+ Misses       6905     6874      -31     
Impacted Files Coverage Δ
srtcore/sync.h 76.00% <ø> (ø)
srtcore/api.cpp 48.74% <100.00%> (+0.42%) ⬆️
srtcore/core.cpp 55.12% <100.00%> (+0.41%) ⬆️
srtcore/epoll.cpp 62.68% <100.00%> (+0.11%) ⬆️
srtcore/logging.h 94.20% <100.00%> (+0.08%) ⬆️
srtcore/queue.cpp 82.00% <100.00%> (+0.30%) ⬆️
srtcore/sync_posix.cpp 89.70% <100.00%> (+0.23%) ⬆️
srtcore/buffer.h 77.77% <0.00%> (-4.58%) ⬇️
srtcore/congctl.cpp 82.05% <0.00%> (-1.54%) ⬇️
test/test_bonding.cpp 98.26% <0.00%> (-0.58%) ⬇️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c42bc13...130f7f3. Read the comment docs.

@ethouris ethouris changed the title [core] Fixed correct locks and lock ordering around m_ConnectionLock [core] Added devel support mutex DB Dec 2, 2020
@ethouris ethouris marked this pull request as ready for review December 2, 2020 11:08
@codecov-commenter
Copy link

Codecov Report

Merging #1676 (904e237) into master (5ec84d2) will decrease coverage by 0.52%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1676      +/-   ##
==========================================
- Coverage   61.45%   60.92%   -0.53%     
==========================================
  Files          80       80              
  Lines       17579    17591      +12     
==========================================
- Hits        10803    10718      -85     
- Misses       6776     6873      +97     
Impacted Files Coverage Δ
srtcore/sync.h 80.41% <ø> (ø)
srtcore/api.cpp 50.24% <100.00%> (+0.05%) ⬆️
srtcore/core.cpp 54.04% <100.00%> (-0.97%) ⬇️
srtcore/epoll.cpp 62.90% <100.00%> (+0.11%) ⬆️
srtcore/logging.h 94.20% <100.00%> (+0.08%) ⬆️
srtcore/queue.cpp 82.87% <100.00%> (-0.15%) ⬇️
srtcore/sync_posix.cpp 90.00% <100.00%> (+0.20%) ⬆️
srtcore/list.cpp 67.60% <0.00%> (-12.96%) ⬇️
srtcore/core.h 77.41% <0.00%> (-3.23%) ⬇️
srtcore/congctl.cpp 81.02% <0.00%> (-2.06%) ⬇️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5ec84d2...904e237. Read the comment docs.

@gou4shi1
Copy link
Contributor

gou4shi1 commented Mar 6, 2022

absl::Mutex has similar feature, can we just use it?

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.

4 participants