* dcrt0.cc (child_info_spawn::handle_spawn): Call fixup_lockf_after_exec
with additional argument to specify if the process has been execed or spawned. * flock.cc (fixup_lockf_after_exec): Take bool parameter to handle exec and spawn differently. In case of spawn, just give up POSIX locks in favor of the still running parent. Add comments to explain.
This commit is contained in:
parent
2f850d402e
commit
127cfd4f5a
|
@ -1,3 +1,12 @@
|
||||||
|
2014-02-10 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* dcrt0.cc (child_info_spawn::handle_spawn): Call fixup_lockf_after_exec
|
||||||
|
with additional argument to specify if the process has been execed
|
||||||
|
or spawned.
|
||||||
|
* flock.cc (fixup_lockf_after_exec): Take bool parameter to handle
|
||||||
|
exec and spawn differently. In case of spawn, just give up POSIX
|
||||||
|
locks in favor of the still running parent. Add comments to explain.
|
||||||
|
|
||||||
2014-02-09 Christopher Faylor <me.cygwin2014@cgf.cx>
|
2014-02-09 Christopher Faylor <me.cygwin2014@cgf.cx>
|
||||||
|
|
||||||
* environ.cc (strbrk): Properly deal with environment variable sans
|
* environ.cc (strbrk): Properly deal with environment variable sans
|
||||||
|
|
|
@ -655,7 +655,7 @@ child_info_spawn::get_parent_handle ()
|
||||||
void
|
void
|
||||||
child_info_spawn::handle_spawn ()
|
child_info_spawn::handle_spawn ()
|
||||||
{
|
{
|
||||||
extern void fixup_lockf_after_exec ();
|
extern void fixup_lockf_after_exec (bool);
|
||||||
HANDLE h;
|
HANDLE h;
|
||||||
if (!dynamically_loaded || get_parent_handle ())
|
if (!dynamically_loaded || get_parent_handle ())
|
||||||
{
|
{
|
||||||
|
@ -706,7 +706,7 @@ child_info_spawn::handle_spawn ()
|
||||||
}
|
}
|
||||||
|
|
||||||
signal_fixup_after_exec ();
|
signal_fixup_after_exec ();
|
||||||
fixup_lockf_after_exec ();
|
fixup_lockf_after_exec (type == _CH_EXEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Retrieve and store system directory for later use. Note that the
|
/* Retrieve and store system directory for later use. Note that the
|
||||||
|
|
|
@ -439,7 +439,7 @@ fhandler_base::del_my_locks (del_lock_called_from from)
|
||||||
wait on. If the node has been abandoned due to close_on_exec on the
|
wait on. If the node has been abandoned due to close_on_exec on the
|
||||||
referencing fhandlers, remove the inode entirely. */
|
referencing fhandlers, remove the inode entirely. */
|
||||||
void
|
void
|
||||||
fixup_lockf_after_exec ()
|
fixup_lockf_after_exec (bool exec)
|
||||||
{
|
{
|
||||||
inode_t *node, *next_node;
|
inode_t *node, *next_node;
|
||||||
|
|
||||||
|
@ -464,14 +464,30 @@ fixup_lockf_after_exec ()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
node->LOCK ();
|
node->LOCK ();
|
||||||
for (lockf_t *lock = node->i_lockf; lock; lock = lock->lf_next)
|
lockf_t *lock, *n_lock;
|
||||||
|
lockf_t **prev = &node->i_lockf;
|
||||||
|
for (lock = *prev; lock && (n_lock = lock->lf_next, 1); lock = n_lock)
|
||||||
if (lock->lf_flags & F_POSIX)
|
if (lock->lf_flags & F_POSIX)
|
||||||
{
|
{
|
||||||
|
if (exec)
|
||||||
|
{
|
||||||
|
/* The parent called exec. The lock is passed to the child.
|
||||||
|
Recreate lock object with changed ownership. */
|
||||||
lock->del_lock_obj (NULL);
|
lock->del_lock_obj (NULL);
|
||||||
lock->lf_wid = myself->dwProcessId;
|
lock->lf_wid = myself->dwProcessId;
|
||||||
lock->lf_ver = 0;
|
lock->lf_ver = 0;
|
||||||
lock->create_lock_obj ();
|
lock->create_lock_obj ();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* The parent called spawn. The parent continues to hold
|
||||||
|
the POSIX lock, ownership is not passed to the child.
|
||||||
|
Give up the lock in the child. */
|
||||||
|
*prev = n_lock;
|
||||||
|
lock->close_lock_obj ();
|
||||||
|
delete lock;
|
||||||
|
}
|
||||||
|
}
|
||||||
node->UNLOCK ();
|
node->UNLOCK ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue