Use MAP_SHARED mapping, in place of MAP_PRIVATE mapping, to work around a bug NSPRPUB_RELEASE_3_1_BRANCH
authorsrinivas%netscape.com
Tue, 06 Apr 1999 22:08:25 +0000
branchNSPRPUB_RELEASE_3_1_BRANCH
changeset 539 76252092627c75dd5a04d65bcd38ab73fdb776ee
parent 538 32faf681f6136cb7a03dab201fb47405615f46ca
child 540 5385386ad126167316a3252a68934130fcaf7207
push idunknown
push userunknown
push dateunknown
bugs122419
Use MAP_SHARED mapping, in place of MAP_PRIVATE mapping, to work around a bug in the OSF1 kernel. Bug #122419.
pr/src/md/unix/unix.c
--- a/pr/src/md/unix/unix.c
+++ b/pr/src/md/unix/unix.c
@@ -2965,18 +2965,27 @@ PRIntervalTime timeout)
      * to not consume too much virtual address space
      */
     len = statbuf.st_size < TRANSMITFILE_MMAP_CHUNK ? statbuf.st_size :
         TRANSMITFILE_MMAP_CHUNK;
     /*
      * Map in (part of) file. Take care of zero-length files.
      */
     if (len) {
+#ifdef OSF1
+		/*
+		 * Use MAP_SHARED to work around a bug in OSF1 that results in
+		 * corrupted data in the memory-mapped region
+		 */
+        addr = mmap((caddr_t) 0, len, PROT_READ, MAP_SHARED,
+            fd->secret->md.osfd, 0);
+#else
         addr = mmap((caddr_t) 0, len, PROT_READ, MAP_PRIVATE,
             fd->secret->md.osfd, 0);
+#endif
 
         if (addr == (void*)-1) {
             _PR_MD_MAP_MMAP_ERROR(_MD_ERRNO());
             count = -1;
             goto done;
         }
     }
     /*
@@ -3006,18 +3015,27 @@ PRIntervalTime timeout)
      */
     len = statbuf.st_size < TRANSMITFILE_MMAP_CHUNK ? statbuf.st_size :
         TRANSMITFILE_MMAP_CHUNK;
     while (len > 0) {
         /*
          * Map in (part of) file
          */
         PR_ASSERT((count - hlen) % TRANSMITFILE_MMAP_CHUNK == 0);
+#ifdef OSF1
+		/*
+		 * Use MAP_SHARED to work around a bug in OSF1 that results in
+		 * corrupted data in the memory-mapped region
+		 */
+        addr = mmap((caddr_t) 0, len, PROT_READ, MAP_SHARED,
+                fd->secret->md.osfd, count - hlen);
+#else
         addr = mmap((caddr_t) 0, len, PROT_READ, MAP_PRIVATE,
                 fd->secret->md.osfd, count - hlen);
+#endif
 
         if (addr == (void*)-1) {
             _PR_MD_MAP_MMAP_ERROR(_MD_ERRNO());
             count = -1;
             goto done;
         }
         rv =  PR_Send(sd, addr, len, 0, timeout);
         munmap(addr,len);