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:
Clemens Zeidler 2011-03-10 01:31:33 +00:00
parent 7aafe6e5e7
commit 8b254785bb
3 changed files with 11 additions and 8 deletions

View File

@ -127,7 +127,7 @@ IMAPMailbox::StartWatchingMailbox()
//TODO set it when we actually watching
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
status_t status;
while (true) {
@ -136,7 +136,7 @@ IMAPMailbox::StartWatchingMailbox()
status = SendCommand("IDLE", commandId);
if (status != B_OK)
break;
status = HandleResponse(commandId, timeout);
status = HandleResponse(commandId, timeout, false);
ProcessAfterQuacks(kIMAP4ClientTimeout);
if (atomic_get(&fWatching) == 0)

View File

@ -303,7 +303,7 @@ IMAPProtocol::SendCommand(const char* command, int32 commandId)
status_t
IMAPProtocol::HandleResponse(int32 commandId, bigtime_t timeout)
IMAPProtocol::HandleResponse(int32 commandId, bigtime_t timeout, bool disconnectOnTimeout)
{
status_t commandStatus = B_ERROR;
@ -312,11 +312,13 @@ IMAPProtocol::HandleResponse(int32 commandId, bigtime_t timeout)
BString line;
status_t status = fConnectionReader.GetNextLine(line, timeout);
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
TRACE("Disconnect\n");
_Disconnect();
if (status != B_TIMED_OUT) {
TRACE("S:read error %s", line.String());
_Disconnect();
} else if (disconnectOnTimeout) {
_Disconnect();
}
return status;
}
//TRACE("S: %s", line.String());

View File

@ -94,7 +94,8 @@ protected:
status_t SendCommand(const char* command,
int32 commandId);
status_t HandleResponse(int32 commandId,
bigtime_t timeout = kIMAP4ClientTimeout);
bigtime_t timeout = kIMAP4ClientTimeout,
bool disconnectOnTimeout = true);
void ProcessAfterQuacks(bigtime_t timeout);
int32 NextCommandId();