mirror of https://github.com/procxx/kepka.git
fixing http-transport crash
This commit is contained in:
parent
3ce8d9f0b7
commit
e97cc9f172
|
@ -677,8 +677,16 @@ namespace MTP {
|
||||||
void killSession(int32 dc) {
|
void killSession(int32 dc) {
|
||||||
Sessions::iterator i = sessions.find(dc);
|
Sessions::iterator i = sessions.find(dc);
|
||||||
if (i != sessions.end()) {
|
if (i != sessions.end()) {
|
||||||
|
bool wasMain = (i.value() == mainSession);
|
||||||
|
|
||||||
i.value()->stop();
|
i.value()->stop();
|
||||||
sessions.erase(i);
|
sessions.erase(i);
|
||||||
|
|
||||||
|
if (wasMain) {
|
||||||
|
mainSession = MTProtoSessionPtr(new MTProtoSession());
|
||||||
|
mainSession->start(mtpMainDC());
|
||||||
|
sessions[mainSession->getDC()] = mainSession;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -298,16 +298,16 @@ int32 MTProtoConnection::start(MTPSessionData *sessionData, int32 dc) {
|
||||||
|
|
||||||
dc = data->getDC();
|
dc = data->getDC();
|
||||||
if (!dc) {
|
if (!dc) {
|
||||||
|
delete data;
|
||||||
|
delete thread;
|
||||||
|
data = 0;
|
||||||
|
thread = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
thread->start();
|
thread->start();
|
||||||
return dc;
|
return dc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MTProtoConnection::restart() {
|
|
||||||
emit data->needToRestart();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MTProtoConnection::stop() {
|
void MTProtoConnection::stop() {
|
||||||
if (data) data->stop();
|
if (data) data->stop();
|
||||||
if (thread) thread->quit();
|
if (thread) thread->quit();
|
||||||
|
@ -318,6 +318,7 @@ void MTProtoConnection::stopped() {
|
||||||
if (data) data->deleteLater();
|
if (data) data->deleteLater();
|
||||||
thread = 0;
|
thread = 0;
|
||||||
data = 0;
|
data = 0;
|
||||||
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 MTProtoConnection::state() const {
|
int32 MTProtoConnection::state() const {
|
||||||
|
@ -1107,20 +1108,20 @@ MTProtoConnectionPrivate::MTProtoConnectionPrivate(QThread *thread, MTProtoConne
|
||||||
|
|
||||||
connect(thread, SIGNAL(started()), this, SLOT(socketStart()));
|
connect(thread, SIGNAL(started()), this, SLOT(socketStart()));
|
||||||
connect(thread, SIGNAL(finished()), this, SLOT(doFinish()));
|
connect(thread, SIGNAL(finished()), this, SLOT(doFinish()));
|
||||||
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
|
||||||
|
|
||||||
connect(&retryTimer, SIGNAL(timeout()), this, SLOT(retryByTimer()));
|
connect(&retryTimer, SIGNAL(timeout()), this, SLOT(retryByTimer()));
|
||||||
connect(&connCheckTimer, SIGNAL(timeout()), this, SLOT(onBadConnection()));
|
connect(&connCheckTimer, SIGNAL(timeout()), this, SLOT(onBadConnection()));
|
||||||
connect(&oldConnectionTimer, SIGNAL(timeout()), this, SLOT(onOldConnection()));
|
connect(&oldConnectionTimer, SIGNAL(timeout()), this, SLOT(onOldConnection()));
|
||||||
connect(sessionData->owner(), SIGNAL(authKeyCreated()), this, SLOT(updateAuthKey()));
|
connect(sessionData->owner(), SIGNAL(authKeyCreated()), this, SLOT(updateAuthKey()), Qt::QueuedConnection);
|
||||||
|
|
||||||
connect(this, SIGNAL(needToRestart()), this, SLOT(restartNow()));
|
connect(sessionData->owner(), SIGNAL(needToRestart()), this, SLOT(restartNow()), Qt::QueuedConnection);
|
||||||
connect(this, SIGNAL(needToReceive()), sessionData->owner(), SLOT(tryToReceive()));
|
connect(this, SIGNAL(needToReceive()), sessionData->owner(), SLOT(tryToReceive()), Qt::QueuedConnection);
|
||||||
connect(this, SIGNAL(stateChanged(qint32)), sessionData->owner(), SLOT(onConnectionStateChange(qint32)));
|
connect(this, SIGNAL(stateChanged(qint32)), sessionData->owner(), SLOT(onConnectionStateChange(qint32)), Qt::QueuedConnection);
|
||||||
connect(sessionData->owner(), SIGNAL(needToSend()), this, SLOT(tryToSend()));
|
connect(sessionData->owner(), SIGNAL(needToSend()), this, SLOT(tryToSend()), Qt::QueuedConnection);
|
||||||
connect(this, SIGNAL(needToSendAsync()), sessionData->owner(), SIGNAL(needToSend()));
|
connect(this, SIGNAL(needToSendAsync()), sessionData->owner(), SIGNAL(needToSend()), Qt::QueuedConnection);
|
||||||
connect(this, SIGNAL(sessionResetDone()), sessionData->owner(), SLOT(onResetDone()));
|
connect(this, SIGNAL(sendHttpWait()), sessionData->owner(), SLOT(sendHttpWait()), Qt::QueuedConnection);
|
||||||
connect(this, SIGNAL(sendAnythingAsync(quint64)), sessionData->owner(), SLOT(sendAnything(quint64)));
|
connect(this, SIGNAL(sessionResetDone()), sessionData->owner(), SLOT(onResetDone()), Qt::QueuedConnection);
|
||||||
|
connect(this, SIGNAL(sendAnythingAsync(quint64)), sessionData->owner(), SLOT(sendAnything(quint64)), Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MTProtoConnectionPrivate::onConfigLoaded() {
|
void MTProtoConnectionPrivate::onConfigLoaded() {
|
||||||
|
@ -1986,7 +1987,7 @@ void MTProtoConnectionPrivate::handleReceived() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (conn->needHttpWait()) {
|
if (conn->needHttpWait()) {
|
||||||
sessionData->owner()->send(MTPHttpWait(MTP_http_wait(MTP_int(100), MTP_int(30), MTP_int(25000))));
|
emit sendHttpWait();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3399,5 +3400,4 @@ void MTProtoConnectionPrivate::stop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
MTProtoConnection::~MTProtoConnection() {
|
MTProtoConnection::~MTProtoConnection() {
|
||||||
stopped();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,6 @@ public:
|
||||||
|
|
||||||
MTProtoConnection();
|
MTProtoConnection();
|
||||||
int32 start(MTPSessionData *data, int32 dc = 0); // return dc
|
int32 start(MTPSessionData *data, int32 dc = 0); // return dc
|
||||||
void restart();
|
|
||||||
void stop();
|
void stop();
|
||||||
void stopped();
|
void stopped();
|
||||||
~MTProtoConnection();
|
~MTProtoConnection();
|
||||||
|
@ -312,6 +311,8 @@ signals:
|
||||||
void needToSendAsync();
|
void needToSendAsync();
|
||||||
void sendAnythingAsync(quint64);
|
void sendAnythingAsync(quint64);
|
||||||
|
|
||||||
|
void sendHttpWait();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void retryByTimer();
|
void retryByTimer();
|
||||||
|
|
|
@ -460,7 +460,7 @@ void MTProtoConfigLoader::load() {
|
||||||
void MTProtoConfigLoader::done() {
|
void MTProtoConfigLoader::done() {
|
||||||
_enumDCTimer.stop();
|
_enumDCTimer.stop();
|
||||||
if (_enumRequest) MTP::cancel(_enumRequest);
|
if (_enumRequest) MTP::cancel(_enumRequest);
|
||||||
if (_enumCurrent) MTP::killSession(_enumCurrent);
|
if (_enumCurrent) MTP::killSession(MTP::cfg + _enumCurrent);
|
||||||
emit loaded();
|
emit loaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,9 +120,7 @@ void MTProtoSession::start(int32 dcenter, uint32 connects) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MTProtoSession::restart() {
|
void MTProtoSession::restart() {
|
||||||
for (MTProtoConnections::const_iterator i = connections.cbegin(), e = connections.cend(); i != e; ++i) {
|
emit needToRestart();
|
||||||
(*i)->restart();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MTProtoSession::stop() {
|
void MTProtoSession::stop() {
|
||||||
|
@ -158,6 +156,10 @@ void MTProtoSession::sendAnything(quint64 msCanWait) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MTProtoSession::sendHttpWait() {
|
||||||
|
send(MTPHttpWait(MTP_http_wait(MTP_int(100), MTP_int(30), MTP_int(25000))), RPCResponseHandler(), 50);
|
||||||
|
}
|
||||||
|
|
||||||
void MTProtoSession::checkRequestsByTimer() {
|
void MTProtoSession::checkRequestsByTimer() {
|
||||||
QVector<mtpMsgId> resendingIds;
|
QVector<mtpMsgId> resendingIds;
|
||||||
QVector<mtpMsgId> removingIds; // remove very old (10 minutes) containers and resend requests
|
QVector<mtpMsgId> removingIds; // remove very old (10 minutes) containers and resend requests
|
||||||
|
|
|
@ -250,8 +250,8 @@ public:
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void authKeyCreated();
|
void authKeyCreated();
|
||||||
|
|
||||||
void needToSend();
|
void needToSend();
|
||||||
|
void needToRestart();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
@ -265,6 +265,8 @@ public slots:
|
||||||
|
|
||||||
void sendAnything(quint64 msCanWait);
|
void sendAnything(quint64 msCanWait);
|
||||||
|
|
||||||
|
void sendHttpWait();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
typedef QList<MTProtoConnection*> MTProtoConnections;
|
typedef QList<MTProtoConnection*> MTProtoConnections;
|
||||||
|
|
Loading…
Reference in New Issue