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

refactor: Make tox mutex non-recursive. #2652

Merged
merged 1 commit into from
Feb 8, 2024

Conversation

iphydf
Copy link
Member

@iphydf iphydf commented Feb 7, 2024

Instead, unlock it before entering client callback code.


This change is Reviewable

@iphydf iphydf added this to the v0.2.19 milestone Feb 7, 2024
@iphydf iphydf marked this pull request as ready for review February 7, 2024 22:51
Copy link

codecov bot commented Feb 7, 2024

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (aacff73) 73.61% compared to head (5c93231) 73.66%.

Files Patch % Lines
toxcore/tox.c 96.29% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2652      +/-   ##
==========================================
+ Coverage   73.61%   73.66%   +0.05%     
==========================================
  Files         148      148              
  Lines       30404    30481      +77     
==========================================
+ Hits        22382    22455      +73     
- Misses       8022     8026       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@robinlinden robinlinden left a comment

Choose a reason for hiding this comment

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

Guess we're missing a test that sets the conference title and a test that actually uses the experimental thread safety option?

Copy link
Member

@nurupo nurupo left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 1 change requests, 1 of 1 approvals obtained (waiting on @iphydf)


toxcore/tox.c line 89 at r1 (raw file):

    if (tox->log_callback != nullptr) {
        tox->log_callback(tox, (Tox_Log_Level)level, file, line, func, message, userdata);

Is locking not needed here?

Copy link
Member Author

@iphydf iphydf left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 1 change requests, 1 of 1 approvals obtained (waiting on @nurupo)


toxcore/tox.c line 89 at r1 (raw file):

Previously, nurupo wrote…

Is locking not needed here?

More accurately, unlocking is not needed here. The log callback happens in really any kind of situation, and client could should never call tox functions inside the log callback.

@nurupo
Copy link
Member

nurupo commented Feb 8, 2024

toxcore/tox.c line 89 at r1 (raw file):

Previously, iphydf wrote…

More accurately, unlocking is not needed here. The log callback happens in really any kind of situation, and client could should never call tox functions inside the log callback.

Is this documented somewhere? I don't see a mentioning of this where the callback is defined in tox.h.

Also, for what purpose does the callback pass Tox *tox to the user if it's not to be used? (I guess to use of operator== on tox against some other Tox instance might be a valid use-case?)

Copy link
Member Author

@iphydf iphydf left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 1 change requests, 1 of 1 approvals obtained (waiting on @nurupo)


toxcore/tox.c line 89 at r1 (raw file):

Previously, nurupo wrote…

Is this documented somewhere? I don't see a mentioning of this where the callback is defined in tox.h.

Also, for what purpose does the callback pass Tox *tox to the user if it's not to be used? (I guess to use of operator== on tox against some other Tox instance might be a valid use-case?)

Passing Tox to log callbacks was a mistake. Added a comment to the log_callback docs.

Instead, unlock it before entering client callback code.
@nurupo
Copy link
Member

nurupo commented Feb 8, 2024

toxcore/tox.c line 89 at r1 (raw file):

Previously, iphydf wrote…

Passing Tox to log callbacks was a mistake. Added a comment to the log_callback docs.

Do we want to remove Tox *tox from tox_log_cb when we break the API in the future? If so, might be worth noting this somewhere so that we don't forget, e.g. create an issue mentioning it or add a note to tox_log_cb tox.h for ourselves.

Copy link
Member Author

@iphydf iphydf left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 1 change requests, 1 of 1 approvals obtained (waiting on @nurupo)


toxcore/tox.c line 89 at r1 (raw file):

Previously, nurupo wrote…

Do we want to remove Tox *tox from tox_log_cb when we break the API in the future? If so, might be worth noting this somewhere so that we don't forget, e.g. create an issue mentioning it or add a note to tox_log_cb tox.h for ourselves.

Done.

Copy link
Member

@nurupo nurupo left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r1, 1 of 1 files at r3, 1 of 1 files at r4, all commit messages.
Reviewable status: :shipit: complete! 2 of 1 approvals obtained

@iphydf iphydf merged commit 5c93231 into TokTok:master Feb 8, 2024
59 of 60 checks passed
@iphydf iphydf deleted the non-recursive-mutex branch February 8, 2024 00:52
This pull request was closed.
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