summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/shm.cc
diff options
context:
space:
mode:
authorRobert Collins <rbtcollins@hotmail.com>2002-03-04 07:22:08 +0000
committerRobert Collins <rbtcollins@hotmail.com>2002-03-04 07:22:08 +0000
commit67be0adb710ef4e53bd494ad1d19c15db6eb500d (patch)
tree51323d841821c476c48fe5a93498d553e0ad0010 /winsup/cygwin/shm.cc
parent74c3173ade62d764f05b0da5c319ae6e14a7d048 (diff)
downloadcygnal-67be0adb710ef4e53bd494ad1d19c15db6eb500d.tar.gz
cygnal-67be0adb710ef4e53bd494ad1d19c15db6eb500d.tar.bz2
cygnal-67be0adb710ef4e53bd494ad1d19c15db6eb500d.zip
2002-03-04 Robert Collins <rbtcollins@hotmail.com>
* cygserver_shm.cc: Run indent. (deleted_head): New global for storing shm id's pending deletion. (client_request_shm::serve): Return ENOSYS for invalid request types. Implement SHM_DEL - delete a shm id. * cygserver_shm.h (SHM_DEL): New type value. * shm.cc (delete_inprocess_shmds): New function, does what it's name implies. (shmctl): Implement shm_rmid control type.
Diffstat (limited to 'winsup/cygwin/shm.cc')
-rw-r--r--winsup/cygwin/shm.cc36
1 files changed, 32 insertions, 4 deletions
diff --git a/winsup/cygwin/shm.cc b/winsup/cygwin/shm.cc
index 7fe95edde..530539569 100644
--- a/winsup/cygwin/shm.cc
+++ b/winsup/cygwin/shm.cc
@@ -134,6 +134,34 @@ build_inprocess_shmds (HANDLE hfilemap, HANDLE hattachmap, key_t key,
return tempnode;
}
+static void
+delete_inprocess_shmds (shmnode **nodeptr)
+{
+ shmnode *node = *nodeptr;
+
+ // remove from the list
+ if (node == shm_head)
+ shm_head = shm_head->next;
+ else
+ {
+ shmnode *tempnode = shm_head;
+ while (tempnode && tempnode->next != node)
+ tempnode = tempnode->next;
+ if (tempnode)
+ tempnode->next = node->next;
+ // else log the unexpected !
+ }
+
+ // release the shared data view
+ UnmapViewOfFile (node->shmds);
+ CloseHandle (node->filemap);
+ CloseHandle (node->attachmap);
+
+ // free the memory
+ delete node;
+ nodeptr = NULL;
+}
+
int __stdcall
fixup_shms_after_fork ()
{
@@ -352,8 +380,7 @@ shmctl (int shmid, int cmd, struct shmid_ds *buf)
* and each process, as they touch this area detaches. eventually only the
* daemon has an attach. The daemon gets asked to detach immediately.
*/
-#if 0
-//waiting for the daemon to handle terminating process's
+ //waiting for the daemon to handle terminating process's
client_request_shm *req =
new client_request_shm (SHM_DEL, shmid, GetCurrentProcessId ());
int rc;
@@ -373,9 +400,10 @@ shmctl (int shmid, int cmd, struct shmid_ds *buf)
/* the daemon has deleted it's references */
/* now for us */
-
-#endif
+ // FIXME: create a destructor
+ delete_inprocess_shmds (&tempnode);
+
}
break;
case IPC_SET: