mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-19 04:49:25 +08:00
Cygwin: AF_UNIX: Add state_lock to guard manipulating shared state info
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
60ca1c1359
commit
848d5b70db
@ -887,6 +887,7 @@ class af_unix_shmem_t
|
||||
deadlocks. */
|
||||
af_unix_spinlock_t _bind_lock;
|
||||
af_unix_spinlock_t _conn_lock;
|
||||
af_unix_spinlock_t _state_lock;
|
||||
af_unix_spinlock_t _io_lock;
|
||||
LONG _connection_state; /* conn_state */
|
||||
LONG _binding_state; /* bind_state */
|
||||
@ -899,6 +900,8 @@ class af_unix_shmem_t
|
||||
void bind_unlock () { _bind_lock.unlock (); }
|
||||
void conn_lock () { _conn_lock.lock (); }
|
||||
void conn_unlock () { _conn_lock.unlock (); }
|
||||
void state_lock () { _state_lock.lock (); }
|
||||
void state_unlock () { _state_lock.unlock (); }
|
||||
void io_lock () { _io_lock.lock (); }
|
||||
void io_unlock () { _io_lock.unlock (); }
|
||||
|
||||
@ -943,6 +946,8 @@ class fhandler_socket_unix : public fhandler_socket
|
||||
void bind_unlock () { shmem->bind_unlock (); }
|
||||
void conn_lock () { shmem->conn_lock (); }
|
||||
void conn_unlock () { shmem->conn_unlock (); }
|
||||
void state_lock () { shmem->state_lock (); }
|
||||
void state_unlock () { shmem->state_unlock (); }
|
||||
void io_lock () { shmem->io_lock (); }
|
||||
void io_unlock () { shmem->io_unlock (); }
|
||||
conn_state connect_state (conn_state val)
|
||||
|
@ -1225,8 +1225,10 @@ out:
|
||||
if (param)
|
||||
cfree (param);
|
||||
conn_lock ();
|
||||
state_lock ();
|
||||
so_error (error);
|
||||
connect_state (error ? connect_failed : connected);
|
||||
state_unlock ();
|
||||
conn_unlock ();
|
||||
return error;
|
||||
}
|
||||
@ -1688,12 +1690,14 @@ fhandler_socket_unix::getpeereid (pid_t *pid, uid_t *euid, gid_t *egid)
|
||||
{
|
||||
__try
|
||||
{
|
||||
state_lock ();
|
||||
if (pid)
|
||||
*pid = peer_cred.pid;
|
||||
if (euid)
|
||||
*euid = peer_cred.uid;
|
||||
if (egid)
|
||||
*egid = peer_cred.gid;
|
||||
state_unlock ();
|
||||
ret = 0;
|
||||
}
|
||||
__except (EFAULT) {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user