mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
7197672: There are issues with shared data on windows
On Windows, set rw protection on the CDS file just before removing it. Reviewed-by: dcubed, iklam
This commit is contained in:
parent
898965f458
commit
812262d16b
1 changed files with 8 additions and 7 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -210,13 +210,14 @@ void FileMapInfo::open_for_write() {
|
||||||
tty->print_cr(" %s", _full_path);
|
tty->print_cr(" %s", _full_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the existing file in case another process has it open.
|
#ifdef _WINDOWS // On Windows, need WRITE permission to remove the file.
|
||||||
remove(_full_path);
|
chmod(_full_path, _S_IREAD | _S_IWRITE);
|
||||||
#ifdef _WINDOWS // if 0444 is used on Windows, then remove() will fail.
|
|
||||||
int fd = open(_full_path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0744);
|
|
||||||
#else
|
|
||||||
int fd = open(_full_path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0444);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Use remove() to delete the existing file because, on Unix, this will
|
||||||
|
// allow processes that have it open continued access to the file.
|
||||||
|
remove(_full_path);
|
||||||
|
int fd = open(_full_path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0444);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
fail_stop("Unable to create shared archive file %s.", _full_path);
|
fail_stop("Unable to create shared archive file %s.", _full_path);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue