Skip to content

refactor: Make tox mutex non-recursive.#2652

Merged
iphydf merged 1 commit into
TokTok:masterfrom
iphydf:non-recursive-mutex
Feb 8, 2024
Merged

refactor: Make tox mutex non-recursive.#2652
iphydf merged 1 commit into
TokTok:masterfrom
iphydf:non-recursive-mutex

Conversation

@iphydf

@iphydf iphydf commented Feb 7, 2024

Copy link
Copy Markdown
Member

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
@codecov

codecov Bot commented Feb 7, 2024

Copy link
Copy Markdown

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.

@robinlinden robinlinden left a comment

Copy link
Copy Markdown

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?

@nurupo nurupo left a comment

Copy link
Copy Markdown
Member

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?

@iphydf iphydf left a comment

Copy link
Copy Markdown
Member Author

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

nurupo commented Feb 8, 2024

Copy link
Copy Markdown
Member

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?)

@iphydf iphydf force-pushed the non-recursive-mutex branch from a18412a to 5daedb8 Compare February 8, 2024 00:33

@iphydf iphydf left a comment

Copy link
Copy Markdown
Member Author

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.
@iphydf iphydf force-pushed the non-recursive-mutex branch from 5daedb8 to 5c93231 Compare February 8, 2024 00:37
@nurupo

nurupo commented Feb 8, 2024

Copy link
Copy Markdown
Member

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.

@iphydf iphydf left a comment

Copy link
Copy Markdown
Member Author

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.

@nurupo nurupo left a comment

Copy link
Copy Markdown
Member

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
@iphydf iphydf deleted the non-recursive-mutex branch February 8, 2024 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants