The IDLE watching command is supposed to timeout after 29 min if nothing happens. Add an mechanism to not treat this timeout as an
error. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40894 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -127,7 +127,7 @@ IMAPMailbox::StartWatchingMailbox()
|
|||||||
//TODO set it when we actually watching
|
//TODO set it when we actually watching
|
||||||
atomic_set(&fWatching, 1);
|
atomic_set(&fWatching, 1);
|
||||||
|
|
||||||
// refresh every 29 min TODO: check if it works this way
|
// refresh every 29 min
|
||||||
bigtime_t timeout = 1000 * 1000 * 60 * 29; // 29 min
|
bigtime_t timeout = 1000 * 1000 * 60 * 29; // 29 min
|
||||||
status_t status;
|
status_t status;
|
||||||
while (true) {
|
while (true) {
|
||||||
@@ -136,7 +136,7 @@ IMAPMailbox::StartWatchingMailbox()
|
|||||||
status = SendCommand("IDLE", commandId);
|
status = SendCommand("IDLE", commandId);
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
break;
|
break;
|
||||||
status = HandleResponse(commandId, timeout);
|
status = HandleResponse(commandId, timeout, false);
|
||||||
ProcessAfterQuacks(kIMAP4ClientTimeout);
|
ProcessAfterQuacks(kIMAP4ClientTimeout);
|
||||||
|
|
||||||
if (atomic_get(&fWatching) == 0)
|
if (atomic_get(&fWatching) == 0)
|
||||||
|
|||||||
@@ -303,7 +303,7 @@ IMAPProtocol::SendCommand(const char* command, int32 commandId)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
IMAPProtocol::HandleResponse(int32 commandId, bigtime_t timeout)
|
IMAPProtocol::HandleResponse(int32 commandId, bigtime_t timeout, bool disconnectOnTimeout)
|
||||||
{
|
{
|
||||||
status_t commandStatus = B_ERROR;
|
status_t commandStatus = B_ERROR;
|
||||||
|
|
||||||
@@ -312,11 +312,13 @@ IMAPProtocol::HandleResponse(int32 commandId, bigtime_t timeout)
|
|||||||
BString line;
|
BString line;
|
||||||
status_t status = fConnectionReader.GetNextLine(line, timeout);
|
status_t status = fConnectionReader.GetNextLine(line, timeout);
|
||||||
if (status != B_OK) {
|
if (status != B_OK) {
|
||||||
if (status != B_TIMED_OUT)
|
|
||||||
TRACE("S:read error %s", line.String());
|
|
||||||
// we might lost the connection, clear the connection state
|
// we might lost the connection, clear the connection state
|
||||||
TRACE("Disconnect\n");
|
if (status != B_TIMED_OUT) {
|
||||||
_Disconnect();
|
TRACE("S:read error %s", line.String());
|
||||||
|
_Disconnect();
|
||||||
|
} else if (disconnectOnTimeout) {
|
||||||
|
_Disconnect();
|
||||||
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
//TRACE("S: %s", line.String());
|
//TRACE("S: %s", line.String());
|
||||||
|
|||||||
@@ -94,7 +94,8 @@ protected:
|
|||||||
status_t SendCommand(const char* command,
|
status_t SendCommand(const char* command,
|
||||||
int32 commandId);
|
int32 commandId);
|
||||||
status_t HandleResponse(int32 commandId,
|
status_t HandleResponse(int32 commandId,
|
||||||
bigtime_t timeout = kIMAP4ClientTimeout);
|
bigtime_t timeout = kIMAP4ClientTimeout,
|
||||||
|
bool disconnectOnTimeout = true);
|
||||||
void ProcessAfterQuacks(bigtime_t timeout);
|
void ProcessAfterQuacks(bigtime_t timeout);
|
||||||
int32 NextCommandId();
|
int32 NextCommandId();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user