diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2007-11-05 18:25:55 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2007-11-05 18:25:55 +0300 |
commit | 5c8426d50e255a317b9ab4586776f238ad2154ae (patch) | |
tree | 82bdfc5b225f0f2317a89c70db007f1959a7f2b8 /winsup | |
parent | 92beb4638f08452261beab4629d74aee759b1732 (diff) |
* shm.cc (shmctl): On IPC_RMID don't unmap views and don't close handle
if the map is still referenced to emulate Linux and BSD behaviour.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/ChangeLog | 5 | ||||
-rw-r--r-- | winsup/cygwin/shm.cc | 18 |
2 files changed, 13 insertions, 10 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index a4905aa2a..3538eb1ae 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,10 @@ 2007-11-05 Corinna Vinschen <corinna@vinschen.de> + * shm.cc (shmctl): On IPC_RMID don't unmap views and don't close handle + if the map is still referenced to emulate Linux and BSD behaviour. + +2007-11-05 Corinna Vinschen <corinna@vinschen.de> + * shm.cc (shmctl): On IPC_RMID also unmap all views on shared mem as well as connected shm_attached_list entry. diff --git a/winsup/cygwin/shm.cc b/winsup/cygwin/shm.cc index 27cc9843c..6fb120b6d 100644 --- a/winsup/cygwin/shm.cc +++ b/winsup/cygwin/shm.cc @@ -265,22 +265,20 @@ shmctl (int shmid, int cmd, struct shmid_ds *buf) { if (ssh_entry->shmid == shmid) { - shm_attached_list *sph_entry, *sph_next_entry; - SLIST_FOREACH_SAFE (sph_entry, &sph_list, sph_next, - sph_next_entry) + bool in_use = false; + shm_attached_list *sph_entry; + SLIST_FOREACH (sph_entry, &sph_list, sph_next) { if (sph_entry->hdl == ssh_entry->hdl) { - SLIST_REMOVE (&sph_list, sph_entry, shm_attached_list, - sph_next); - /* ...unmap all views for this handle... */ - UnmapViewOfFile (sph_entry->ptr); - delete sph_entry; + in_use = true; + break; } } SLIST_REMOVE (&ssh_list, ssh_entry, shm_shmid_list, ssh_next); - /* ...and close the handle. */ - CloseHandle (ssh_entry->hdl); + /* ...and close the handle if it's not in use anymore. */ + if (!in_use) + CloseHandle (ssh_entry->hdl); delete ssh_entry; break; } |