Changeset 646 for trunk/src


Ignore:
Timestamp:
Mar 7, 2010, 9:17:02 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

corelib: QProcess: Fixed a problem that, depending on the order of events, could cause a failure to write to the standard input channel of the started process (accompanied by an assertion in QProcessPrivate::writeToStdin() in debug mode).

Location:
trunk/src/corelib/io
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/corelib/io/qprocess.cpp

    r600 r646  
    18161816#endif
    18171817#if defined(Q_OS_OS2)
    1818         qint64 available = d->bytesAvailableInStdin();
    1819         if (available > 0)
    1820             d->_q_canWrite();
     1818        // try to write some bytes (there may be space in the pipe)
     1819        d->_q_canWrite();
    18211820#endif
    18221821        return 1;
     
    18321831#endif
    18331832#if defined(Q_OS_OS2)
    1834         qint64 available = d->bytesAvailableInStdin();
    1835         if (available > 0)
    1836             d->_q_canWrite();
     1833        // try to write some bytes (there may be space in the pipe)
     1834        d->_q_canWrite();
    18371835#endif
    18381836    return len;
  • trunk/src/corelib/io/qprocess_os2.cpp

    r645 r646  
    13141314    }
    13151315
    1316     that->pipeData[OutPipe].bytesLeft += newBytes;
     1316    if (newBytes)
     1317        that->pipeData[OutPipe].bytesLeft = newBytes;
    13171318
    13181319#if defined (QPROCESS_DEBUG)
     
    13481349    }
    13491350
    1350     that->pipeData[ErrPipe].bytesLeft += newBytes;
     1351    if (newBytes)
     1352        that->pipeData[ErrPipe].bytesLeft = newBytes;
    13511353
    13521354#if defined (QPROCESS_DEBUG)
     
    13551357#endif
    13561358    return that->pipeData[ErrPipe].bytesLeft;
    1357 }
    1358 
    1359 qint64 QProcessPrivate::bytesAvailableInStdin() const
    1360 {
    1361     QProcessPrivate* that = const_cast<QProcessPrivate*>(this);
    1362 
    1363     // grab new bytes from QProcessManager (if any)
    1364     int newBytes = that->pipeData[InPipe].newBytes.fetchAndStoreRelaxed(0);
    1365     that->pipeData[InPipe].bytesLeft += newBytes;
    1366 
    1367 #if defined (QPROCESS_DEBUG)
    1368     qDebug("QProcessPrivate::bytesAvailableInStdin() == %lld",
    1369            that->pipeData[InPipe].bytesLeft);
    1370 #endif
    1371     return that->pipeData[InPipe].bytesLeft;
    13721359}
    13731360
     
    14141401qint64 QProcessPrivate::writeToStdin(const char *data, qint64 maxlen)
    14151402{
     1403    QProcessPrivate* that = const_cast<QProcessPrivate*>(this);
     1404
     1405    // grab new bytes from QProcessManager (if any)
     1406    int newBytes = that->pipeData[InPipe].newBytes.fetchAndStoreRelaxed(0);
     1407    if (newBytes)
     1408        that->pipeData[InPipe].bytesLeft = newBytes;
     1409
     1410#if defined (QPROCESS_DEBUG)
     1411    qDebug("QProcessPrivate::writeToStdin(): %lld free bytes in pipe",
     1412           that->pipeData[InPipe].bytesLeft);
     1413#endif
     1414    if (!that->pipeData[InPipe].bytesLeft)
     1415        return 0;
     1416
    14161417    ULONG actual = 0;
    14171418    APIRET arc = DosWrite(stdinChannel.pipe.server, data, maxlen, &actual);
  • trunk/src/corelib/io/qprocess_p.h

    r561 r646  
    271271    qint64 bytesAvailableFromStdout() const;
    272272    qint64 bytesAvailableFromStderr() const;
    273 #if defined(Q_OS_OS2)
    274     qint64 bytesAvailableInStdin() const;
    275 #endif
     273
    276274    qint64 readFromStdout(char *data, qint64 maxlen);
    277275    qint64 readFromStderr(char *data, qint64 maxlen);
Note: See TracChangeset for help on using the changeset viewer.