1
This commit is contained in:
parent
9487d93b32
commit
a61719966e
@ -27,7 +27,7 @@ void UpStream::Init(int instance_id, const std::string& remote_ip, int remote_po
|
||||
recv_bufflen_ = 0;
|
||||
last_pong_tick = a8::XGetTickCount();
|
||||
recv_buff_ = (char*) malloc(PACK_MAX * 2);
|
||||
tcp_client_ = new a8::TcpClient();
|
||||
tcp_client_ = std::make_shared<a8::TcpClient>();
|
||||
tcp_client_->remote_address = remote_ip;
|
||||
tcp_client_->remote_port = remote_port;
|
||||
tcp_client_->on_error = std::bind(&UpStream::on_error, this, std::placeholders::_1, std::placeholders::_2);
|
||||
@ -63,7 +63,9 @@ void UpStream::UnInit()
|
||||
timer_ = nullptr;
|
||||
#endif
|
||||
tcp_client_->Close();
|
||||
delete tcp_client_;
|
||||
if(tcp_client_.use_count() != 1) {
|
||||
abort();
|
||||
}
|
||||
tcp_client_ = nullptr;
|
||||
recv_bufflen_ = 0;
|
||||
free(recv_buff_);
|
||||
@ -96,7 +98,7 @@ void UpStream::SendStockMsg()
|
||||
work_node = work_node->next_node;
|
||||
|
||||
if (pdelnode->msg) {
|
||||
f8::Net_SendProxyCMsg(tcp_client_, pdelnode->socket_handle, pdelnode->msgid, *pdelnode->msg);
|
||||
f8::Net_SendProxyCMsg(tcp_client_.get(), pdelnode->socket_handle, pdelnode->msgid, *pdelnode->msg);
|
||||
delete pdelnode->msg;
|
||||
}
|
||||
if (pdelnode->hdr) {
|
||||
|
@ -42,7 +42,7 @@ class UpStream
|
||||
if (top_node_) {
|
||||
SendStockMsg();
|
||||
}
|
||||
f8::Net_SendProxyCMsg(tcp_client_, socket_handle, msgid, msg);
|
||||
f8::Net_SendProxyCMsg(tcp_client_.get(), socket_handle, msgid, msg);
|
||||
} else {
|
||||
T* new_msg = new T();
|
||||
*new_msg = msg;
|
||||
@ -67,7 +67,7 @@ class UpStream
|
||||
private:
|
||||
char *recv_buff_ = nullptr;
|
||||
unsigned int recv_bufflen_ = 0;
|
||||
a8::TcpClient* tcp_client_ = nullptr;
|
||||
std::shared_ptr<a8::TcpClient> tcp_client_;
|
||||
timer_list* timer_ = nullptr;
|
||||
|
||||
UpStreamMsgNode* top_node_ = nullptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user