mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-19 09:57:49 +00:00
8150232: AIX cleanup: Integrate changes of 7178026 and others
Reviewed-by: simonis
This commit is contained in:
parent
390295caf1
commit
5d04cc8e61
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2015 SAP SE. All rights reserved.
|
||||
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2016 SAP SE. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -225,7 +225,7 @@ int AixAttachListener::init() {
|
||||
// We must call bind with the actual socketaddr length. This is obligatory for AS400.
|
||||
int res = ::bind(listener, (struct sockaddr*)&addr, SUN_LEN(&addr));
|
||||
if (res == -1) {
|
||||
RESTARTABLE(::close(listener), res);
|
||||
::close(listener);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -238,7 +238,7 @@ int AixAttachListener::init() {
|
||||
}
|
||||
}
|
||||
if (res == -1) {
|
||||
RESTARTABLE(::close(listener), res);
|
||||
::close(listener);
|
||||
::unlink(initial_path);
|
||||
return -1;
|
||||
}
|
||||
@ -400,7 +400,7 @@ AixAttachOperation* AixAttachListener::dequeue() {
|
||||
AixAttachOperation* op = read_request(s);
|
||||
if (op == NULL) {
|
||||
int res;
|
||||
RESTARTABLE(::close(s), res);
|
||||
::close(s);
|
||||
continue;
|
||||
} else {
|
||||
return op;
|
||||
@ -452,7 +452,7 @@ void AixAttachOperation::complete(jint result, bufferedStream* st) {
|
||||
}
|
||||
|
||||
// done
|
||||
RESTARTABLE(::close(this->socket()), rc);
|
||||
::close(this->socket());
|
||||
|
||||
// were we externally suspended while we were waiting?
|
||||
thread->check_and_wait_while_suspended();
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2013 SAP SE. All rights reserved.
|
||||
* Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2016 SAP SE. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -121,7 +121,7 @@ static void save_memory_to_file(char* addr, size_t size) {
|
||||
addr += result;
|
||||
}
|
||||
|
||||
RESTARTABLE(::close(fd), result);
|
||||
result = ::close(fd);
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
if (result == OS_ERR) {
|
||||
warning("Could not close %s: %s\n", destfile, strerror(errno));
|
||||
@ -299,10 +299,13 @@ static int open_o_nofollow_impl(const char* path, int oflag, mode_t mode, bool u
|
||||
bool create;
|
||||
int error;
|
||||
int fd;
|
||||
int result;
|
||||
|
||||
create = false;
|
||||
|
||||
if (lstat(path, &orig_st) != 0) {
|
||||
RESTARTABLE(::lstat(path, &orig_st), result);
|
||||
|
||||
if (result == OS_ERR) {
|
||||
if (errno == ENOENT && (oflag & O_CREAT) != 0) {
|
||||
// File doesn't exist, but_we want to create it, add O_EXCL flag
|
||||
// to make sure no-one creates it (or a symlink) before us
|
||||
@ -316,7 +319,7 @@ static int open_o_nofollow_impl(const char* path, int oflag, mode_t mode, bool u
|
||||
return OS_ERR;
|
||||
}
|
||||
} else {
|
||||
// Lstat success, check if existing file is a link.
|
||||
// lstat success, check if existing file is a link.
|
||||
if ((orig_st.st_mode & S_IFMT) == S_IFLNK) {
|
||||
// File is a symlink.
|
||||
errno = ELOOP;
|
||||
@ -325,9 +328,9 @@ static int open_o_nofollow_impl(const char* path, int oflag, mode_t mode, bool u
|
||||
}
|
||||
|
||||
if (use_mode == true) {
|
||||
fd = open(path, oflag, mode);
|
||||
RESTARTABLE(::open(path, oflag, mode), fd);
|
||||
} else {
|
||||
fd = open(path, oflag);
|
||||
RESTARTABLE(::open(path, oflag), fd);
|
||||
}
|
||||
|
||||
if (fd == OS_ERR) {
|
||||
@ -336,7 +339,8 @@ static int open_o_nofollow_impl(const char* path, int oflag, mode_t mode, bool u
|
||||
|
||||
// Can't do inode checks on before/after if we created the file.
|
||||
if (create == false) {
|
||||
if (fstat(fd, &new_st) != 0) {
|
||||
RESTARTABLE(::fstat(fd, &new_st), result);
|
||||
if (result == OS_ERR) {
|
||||
// Keep errno from fstat, in case close also fails.
|
||||
error = errno;
|
||||
::close(fd);
|
||||
@ -384,7 +388,7 @@ static DIR *open_directory_secure(const char* dirname) {
|
||||
RESTARTABLE(::open(dirname, O_RDONLY|O_NOFOLLOW), result);
|
||||
#else
|
||||
// workaround (jdk6 coding)
|
||||
RESTARTABLE(::open_o_nofollow(dirname, O_RDONLY), result);
|
||||
result = open_o_nofollow(dirname, O_RDONLY);
|
||||
#endif
|
||||
|
||||
if (result == OS_ERR) {
|
||||
@ -888,7 +892,7 @@ static int create_sharedmem_resources(const char* dirname, const char* filename,
|
||||
RESTARTABLE(::open(filename, O_RDWR|O_CREAT|O_NOFOLLOW, S_IREAD|S_IWRITE), result);
|
||||
#else
|
||||
// workaround function (jdk6 code)
|
||||
RESTARTABLE(::open_o_nofollow(filename, O_RDWR|O_CREAT, S_IREAD|S_IWRITE), result);
|
||||
result = open_o_nofollow(filename, O_RDWR|O_CREAT, S_IREAD|S_IWRITE);
|
||||
#endif
|
||||
|
||||
if (result == OS_ERR) {
|
||||
@ -931,7 +935,7 @@ static int create_sharedmem_resources(const char* dirname, const char* filename,
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
warning("could not set shared memory file size: %s\n", strerror(errno));
|
||||
}
|
||||
RESTARTABLE(::close(fd), result);
|
||||
::close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -951,7 +955,7 @@ static int open_sharedmem_file(const char* filename, int oflags, TRAPS) {
|
||||
#ifdef O_NOFOLLOW
|
||||
RESTARTABLE(::open(filename, oflags), result);
|
||||
#else
|
||||
RESTARTABLE(::open_o_nofollow(filename, oflags), result);
|
||||
open_o_nofollow(filename, oflags);
|
||||
#endif
|
||||
|
||||
if (result == OS_ERR) {
|
||||
@ -1006,8 +1010,7 @@ static char* mmap_create_shared(size_t size) {
|
||||
|
||||
char* dirname = get_user_tmp_dir(user_name);
|
||||
char* filename = get_sharedmem_filename(dirname, vmid);
|
||||
|
||||
// Get the short filename.
|
||||
// get the short filename.
|
||||
char* short_filename = strrchr(filename, '/');
|
||||
if (short_filename == NULL) {
|
||||
short_filename = filename;
|
||||
@ -1033,9 +1036,7 @@ static char* mmap_create_shared(size_t size) {
|
||||
|
||||
mapAddress = (char*)::mmap((char*)0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
|
||||
// attempt to close the file - restart it if it was interrupted,
|
||||
// but ignore other failures
|
||||
RESTARTABLE(::close(fd), result);
|
||||
result = ::close(fd);
|
||||
assert(result != OS_ERR, "could not close file");
|
||||
|
||||
if (mapAddress == MAP_FAILED) {
|
||||
@ -1142,7 +1143,6 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor
|
||||
// constructs for the file and the shared memory mapping.
|
||||
if (mode == PerfMemory::PERF_MODE_RO) {
|
||||
mmap_prot = PROT_READ;
|
||||
|
||||
// No O_NOFOLLOW defined at buildtime, and it is not documented for open.
|
||||
#ifdef O_NOFOLLOW
|
||||
file_flags = O_RDONLY | O_NOFOLLOW;
|
||||
@ -1205,21 +1205,28 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor
|
||||
FREE_C_HEAP_ARRAY(char, filename);
|
||||
|
||||
// open the shared memory file for the give vmid
|
||||
fd = open_sharedmem_file(rfilename, file_flags, CHECK);
|
||||
assert(fd != OS_ERR, "unexpected value");
|
||||
fd = open_sharedmem_file(rfilename, file_flags, THREAD);
|
||||
|
||||
if (fd == OS_ERR) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (HAS_PENDING_EXCEPTION) {
|
||||
::close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
if (*sizep == 0) {
|
||||
size = sharedmem_filesize(fd, CHECK);
|
||||
assert(size != 0, "unexpected size");
|
||||
} else {
|
||||
size = *sizep;
|
||||
}
|
||||
|
||||
assert(size > 0, "unexpected size <= 0");
|
||||
|
||||
mapAddress = (char*)::mmap((char*)0, size, mmap_prot, MAP_SHARED, fd, 0);
|
||||
|
||||
// attempt to close the file - restart if it gets interrupted,
|
||||
// but ignore other failures
|
||||
RESTARTABLE(::close(fd), result);
|
||||
result = ::close(fd);
|
||||
assert(result != OS_ERR, "could not close file");
|
||||
|
||||
if (mapAddress == MAP_FAILED) {
|
||||
@ -1230,7 +1237,7 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor
|
||||
"Could not map PerfMemory");
|
||||
}
|
||||
|
||||
// It does not go through os api, the operation has to record from here.
|
||||
// it does not go through os api, the operation has to record from here.
|
||||
MemTracker::record_virtual_memory_reserve((address)mapAddress, size, CURRENT_PC, mtInternal);
|
||||
|
||||
*addr = mapAddress;
|
||||
@ -1238,7 +1245,7 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor
|
||||
|
||||
if (PerfTraceMemOps) {
|
||||
tty->print("mapped " SIZE_FORMAT " bytes for vmid %d at "
|
||||
INTPTR_FORMAT "\n", size, vmid, (void*)mapAddress);
|
||||
INTPTR_FORMAT "\n", size, vmid, p2i((void*)mapAddress));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user