Mercurial > hg > truffle
comparison src/share/vm/memory/filemap.cpp @ 7980:c4ef3380a70b
7197672: There are issues with shared data on windows
Summary: On Windows, set rw protection on the CDS file just before removing it.
Reviewed-by: dcubed, iklam
author | hseigel |
---|---|
date | Sun, 03 Feb 2013 16:49:16 -0500 |
parents | 561148896559 |
children | 91bf0bdae37b |
comparison
equal
deleted
inserted
replaced
7978:a7f9a1195d86 | 7980:c4ef3380a70b |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
208 if (PrintSharedSpaces) { | 208 if (PrintSharedSpaces) { |
209 tty->print_cr("Dumping shared data to file: "); | 209 tty->print_cr("Dumping shared data to file: "); |
210 tty->print_cr(" %s", _full_path); | 210 tty->print_cr(" %s", _full_path); |
211 } | 211 } |
212 | 212 |
213 // Remove the existing file in case another process has it open. | 213 #ifdef _WINDOWS // On Windows, need WRITE permission to remove the file. |
214 chmod(_full_path, _S_IREAD | _S_IWRITE); | |
215 #endif | |
216 | |
217 // Use remove() to delete the existing file because, on Unix, this will | |
218 // allow processes that have it open continued access to the file. | |
214 remove(_full_path); | 219 remove(_full_path); |
215 #ifdef _WINDOWS // if 0444 is used on Windows, then remove() will fail. | |
216 int fd = open(_full_path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0744); | |
217 #else | |
218 int fd = open(_full_path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0444); | 220 int fd = open(_full_path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0444); |
219 #endif | |
220 if (fd < 0) { | 221 if (fd < 0) { |
221 fail_stop("Unable to create shared archive file %s.", _full_path); | 222 fail_stop("Unable to create shared archive file %s.", _full_path); |
222 } | 223 } |
223 _fd = fd; | 224 _fd = fd; |
224 _file_offset = 0; | 225 _file_offset = 0; |