Fixes double open() call on unix

This commit is contained in:
Guilherme Francescon 2016-02-16 19:09:28 -02:00 • committed by Francis Gulotta
parent 5df5a779ee
commit 7151eb3fbf

View file

@ -131,6 +131,9 @@ void EIO_Open(uv_work_t* req) {
OpenBaton* data = static_cast<OpenBaton*>(req->data);
int flags = (O_RDWR | O_NOCTTY | O_NONBLOCK | O_CLOEXEC | O_SYNC);
if(data->hupcl == false) {
flags &= ~HUPCL;
}
int fd = open(data->path, flags);
if(-1 == setup(fd, data)){
@ -172,20 +175,6 @@ int setup(int fd, OpenBaton *data) {
return -1;
}
// int flags = (O_RDWR | O_NOCTTY | O_NONBLOCK | O_CLOEXEC | O_SYNC);
// if(data->hupcl == false) {
// flags &= ~HUPCL;
// }
// int fd = open(data->path, flags);
int flags = (O_RDWR | O_NOCTTY | O_NONBLOCK | O_CLOEXEC | O_SYNC);
if(data->hupcl == false) {
flags &= ~HUPCL;
}
fd = open(data->path, flags);
if (fd == -1) {
snprintf(data->errorString, sizeof(data->errorString), "Cannot open %s", data->path);
return -1;