Skip to content

Don't explicitly use files for mutex creation #3285

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

Conversation

marcstern
Copy link

We don't have to generate a temp name ourselves, it'll be done in apr_global_mutex_create().
We don't have to provide a filename, apr_global_mutex_create() generates one automatically.
Moreover, under Unix & Windows, the preferred mechanism won't use a file at all.
apr_file_mktemp() cannot be used as it creates the file (at least on FreeBSD).
Discussion in Apache mailing list: https://lists.apache.org/thread/ykb26kg4lgcqnldvxwd9p6hv16fy4z9l

Marc Stern added 2 commits October 3, 2024 12:35
We don't have to generate a temp name ourselves, it'll be done in apr_global_mutex_create().
We don't have to provide a filename, apr_global_mutex_create() generates one automatically.
Moreover, under Unix & Windows, the preferred mechanism won't use a file at all.
apr_file_mktemp() cannot be used as it creates the file (at least on FreeBSD).
Discussion in Apache mailing list: https://lists.apache.org/thread/ykb26kg4lgcqnldvxwd9p6hv16fy4z9l
We don't have to generate a temp name ourselves, it'll be done in apr_global_mutex_create().
We don't have to provide a filename, apr_global_mutex_create() generates one automatically.
Moreover, under Unix & Windows, the preferred mechanism won't use a file at all.
apr_file_mktemp() cannot be used as it creates the file (at least on FreeBSD).
Discussion in Apache mailing list: https://lists.apache.org/thread/ykb26kg4lgcqnldvxwd9p6hv16fy4z9l
@marcstern marcstern added Platform - Apache 2.x Related to ModSecurity version 2.x labels Oct 22, 2024
@airween
Copy link
Member

airween commented Nov 12, 2024

@marcstern ping.

Copy link

Copy link
Contributor

@fzipi fzipi left a comment

Choose a reason for hiding this comment

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

There is no better feeling than removing unneeded code.

apr_file_name_get(&filename, lock_name);

rc = apr_global_mutex_create(lock, filename, APR_LOCK_DEFAULT, mp);
apr_status_t rc = apr_global_mutex_create(lock, NULL, APR_LOCK_DEFAULT, mp);
if (rc != APR_SUCCESS) {
ap_log_perror(APLOG_MARK, APLOG_ERR, 0, mp, " ModSecurity: Could not create global mutex");
Copy link

@notroj notroj May 9, 2025

Choose a reason for hiding this comment

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

Passing rc as the apr_status_t argument rather than 0 would be better.

@airween
Copy link
Member

airween commented May 16, 2025

@notroj,

could you help us to review this PR and finish it (if it's necessary to do anything). Thanks!

@notroj
Copy link

notroj commented May 16, 2025

I can't push to this PR branch but I'd add:

notroj@aac61ae

and merge this

@airween
Copy link
Member

airween commented May 16, 2025

I can't push to this PR branch but I'd add:

notroj@aac61ae

and merge this

Ah, you're right - thanks. Probably we should open a new PR, based on this one and then odd yours.

I can do that later or feel free to do it.

Thanks anyway.

@notroj
Copy link

notroj commented May 16, 2025

Actually it looks like the first commits from this PR were merged already in 1121ef0 and the third one looks wrong. So I just made a new PR #3385 with the suggested change. I think this PR can be closed.

@airween
Copy link
Member

airween commented May 17, 2025

Seems like this PR is orphan, I mean the modifications are the part of an another PR (#3269) and already merged. Closing as the issue is solved and PR is abandoned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x Related to ModSecurity version 2.x Platform - Apache
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants