Changeset 151825 in webkit


Ignore:
Timestamp:
Jun 20, 2013 11:02:58 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[WK2] Looping for EINTR on close() is incorrect for Linux, at least
https://bugs.webkit.org/show_bug.cgi?id=117266

Patch by Sergio Correia <Sergio Correia> on 2013-06-20
Reviewed by Darin Adler.

Source/WebKit2:

Call closeWithRetry() to work around a difference in how the retry needs to
be done on Linux.

  • Platform/CoreIPC/unix/AttachmentUnix.cpp:

(CoreIPC::Attachment::dispose):

  • Platform/CoreIPC/unix/ConnectionUnix.cpp:

(CoreIPC::Connection::platformInvalidate):

  • Platform/unix/SharedMemoryUnix.cpp:

(WebKit::SharedMemory::Handle::~Handle):
(WebKit::SharedMemory::create):
(WebKit::SharedMemory::~SharedMemory):
(WebKit::SharedMemory::createHandle):

  • PluginProcess/PluginProcess.cpp:

(WebKit::PluginProcess::createWebProcessConnection):

  • SharedWorkerProcess/SharedWorkerProcess.cpp:

(WebKit::SharedWorkerProcess::createWebProcessConnection):

  • UIProcess/Launcher/qt/ProcessLauncherQt.cpp:

(WebKit::ProcessLauncher::launchProcess): All these places had
close-followed-by-EINTR-handling replaced with the new closeWithRetry()
function added in this commit.

Source/WTF:

Added file UniStdExtras with a closeWithRetry() function that works around
the EINTR behavior on Linux during a close() call: it closes the descriptor
unconditionally even when the call is interrupted.

  • wtf/UniStdExtras.h: Added.

(WTF::closeWithRetry): Wrapper around POSIX close() that handles EINTR
correctly.

Location:
trunk/Source
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r151817 r151825  
     12013-06-20  Sergio Correia  <sergio.correia@openbossa.org>
     2
     3        [WK2] Looping for EINTR on close() is incorrect for Linux, at least
     4        https://bugs.webkit.org/show_bug.cgi?id=117266
     5
     6        Reviewed by Darin Adler.
     7
     8        Added file UniStdExtras with a closeWithRetry() function that works around
     9        the EINTR behavior on Linux during a close() call: it closes the descriptor
     10        unconditionally even when the call is interrupted.
     11
     12        * wtf/UniStdExtras.h: Added.
     13        (WTF::closeWithRetry): Wrapper around POSIX close() that handles EINTR
     14        correctly.
     15
    1162013-06-20  Mark Lam  <mark.lam@apple.com>
    217
  • trunk/Source/WebKit2/ChangeLog

    r151795 r151825  
     12013-06-20  Sergio Correia  <sergio.correia@openbossa.org>
     2
     3        [WK2] Looping for EINTR on close() is incorrect for Linux, at least
     4        https://bugs.webkit.org/show_bug.cgi?id=117266
     5
     6        Reviewed by Darin Adler.
     7
     8        Call closeWithRetry() to work around a difference in how the retry needs to
     9        be done on Linux.
     10
     11        * Platform/CoreIPC/unix/AttachmentUnix.cpp:
     12        (CoreIPC::Attachment::dispose):
     13        * Platform/CoreIPC/unix/ConnectionUnix.cpp:
     14        (CoreIPC::Connection::platformInvalidate):
     15        * Platform/unix/SharedMemoryUnix.cpp:
     16        (WebKit::SharedMemory::Handle::~Handle):
     17        (WebKit::SharedMemory::create):
     18        (WebKit::SharedMemory::~SharedMemory):
     19        (WebKit::SharedMemory::createHandle):
     20        * PluginProcess/PluginProcess.cpp:
     21        (WebKit::PluginProcess::createWebProcessConnection):
     22        * SharedWorkerProcess/SharedWorkerProcess.cpp:
     23        (WebKit::SharedWorkerProcess::createWebProcessConnection):
     24        * UIProcess/Launcher/qt/ProcessLauncherQt.cpp:
     25        (WebKit::ProcessLauncher::launchProcess): All these places had
     26        ``close-followed-by-EINTR-handling'' replaced with the new closeWithRetry()
     27        function added in this commit.
     28
    1292013-06-20  Brady Eidson  <beidson@apple.com>
    230
  • trunk/Source/WebKit2/Platform/CoreIPC/unix/AttachmentUnix.cpp

    r95901 r151825  
    2828#include "Attachment.h"
    2929
    30 #include <unistd.h>
    31 #include <errno.h>
     30#include <wtf/UniStdExtras.h>
    3231
    3332namespace CoreIPC {
     
    5049{
    5150    if (m_fileDescriptor != -1)
    52         while (close(m_fileDescriptor) == -1 && (errno == EINTR)) { }
     51        closeWithRetry(m_fileDescriptor);
    5352}
    5453
  • trunk/Source/WebKit2/Platform/CoreIPC/unix/ConnectionUnix.cpp

    r150808 r151825  
    3838#include <wtf/Functional.h>
    3939#include <wtf/OwnArrayPtr.h>
     40#include <wtf/UniStdExtras.h>
    4041
    4142#if PLATFORM(QT)
     
    137138#if !PLATFORM(GTK)
    138139    if (m_socketDescriptor != -1)
    139         while (close(m_socketDescriptor) == -1 && errno == EINTR) { }
     140        closeWithRetry(m_socketDescriptor);
    140141#endif
    141142
  • trunk/Source/WebKit2/Platform/unix/SharedMemoryUnix.cpp

    r151324 r151825  
    4242#include <wtf/CurrentTime.h>
    4343#include <wtf/RandomNumber.h>
     44#include <wtf/UniStdExtras.h>
    4445#include <wtf/text/CString.h>
    4546
     
    5556{
    5657    if (!isNull())
    57         while (close(m_fileDescriptor) == -1 && errno == EINTR) { }
     58        closeWithRetry(m_fileDescriptor);
    5859}
    5960
     
    117118    while (ftruncate(fileDescriptor, size) == -1) {
    118119        if (errno != EINTR) {
    119             while (close(fileDescriptor) == -1 && errno == EINTR) { }
     120            closeWithRetry(fileDescriptor);
    120121            shm_unlink(tempName.data());
    121122            return 0;
     
    125126    void* data = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fileDescriptor, 0);
    126127    if (data == MAP_FAILED) {
    127         while (close(fileDescriptor) == -1 && errno == EINTR) { }
     128        closeWithRetry(fileDescriptor);
    128129        shm_unlink(tempName.data());
    129130        return 0;
     
    171172{
    172173    munmap(m_data, m_size);
    173     while (close(m_fileDescriptor) == -1 && errno == EINTR) { }
     174    closeWithRetry(m_fileDescriptor);
    174175}
    175176
     
    203204        if (errno != EINTR) {
    204205            ASSERT_NOT_REACHED();
    205             while (close(duplicatedHandle) == -1 && errno == EINTR) { }
     206            closeWithRetry(duplicatedHandle);
    206207            return false;
    207208        }
  • trunk/Source/WebKit2/PluginProcess/PluginProcess.cpp

    r142521 r151825  
    5151#include <sys/socket.h>
    5252#include <unistd.h>
     53#include <wtf/UniStdExtras.h>
    5354
    5455#ifdef SOCK_SEQPACKET
     
    193194        if (errno != EINTR) {
    194195            ASSERT_NOT_REACHED();
    195             while (close(sockets[0]) == -1 && errno == EINTR) { }
    196             while (close(sockets[1]) == -1 && errno == EINTR) { }
     196            closeWithRetry(sockets[0]);
     197            closeWithRetry(sockets[1]);
    197198            return;
    198199        }
     
    203204        if (errno != EINTR) {
    204205            ASSERT_NOT_REACHED();
    205             while (close(sockets[0]) == -1 && errno == EINTR) { }
    206             while (close(sockets[1]) == -1 && errno == EINTR) { }
     206            closeWithRetry(sockets[0]);
     207            closeWithRetry(sockets[1]);
    207208            return;
    208209        }
  • trunk/Source/WebKit2/SharedWorkerProcess/SharedWorkerProcess.cpp

    r149413 r151825  
    4747#include <sys/socket.h>
    4848#include <unistd.h>
     49#include <wtf/UniStdExtras.h>
    4950
    5051#ifdef SOCK_SEQPACKET
     
    140141        if (errno != EINTR) {
    141142            ASSERT_NOT_REACHED();
    142             while (close(sockets[0]) == -1 && errno == EINTR) { }
    143             while (close(sockets[1]) == -1 && errno == EINTR) { }
     143            closeWithRetry(sockets[0]);
     144            closeWithRetry(sockets[1]);
    144145            return;
    145146        }
     
    150151        if (errno != EINTR) {
    151152            ASSERT_NOT_REACHED();
    152             while (close(sockets[0]) == -1 && errno == EINTR) { }
    153             while (close(sockets[1]) == -1 && errno == EINTR) { }
     153            closeWithRetry(sockets[0]);
     154            closeWithRetry(sockets[1]);
    154155            return;
    155156        }
  • trunk/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp

    r146915 r151825  
    5151#include <sys/socket.h>
    5252#include <unistd.h>
     53#include <wtf/UniStdExtras.h>
    5354#endif
    5455
     
    163164        if (errno != EINTR) {
    164165            ASSERT_NOT_REACHED();
    165             while (close(sockets[0]) == -1 && errno == EINTR) { }
    166             while (close(sockets[1]) == -1 && errno == EINTR) { }
     166            closeWithRetry(sockets[0]);
     167            closeWithRetry(sockets[1]);
    167168            return;
    168169        }
Note: See TracChangeset for help on using the changeset viewer.