Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Unmaintained
KDE Pim Libraries
Commits
2bc7588f
Commit
2bc7588f
authored
Feb 11, 2012
by
Kevin Ottens
Browse files
Handle properly inconsistent parser state by closing the session
BUG: 287424
parent
802926e0
Changes
2
Hide whitespace changes
Inline
Side-by-side
kimap/sessionthread.cpp
View file @
2bc7588f
...
...
@@ -107,8 +107,11 @@ void SessionThread::readMessage()
}
*
payload
<<
Message
::
Part
(
literal
);
}
else
{
// Oops! Something really bad happened
throw
ImapParserException
(
"Inconsistent state, probably due to some packet loss"
);
// Oops! Something really bad happened, we won't be able to recover
// so close the socket immediately
qWarning
(
"Inconsistent state, probably due to some packet loss"
);
doCloseSocket
();
return
;
}
}
...
...
kimap/tests/testsession.cpp
View file @
2bc7588f
...
...
@@ -309,6 +309,39 @@ class SessionTest : public QObject
QCOMPARE
(
s
.
jobQueueSize
(),
0
);
}
void
shouldCloseOnInconsistency
()
{
for
(
int
count
=
0
;
count
<
10
;
count
++
)
{
FakeServer
fakeServer
;
fakeServer
.
setScenario
(
QList
<
QByteArray
>
()
<<
FakeServer
::
preauth
()
<<
"C: A000001 DUMMY"
<<
"S: * DUMMY %"
<<
"S: DUMMY)"
);
fakeServer
.
startAndWait
();
KIMAP
::
Session
s
(
"127.0.0.1"
,
5989
);
QSignalSpy
spyFail
(
&
s
,
SIGNAL
(
connectionFailed
()));
QSignalSpy
spyLost
(
&
s
,
SIGNAL
(
connectionLost
()));
QSignalSpy
spyState
(
&
s
,
SIGNAL
(
stateChanged
(
KIMAP
::
Session
::
State
,
KIMAP
::
Session
::
State
)));
MockJob
*
mock
=
new
MockJob
(
&
s
);
mock
->
setTimeout
(
5000
);
mock
->
setCommand
(
"DUMMY"
);
mock
->
start
();
QTest
::
qWait
(
250
);
// Should be plenty
// We expect to get an error here due to the inconsistency
QVERIFY
(
mock
->
error
()
!=
0
);
QCOMPARE
(
spyFail
.
count
(),
0
);
QCOMPARE
(
spyLost
.
count
(),
1
);
QCOMPARE
(
spyState
.
count
(),
2
);
// Authenticated, Disconnected
}
}
public
slots
:
void
jobDone
(
KJob
*
job
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment