BUG: Fixed polling feature of WaitForData.
This commit is contained in:
parent
28ffc134a0
commit
5df6d35dc6
|
@ -101,6 +101,7 @@ static void kwsysProcessCleanErrorMessage(kwsysProcess* cp);
|
||||||
static int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout,
|
static int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout,
|
||||||
kwsysProcessTime* timeoutTime);
|
kwsysProcessTime* timeoutTime);
|
||||||
static int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
|
static int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
|
||||||
|
double* userTimeout,
|
||||||
kwsysProcessTime* timeoutLength);
|
kwsysProcessTime* timeoutLength);
|
||||||
static kwsysProcessTime kwsysProcessTimeGetCurrent();
|
static kwsysProcessTime kwsysProcessTimeGetCurrent();
|
||||||
static DWORD kwsysProcessTimeToDWORD(kwsysProcessTime t);
|
static DWORD kwsysProcessTimeToDWORD(kwsysProcessTime t);
|
||||||
|
@ -1300,7 +1301,8 @@ int kwsysProcess_WaitForData(kwsysProcess* cp, char** data, int* length,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Setup a timeout if required. */
|
/* Setup a timeout if required. */
|
||||||
if(kwsysProcessGetTimeoutLeft(&timeoutTime, &timeoutLength))
|
if(kwsysProcessGetTimeoutLeft(&timeoutTime, user?userTimeout:0,
|
||||||
|
&timeoutLength))
|
||||||
{
|
{
|
||||||
/* Timeout has already expired. */
|
/* Timeout has already expired. */
|
||||||
expired = 1;
|
expired = 1;
|
||||||
|
@ -2122,7 +2124,8 @@ int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout,
|
||||||
kwsysProcessTime userTimeoutLength = kwsysProcessTimeFromDouble(*userTimeout);
|
kwsysProcessTime userTimeoutLength = kwsysProcessTimeFromDouble(*userTimeout);
|
||||||
kwsysProcessTime userTimeoutTime = kwsysProcessTimeAdd(currentTime,
|
kwsysProcessTime userTimeoutTime = kwsysProcessTimeAdd(currentTime,
|
||||||
userTimeoutLength);
|
userTimeoutLength);
|
||||||
if(kwsysProcessTimeLess(userTimeoutTime, *timeoutTime))
|
if(timeoutTime->QuadPart < 0 ||
|
||||||
|
kwsysProcessTimeLess(userTimeoutTime, *timeoutTime))
|
||||||
{
|
{
|
||||||
*timeoutTime = userTimeoutTime;
|
*timeoutTime = userTimeoutTime;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -2135,6 +2138,7 @@ int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout,
|
||||||
/* Get the length of time before the given timeout time arrives.
|
/* Get the length of time before the given timeout time arrives.
|
||||||
Returns 1 if the time has already arrived, and 0 otherwise. */
|
Returns 1 if the time has already arrived, and 0 otherwise. */
|
||||||
int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
|
int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
|
||||||
|
double* userTimeout,
|
||||||
kwsysProcessTime* timeoutLength)
|
kwsysProcessTime* timeoutLength)
|
||||||
{
|
{
|
||||||
if(timeoutTime->QuadPart < 0)
|
if(timeoutTime->QuadPart < 0)
|
||||||
|
@ -2147,6 +2151,13 @@ int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
|
||||||
/* Calculate the remaining time. */
|
/* Calculate the remaining time. */
|
||||||
kwsysProcessTime currentTime = kwsysProcessTimeGetCurrent();
|
kwsysProcessTime currentTime = kwsysProcessTimeGetCurrent();
|
||||||
*timeoutLength = kwsysProcessTimeSubtract(*timeoutTime, currentTime);
|
*timeoutLength = kwsysProcessTimeSubtract(*timeoutTime, currentTime);
|
||||||
|
|
||||||
|
if(timeoutLength->QuadPart < 0 && userTimeout && *userTimeout <= 0)
|
||||||
|
{
|
||||||
|
/* Caller has explicitly requested a zero timeout. */
|
||||||
|
timeoutLength->QuadPart = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(timeoutLength->QuadPart < 0)
|
if(timeoutLength->QuadPart < 0)
|
||||||
{
|
{
|
||||||
/* Timeout has already expired. */
|
/* Timeout has already expired. */
|
||||||
|
|
Loading…
Reference in New Issue