You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@apr.apache.org by bu...@apache.org on 2018/01/02 08:22:43 UTC
[Bug 61953] New: cross-process APR_LOCK_FLOCK is released during
cleanup if file already exists
https://bz.apache.org/bugzilla/show_bug.cgi?id=61953
Bug ID: 61953
Summary: cross-process APR_LOCK_FLOCK is released during
cleanup if file already exists
Product: APR
Version: HEAD
Hardware: PC
OS: Linux
Status: NEW
Severity: major
Priority: P2
Component: APR
Assignee: bugs@apr.apache.org
Reporter: och@m.one-crazy-human.net
Target Milestone: ---
The processes have the same working directory and fname is a file name, not a
full path, however, the bug is also present with a common full path.
On a call to apr_proc_mutex_create with the same fname, a sample process will
create the file then acquire the lock, if another process calls with the same
fname, it will fail to create the APR_LOCK_FLOCK mutex, and during cleanup
unlink the file with filename fname, making future calls from this one process
or any other process successful (releasing the lock) and corrupting it for its
owner.
I think you should verify if the lockfile is busy before deleting it
See comment within snippet
//file: locks/unix/proc_mutex.c line: 1143
static apr_status_t proc_mutex_flock_cleanup(void *mutex_)
{
apr_status_t status = APR_SUCCESS;
apr_proc_mutex_t *mutex=mutex_;
if (mutex->curr_locked == 1) {
status = proc_mutex_flock_release(mutex);
if (status != APR_SUCCESS)
return status;
}
if (mutex->interproc) { /* if it was opened properly */
status = apr_file_close(mutex->interproc);
}
if (!mutex->interproc_closing
&& mutex->os.crossproc != -1
&& close(mutex->os.crossproc) == -1
&& status == APR_SUCCESS) {
status = errno;
}
// call flock with exclusive flag on mutex->fname,
// if successful, unlink the file (recovering from corrupted lock or deleting
an unrelated existing file), and then maybe we could try again on creating the
mutex?
// else don't unlink the file, and throw error signaling the lockfile is busy
to the caller
if (mutex->fname) {
unlink(mutex->fname);
}
return status;
}
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org
[Bug 61953] cross-process APR_LOCK_FLOCK is released during cleanup
if file already exists
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61953
och@m.one-crazy-human.net changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org
[Bug 61953] cross-process APR_LOCK_FLOCK is released during cleanup
if file already exists
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61953
--- Comment #1 from och@m.one-crazy-human.net ---
Created attachment 35635
--> https://bz.apache.org/bugzilla/attachment.cgi?id=35635&action=edit
patchfile for proc_mutex.c in release 1.6.3
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org
[Bug 61953] cross-process APR_LOCK_FLOCK is released during cleanup
if file already exists
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61953
--- Comment #2 from och@m.one-crazy-human.net ---
After further research, the problem comes from using APR_FOPEN_EXCL flag when
opening the lock file, stripping the flag makes things work correctly!
Attached patchfile.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org
[Bug 61953] cross-process APR_LOCK_FLOCK is released during cleanup
if file already exists
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61953
och@m.one-crazy-human.net changed:
What |Removed |Added
----------------------------------------------------------------------------
Version|HEAD |1.6.3
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org
[Bug 61953] cross-process APR_LOCK_FLOCK is released during cleanup
if file already exists
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61953
och@m.one-crazy-human.net changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |och@m.one-crazy-human.net
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org