提交 93976ef2 编写于 作者: R rdurbin

7178026: os::close can restart ::close but that is not a restartable syscall

Summary: Removed restart macros from all os:close calls on Solaris, Linux, MacOS X platforms.
Reviewed-by: dcubed, dholmes
上级 118491a3
...@@ -122,9 +122,7 @@ static int file_open(const char* path, int flag) { ...@@ -122,9 +122,7 @@ static int file_open(const char* path, int flag) {
} }
static int file_close(int fd) { static int file_close(int fd) {
int ret; return close(fd);
RESTARTABLE(close(fd), ret);
return ret;
} }
static int file_read(int fd, char* buf, int len) { static int file_read(int fd, char* buf, int len) {
......
...@@ -199,7 +199,7 @@ int BsdAttachListener::init() { ...@@ -199,7 +199,7 @@ int BsdAttachListener::init() {
::unlink(initial_path); ::unlink(initial_path);
int res = ::bind(listener, (struct sockaddr*)&addr, sizeof(addr)); int res = ::bind(listener, (struct sockaddr*)&addr, sizeof(addr));
if (res == -1) { if (res == -1) {
RESTARTABLE(::close(listener), res); ::close(listener);
return -1; return -1;
} }
...@@ -217,7 +217,7 @@ int BsdAttachListener::init() { ...@@ -217,7 +217,7 @@ int BsdAttachListener::init() {
} }
} }
if (res == -1) { if (res == -1) {
RESTARTABLE(::close(listener), res); ::close(listener);
::unlink(initial_path); ::unlink(initial_path);
return -1; return -1;
} }
...@@ -345,24 +345,21 @@ BsdAttachOperation* BsdAttachListener::dequeue() { ...@@ -345,24 +345,21 @@ BsdAttachOperation* BsdAttachListener::dequeue() {
uid_t puid; uid_t puid;
gid_t pgid; gid_t pgid;
if (::getpeereid(s, &puid, &pgid) != 0) { if (::getpeereid(s, &puid, &pgid) != 0) {
int res; ::close(s);
RESTARTABLE(::close(s), res);
continue; continue;
} }
uid_t euid = geteuid(); uid_t euid = geteuid();
gid_t egid = getegid(); gid_t egid = getegid();
if (puid != euid || pgid != egid) { if (puid != euid || pgid != egid) {
int res; ::close(s);
RESTARTABLE(::close(s), res);
continue; continue;
} }
// peer credential look okay so we read the request // peer credential look okay so we read the request
BsdAttachOperation* op = read_request(s); BsdAttachOperation* op = read_request(s);
if (op == NULL) { if (op == NULL) {
int res; ::close(s);
RESTARTABLE(::close(s), res);
continue; continue;
} else { } else {
return op; return op;
...@@ -413,7 +410,7 @@ void BsdAttachOperation::complete(jint result, bufferedStream* st) { ...@@ -413,7 +410,7 @@ void BsdAttachOperation::complete(jint result, bufferedStream* st) {
} }
// done // done
RESTARTABLE(::close(this->socket()), rc); ::close(this->socket());
// were we externally suspended while we were waiting? // were we externally suspended while we were waiting?
thread->check_and_wait_while_suspended(); thread->check_and_wait_while_suspended();
......
...@@ -178,11 +178,11 @@ inline size_t os::write(int fd, const void *buf, unsigned int nBytes) { ...@@ -178,11 +178,11 @@ inline size_t os::write(int fd, const void *buf, unsigned int nBytes) {
} }
inline int os::close(int fd) { inline int os::close(int fd) {
RESTARTABLE_RETURN_INT(::close(fd)); return ::close(fd);
} }
inline int os::socket_close(int fd) { inline int os::socket_close(int fd) {
RESTARTABLE_RETURN_INT(::close(fd)); return ::close(fd);
} }
inline int os::socket(int domain, int type, int protocol) { inline int os::socket(int domain, int type, int protocol) {
......
...@@ -120,7 +120,7 @@ static void save_memory_to_file(char* addr, size_t size) { ...@@ -120,7 +120,7 @@ static void save_memory_to_file(char* addr, size_t size) {
addr += result; addr += result;
} }
RESTARTABLE(::close(fd), result); result = ::close(fd);
if (PrintMiscellaneous && Verbose) { if (PrintMiscellaneous && Verbose) {
if (result == OS_ERR) { if (result == OS_ERR) {
warning("Could not close %s: %s\n", destfile, strerror(errno)); warning("Could not close %s: %s\n", destfile, strerror(errno));
...@@ -632,7 +632,7 @@ static int create_sharedmem_resources(const char* dirname, const char* filename, ...@@ -632,7 +632,7 @@ static int create_sharedmem_resources(const char* dirname, const char* filename,
if (PrintMiscellaneous && Verbose) { if (PrintMiscellaneous && Verbose) {
warning("could not set shared memory file size: %s\n", strerror(errno)); warning("could not set shared memory file size: %s\n", strerror(errno));
} }
RESTARTABLE(::close(fd), result); ::close(fd);
return -1; return -1;
} }
...@@ -656,7 +656,7 @@ static int create_sharedmem_resources(const char* dirname, const char* filename, ...@@ -656,7 +656,7 @@ static int create_sharedmem_resources(const char* dirname, const char* filename,
if (result != -1) { if (result != -1) {
return fd; return fd;
} else { } else {
RESTARTABLE(::close(fd), result); ::close(fd);
return -1; return -1;
} }
} }
...@@ -734,9 +734,7 @@ static char* mmap_create_shared(size_t size) { ...@@ -734,9 +734,7 @@ static char* mmap_create_shared(size_t size) {
mapAddress = (char*)::mmap((char*)0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); 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, result = ::close(fd);
// but ignore other failures
RESTARTABLE(::close(fd), result);
assert(result != OS_ERR, "could not close file"); assert(result != OS_ERR, "could not close file");
if (mapAddress == MAP_FAILED) { if (mapAddress == MAP_FAILED) {
...@@ -909,7 +907,7 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor ...@@ -909,7 +907,7 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor
// attempt to close the file - restart if it gets interrupted, // attempt to close the file - restart if it gets interrupted,
// but ignore other failures // but ignore other failures
RESTARTABLE(::close(fd), result); result = ::close(fd);
assert(result != OS_ERR, "could not close file"); assert(result != OS_ERR, "could not close file");
if (mapAddress == MAP_FAILED) { if (mapAddress == MAP_FAILED) {
......
...@@ -199,7 +199,7 @@ int LinuxAttachListener::init() { ...@@ -199,7 +199,7 @@ int LinuxAttachListener::init() {
::unlink(initial_path); ::unlink(initial_path);
int res = ::bind(listener, (struct sockaddr*)&addr, sizeof(addr)); int res = ::bind(listener, (struct sockaddr*)&addr, sizeof(addr));
if (res == -1) { if (res == -1) {
RESTARTABLE(::close(listener), res); ::close(listener);
return -1; return -1;
} }
...@@ -212,7 +212,7 @@ int LinuxAttachListener::init() { ...@@ -212,7 +212,7 @@ int LinuxAttachListener::init() {
} }
} }
if (res == -1) { if (res == -1) {
RESTARTABLE(::close(listener), res); ::close(listener);
::unlink(initial_path); ::unlink(initial_path);
return -1; return -1;
} }
...@@ -340,24 +340,21 @@ LinuxAttachOperation* LinuxAttachListener::dequeue() { ...@@ -340,24 +340,21 @@ LinuxAttachOperation* LinuxAttachListener::dequeue() {
struct ucred cred_info; struct ucred cred_info;
socklen_t optlen = sizeof(cred_info); socklen_t optlen = sizeof(cred_info);
if (::getsockopt(s, SOL_SOCKET, SO_PEERCRED, (void*)&cred_info, &optlen) == -1) { if (::getsockopt(s, SOL_SOCKET, SO_PEERCRED, (void*)&cred_info, &optlen) == -1) {
int res; ::close(s);
RESTARTABLE(::close(s), res);
continue; continue;
} }
uid_t euid = geteuid(); uid_t euid = geteuid();
gid_t egid = getegid(); gid_t egid = getegid();
if (cred_info.uid != euid || cred_info.gid != egid) { if (cred_info.uid != euid || cred_info.gid != egid) {
int res; ::close(s);
RESTARTABLE(::close(s), res);
continue; continue;
} }
// peer credential look okay so we read the request // peer credential look okay so we read the request
LinuxAttachOperation* op = read_request(s); LinuxAttachOperation* op = read_request(s);
if (op == NULL) { if (op == NULL) {
int res; ::close(s);
RESTARTABLE(::close(s), res);
continue; continue;
} else { } else {
return op; return op;
...@@ -408,7 +405,7 @@ void LinuxAttachOperation::complete(jint result, bufferedStream* st) { ...@@ -408,7 +405,7 @@ void LinuxAttachOperation::complete(jint result, bufferedStream* st) {
} }
// done // done
RESTARTABLE(::close(this->socket()), rc); ::close(this->socket());
// were we externally suspended while we were waiting? // were we externally suspended while we were waiting?
thread->check_and_wait_while_suspended(); thread->check_and_wait_while_suspended();
......
...@@ -120,7 +120,7 @@ static void save_memory_to_file(char* addr, size_t size) { ...@@ -120,7 +120,7 @@ static void save_memory_to_file(char* addr, size_t size) {
addr += result; addr += result;
} }
RESTARTABLE(::close(fd), result); result = ::close(fd);
if (PrintMiscellaneous && Verbose) { if (PrintMiscellaneous && Verbose) {
if (result == OS_ERR) { if (result == OS_ERR) {
warning("Could not close %s: %s\n", destfile, strerror(errno)); warning("Could not close %s: %s\n", destfile, strerror(errno));
...@@ -632,7 +632,7 @@ static int create_sharedmem_resources(const char* dirname, const char* filename, ...@@ -632,7 +632,7 @@ static int create_sharedmem_resources(const char* dirname, const char* filename,
if (PrintMiscellaneous && Verbose) { if (PrintMiscellaneous && Verbose) {
warning("could not set shared memory file size: %s\n", strerror(errno)); warning("could not set shared memory file size: %s\n", strerror(errno));
} }
RESTARTABLE(::close(fd), result); ::close(fd);
return -1; return -1;
} }
...@@ -656,7 +656,7 @@ static int create_sharedmem_resources(const char* dirname, const char* filename, ...@@ -656,7 +656,7 @@ static int create_sharedmem_resources(const char* dirname, const char* filename,
if (result != -1) { if (result != -1) {
return fd; return fd;
} else { } else {
RESTARTABLE(::close(fd), result); ::close(fd);
return -1; return -1;
} }
} }
...@@ -734,9 +734,7 @@ static char* mmap_create_shared(size_t size) { ...@@ -734,9 +734,7 @@ static char* mmap_create_shared(size_t size) {
mapAddress = (char*)::mmap((char*)0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); 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, result = ::close(fd);
// but ignore other failures
RESTARTABLE(::close(fd), result);
assert(result != OS_ERR, "could not close file"); assert(result != OS_ERR, "could not close file");
if (mapAddress == MAP_FAILED) { if (mapAddress == MAP_FAILED) {
...@@ -907,9 +905,7 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor ...@@ -907,9 +905,7 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor
mapAddress = (char*)::mmap((char*)0, size, mmap_prot, MAP_SHARED, fd, 0); mapAddress = (char*)::mmap((char*)0, size, mmap_prot, MAP_SHARED, fd, 0);
// attempt to close the file - restart if it gets interrupted, result = ::close(fd);
// but ignore other failures
RESTARTABLE(::close(fd), result);
assert(result != OS_ERR, "could not close file"); assert(result != OS_ERR, "could not close file");
if (mapAddress == MAP_FAILED) { if (mapAddress == MAP_FAILED) {
......
...@@ -122,9 +122,7 @@ static int file_open(const char* path, int flag) { ...@@ -122,9 +122,7 @@ static int file_open(const char* path, int flag) {
} }
static int file_close(int fd) { static int file_close(int fd) {
int ret; return close(fd);
RESTARTABLE(close(fd), ret);
return ret;
} }
static int file_read(int fd, char* buf, int len) { static int file_read(int fd, char* buf, int len) {
......
...@@ -392,7 +392,7 @@ int SolarisAttachListener::create_door() { ...@@ -392,7 +392,7 @@ int SolarisAttachListener::create_door() {
return -1; return -1;
} }
assert(fd >= 0, "bad file descriptor"); assert(fd >= 0, "bad file descriptor");
RESTARTABLE(::close(fd), res); ::close(fd);
// attach the door descriptor to the file // attach the door descriptor to the file
if ((res = ::fattach(dd, initial_path)) == -1) { if ((res = ::fattach(dd, initial_path)) == -1) {
...@@ -410,7 +410,7 @@ int SolarisAttachListener::create_door() { ...@@ -410,7 +410,7 @@ int SolarisAttachListener::create_door() {
// rename file so that clients can attach // rename file so that clients can attach
if (dd >= 0) { if (dd >= 0) {
if (::rename(initial_path, door_path) == -1) { if (::rename(initial_path, door_path) == -1) {
RESTARTABLE(::close(dd), res); ::close(dd);
::fdetach(initial_path); ::fdetach(initial_path);
dd = -1; dd = -1;
} }
...@@ -549,7 +549,7 @@ void SolarisAttachOperation::complete(jint res, bufferedStream* st) { ...@@ -549,7 +549,7 @@ void SolarisAttachOperation::complete(jint res, bufferedStream* st) {
} }
// close socket and we're done // close socket and we're done
RESTARTABLE(::close(this->socket()), rc); ::close(this->socket());
// were we externally suspended while we were waiting? // were we externally suspended while we were waiting?
thread->check_and_wait_while_suspended(); thread->check_and_wait_while_suspended();
......
...@@ -6679,11 +6679,11 @@ size_t os::write(int fd, const void *buf, unsigned int nBytes) { ...@@ -6679,11 +6679,11 @@ size_t os::write(int fd, const void *buf, unsigned int nBytes) {
} }
int os::close(int fd) { int os::close(int fd) {
RESTARTABLE_RETURN_INT(::close(fd)); return ::close(fd);
} }
int os::socket_close(int fd) { int os::socket_close(int fd) {
RESTARTABLE_RETURN_INT(::close(fd)); return ::close(fd);
} }
int os::recv(int fd, char* buf, size_t nBytes, uint flags) { int os::recv(int fd, char* buf, size_t nBytes, uint flags) {
......
...@@ -122,7 +122,7 @@ static void save_memory_to_file(char* addr, size_t size) { ...@@ -122,7 +122,7 @@ static void save_memory_to_file(char* addr, size_t size) {
addr += result; addr += result;
} }
RESTARTABLE(::close(fd), result); result = ::close(fd);
if (PrintMiscellaneous && Verbose) { if (PrintMiscellaneous && Verbose) {
if (result == OS_ERR) { if (result == OS_ERR) {
warning("Could not close %s: %s\n", destfile, strerror(errno)); warning("Could not close %s: %s\n", destfile, strerror(errno));
...@@ -437,7 +437,7 @@ static char* get_user_name(int vmid, TRAPS) { ...@@ -437,7 +437,7 @@ static char* get_user_name(int vmid, TRAPS) {
addr+=result; addr+=result;
} }
RESTARTABLE(::close(fd), result); ::close(fd);
// get the user name for the effective user id of the process // get the user name for the effective user id of the process
char* user_name = get_user_name(psinfo.pr_euid); char* user_name = get_user_name(psinfo.pr_euid);
...@@ -669,7 +669,7 @@ static int create_sharedmem_resources(const char* dirname, const char* filename, ...@@ -669,7 +669,7 @@ static int create_sharedmem_resources(const char* dirname, const char* filename,
if (PrintMiscellaneous && Verbose) { if (PrintMiscellaneous && Verbose) {
warning("could not set shared memory file size: %s\n", strerror(errno)); warning("could not set shared memory file size: %s\n", strerror(errno));
} }
RESTARTABLE(::close(fd), result); ::close(fd);
return -1; return -1;
} }
...@@ -749,9 +749,7 @@ static char* mmap_create_shared(size_t size) { ...@@ -749,9 +749,7 @@ static char* mmap_create_shared(size_t size) {
mapAddress = (char*)::mmap((char*)0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); 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, result = ::close(fd);
// but ignore other failures
RESTARTABLE(::close(fd), result);
assert(result != OS_ERR, "could not close file"); assert(result != OS_ERR, "could not close file");
if (mapAddress == MAP_FAILED) { if (mapAddress == MAP_FAILED) {
...@@ -922,9 +920,7 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor ...@@ -922,9 +920,7 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor
mapAddress = (char*)::mmap((char*)0, size, mmap_prot, MAP_SHARED, fd, 0); mapAddress = (char*)::mmap((char*)0, size, mmap_prot, MAP_SHARED, fd, 0);
// attempt to close the file - restart if it gets interrupted, result = ::close(fd);
// but ignore other failures
RESTARTABLE(::close(fd), result);
assert(result != OS_ERR, "could not close file"); assert(result != OS_ERR, "could not close file");
if (mapAddress == MAP_FAILED) { if (mapAddress == MAP_FAILED) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册