]> sourceware.org Git - newlib-cygwin.git/commitdiff
Don't rely on size argument in shmget call
authorCorinna Vinschen <corinna@vinschen.de>
Sun, 12 Apr 2015 12:05:12 +0000 (14:05 +0200)
committerCorinna Vinschen <corinna@vinschen.de>
Thu, 23 Apr 2015 19:59:49 +0000 (21:59 +0200)
* shm.cc (shmget): Fetch segment size from server rather than using
size argument to accommodate existing segments.  Add comment to explain
why.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
winsup/cygwin/ChangeLog
winsup/cygwin/release/2.0.0
winsup/cygwin/shm.cc

index 9a481318936a554b91fe3957abb2dd0d6dd17874..a75810f3caf4369c3279b5b94a87a7915cbd1ef8 100644 (file)
@@ -1,3 +1,9 @@
+2015-04-12  Corinna Vinschen  <corinna@vinschen.de>
+
+       * shm.cc (shmget): Fetch segment size from server rather than using
+       size argument to accommodate existing segments.  Add comment to explain
+       why.
+
 2015-04-10  Corinna Vinschen  <corinna@vinschen.de>
 
        * include/cygwin/version.h (CYGWIN_VERSION_DLL_MAJOR): Bump to 2000.
index f01e497feb6b008d95f41d391189c0dceffe4e44..6c89819d3fe4ff0d1cf1c71078b3df6adb43fec8 100644 (file)
@@ -40,3 +40,6 @@ Bug Fixes
 
 - Fix UTF-16 surrogate handling in wctomb and friends.
   Addresses: https://cygwin.com/ml/cygwin/2015-03/msg00452.html
+
+- Fix shmget usage of size parameter for already existing segments.
+  Addresses: https://cygwin.com/ml/cygwin/2015-04/msg00105.html
index c5ab708a4e8be22dbd38233e35defa59cf3e8bd5..e209346f779b93fc23cd70d0965e2380f71c33ef 100644 (file)
@@ -377,7 +377,14 @@ shmget (key_t key, size_t size, int shmflg)
      shmid and hdl value to the list. */
   ssh_new_entry->shmid = shmid;
   ssh_new_entry->hdl = hdl;
-  ssh_new_entry->size = size;
+  /* Fetch segment size from server.  If this is an already existing segment,
+     the size value in this shmget call is supposed to be meaningless. */
+  struct shmid_ds stat;
+  client_request_shm stat_req (shmid, IPC_STAT, &stat);
+  if (stat_req.make_request () == -1 || stat_req.retval () == -1)
+    ssh_new_entry->size = size;
+  else
+    ssh_new_entry->size = stat.shm_segsz;
   ssh_new_entry->ref_count = 0;
   SLIST_INSERT_HEAD (&ssh_list, ssh_new_entry, ssh_next);
   SLIST_UNLOCK ();
This page took 0.034474 seconds and 5 git commands to generate.