Changeset 102493 in webkit


Ignore:
Timestamp:
Dec 9, 2011 5:01:12 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[Qt] Open shared memory files with shm_open.
https://bugs.webkit.org/show_bug.cgi?id=74078

Original patch by Kimmo Kinnunen

Patch by Allan Sandfeld Jensen <allan.jensen@nokia.com> on 2011-12-09
Reviewed by Kenneth Rohde Christiansen.

Open shared memory files with shm_open. This uses mount point that is
intended to host shared memory files. Typically this is /dev/shm.

This fixes crashes when filesystem that hosts QDir::temp() is full.

This is also more well-defined with respect to question whether SHM
writes to temp dir would cause unintended wear if hosted on flash drives.

This also fixes performance problems regarding QDir::temp() and
mkostemp(), both of which appear to be long operations.

  • Platform/unix/SharedMemoryUnix.cpp:

(WebKit::SharedMemory::create):

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r102488 r102493  
     12011-12-09  Allan Sandfeld Jensen  <allan.jensen@nokia.com>
     2
     3        [Qt] Open shared memory files with shm_open.
     4        https://bugs.webkit.org/show_bug.cgi?id=74078
     5
     6        Original patch by Kimmo Kinnunen
     7
     8        Reviewed by Kenneth Rohde Christiansen.
     9
     10        Open shared memory files with shm_open. This uses mount point that is
     11        intended to host shared memory files. Typically this is /dev/shm.
     12
     13        This fixes crashes when filesystem that hosts QDir::temp() is full.
     14
     15        This is also more well-defined with respect to question whether SHM
     16        writes to temp dir would cause unintended wear if hosted on flash drives.
     17
     18        This also fixes performance problems regarding QDir::temp() and
     19        mkostemp(), both of which appear to be long operations.
     20
     21        * Platform/unix/SharedMemoryUnix.cpp:
     22        (WebKit::SharedMemory::create):
     23
    1242011-12-09  Hugo Parente Lima  <hugo.lima@openbossa.org>
    225
  • trunk/Source/WebKit2/Platform/unix/SharedMemoryUnix.cpp

    r95901 r102493  
    106106{
    107107#if PLATFORM(QT)
    108     QString tempName = QDir::temp().filePath(QLatin1String("qwkshm.XXXXXX"));
    109     QByteArray tempNameCSTR = tempName.toLocal8Bit();
     108    QByteArray tempNameCSTR("/qwkshm.");
     109    tempNameCSTR += QByteArray::number(qrand(), 36);
    110110    char* tempNameC = tempNameCSTR.data();
    111111#elif PLATFORM(GTK)
     
    115115
    116116    int fileDescriptor;
     117#if PLATFORM(QT)
     118    while ((fileDescriptor = shm_open(tempNameC, O_CREAT | O_CLOEXEC | O_RDWR, S_IRUSR | S_IWUSR)) == -1) {
     119        if (errno != EINTR)
     120            return 0;
     121    }
     122#else
    117123    while ((fileDescriptor = mkstemp(tempNameC)) == -1) {
    118124        if (errno != EINTR)
     
    126132        }
    127133    }
    128 
     134#endif
    129135    while (ftruncate(fileDescriptor, size) == -1) {
    130136        if (errno != EINTR) {
    131137            while (close(fileDescriptor) == -1 && errno == EINTR) { }
     138#if PLATFORM(QT)
     139            shm_unlink(tempNameC);
     140#else
    132141            unlink(tempNameC);
     142#endif
    133143            return 0;
    134144        }
     
    138148    if (data == MAP_FAILED) {
    139149        while (close(fileDescriptor) == -1 && errno == EINTR) { }
     150#if PLATFORM(QT)
     151        shm_unlink(tempNameC);
     152#else
    140153        unlink(tempNameC);
     154#endif
    141155        return 0;
    142156    }
    143157
     158#if PLATFORM(QT)
     159    shm_unlink(tempNameC);
     160#else
    144161    unlink(tempNameC);
     162#endif
    145163
    146164    RefPtr<SharedMemory> instance = adoptRef(new SharedMemory());
Note: See TracChangeset for help on using the changeset viewer.