Skip to content

Commit

Permalink
Merge r163292 - Fix wrong mix of fcntl commands and flags
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=127842

Reviewed by Darin Adler.

We are mixing the commands to set file descriptor and file status
flags in a couple of fcntl() calls. FD_CLOEXEC must be set using
F_SETFD, and the access mode flags (O_RDONLY, O_WRONLY, O_RDWR)
with F_SETFL.

This combines patches by Guillem Jover and Sergio Correia.

* Platform/IPC/unix/ConnectionUnix.cpp:
(IPC::readBytesFromSocket):
* Platform/unix/SharedMemoryUnix.cpp:
(WebKit::SharedMemory::createHandle):
  • Loading branch information
bertogg authored and carlosgcampos committed Feb 10, 2014
1 parent 9e4f9f5 commit aea46d5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
19 changes: 19 additions & 0 deletions Source/WebKit2/ChangeLog
@@ -1,3 +1,22 @@
2014-02-03 Alberto Garcia <berto@igalia.com>

Fix wrong mix of fcntl commands and flags
https://bugs.webkit.org/show_bug.cgi?id=127842

Reviewed by Darin Adler.

We are mixing the commands to set file descriptor and file status
flags in a couple of fcntl() calls. FD_CLOEXEC must be set using
F_SETFD, and the access mode flags (O_RDONLY, O_WRONLY, O_RDWR)
with F_SETFL.

This combines patches by Guillem Jover and Sergio Correia.

* Platform/IPC/unix/ConnectionUnix.cpp:
(IPC::readBytesFromSocket):
* Platform/unix/SharedMemoryUnix.cpp:
(WebKit::SharedMemory::createHandle):

2014-02-05 Carlos Garcia Campos <cgarcia@igalia.com>

Unreviewed. Fix make distcheck.
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp
Expand Up @@ -321,7 +321,7 @@ static ssize_t readBytesFromSocket(int socketDescriptor, uint8_t* buffer, int co
memcpy(fileDescriptors, CMSG_DATA(controlMessage), sizeof(int) * *fileDescriptorsCount);

for (size_t i = 0; i < *fileDescriptorsCount; ++i) {
while (fcntl(fileDescriptors[i], F_SETFL, FD_CLOEXEC) == -1) {
while (fcntl(fileDescriptors[i], F_SETFD, FD_CLOEXEC) == -1) {
if (errno != EINTR) {
ASSERT_NOT_REACHED();
break;
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit2/Platform/unix/SharedMemoryUnix.cpp
Expand Up @@ -200,7 +200,7 @@ bool SharedMemory::createHandle(Handle& handle, Protection protection)
}
}

while ((fcntl(duplicatedHandle, F_SETFD, FD_CLOEXEC | accessModeFile(protection)) == -1)) {
while (fcntl(duplicatedHandle, F_SETFD, FD_CLOEXEC) == -1 || fcntl(duplicatedHandle, F_SETFL, accessModeFile(protection)) == -1) {
if (errno != EINTR) {
ASSERT_NOT_REACHED();
closeWithRetry(duplicatedHandle);
Expand Down

0 comments on commit aea46d5

Please sign in to comment.