Browse Source

Socket recreation now uses move semantics instead of reconstruction from scratch.

release/0.19
JustinAJ 11 years ago
parent
commit
bcd562a2e1
  1. 12
      Jupiter/IRC_Client.cpp

12
Jupiter/IRC_Client.cpp

@ -1272,15 +1272,21 @@ void Jupiter::IRC::Client::disconnect(bool stayDead)
bool ssl = Jupiter::IRC::Client::readConfigBool(STRING_LITERAL_AS_REFERENCE("SSL")); bool ssl = Jupiter::IRC::Client::readConfigBool(STRING_LITERAL_AS_REFERENCE("SSL"));
if (ssl != Jupiter::IRC::Client::data_->ssl) if (ssl != Jupiter::IRC::Client::data_->ssl)
{ {
delete Jupiter::IRC::Client::data_->sock;
if (Jupiter::IRC::Client::data_->ssl = ssl) if (Jupiter::IRC::Client::data_->ssl = ssl)
{ {
Jupiter::SecureTCPSocket *t = new Jupiter::SecureTCPSocket(); Jupiter::SecureTCPSocket *t = new Jupiter::SecureTCPSocket(std::move(*Jupiter::IRC::Client::data_->sock));
if (Jupiter::IRC::Client::data_->SSLCertificate.size() != 0) if (Jupiter::IRC::Client::data_->SSLCertificate.size() != 0)
t->setCertificate(Jupiter::IRC::Client::data_->SSLCertificate, Jupiter::IRC::Client::data_->SSLKey); t->setCertificate(Jupiter::IRC::Client::data_->SSLCertificate, Jupiter::IRC::Client::data_->SSLKey);
delete Jupiter::IRC::Client::data_->sock;
Jupiter::IRC::Client::data_->sock = t;
}
else
{
Jupiter::TCPSocket *t = new Jupiter::TCPSocket(std::move(*Jupiter::IRC::Client::data_->sock));
delete Jupiter::IRC::Client::data_->sock;
Jupiter::IRC::Client::data_->sock = t; Jupiter::IRC::Client::data_->sock = t;
} }
else Jupiter::IRC::Client::data_->sock = new Jupiter::TCPSocket();
} }
for (int i = Jupiter::plugins->size() - 1; i >= 0; i--) Jupiter::plugins->get(i)->OnDisconnect(this); for (int i = Jupiter::plugins->size() - 1; i >= 0; i--) Jupiter::plugins->get(i)->OnDisconnect(this);
} }

Loading…
Cancel
Save