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;
|
recv_bufflen_ = 0;
|
||||||
last_pong_tick = a8::XGetTickCount();
|
last_pong_tick = a8::XGetTickCount();
|
||||||
recv_buff_ = (char*) malloc(PACK_MAX * 2);
|
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_address = remote_ip;
|
||||||
tcp_client_->remote_port = remote_port;
|
tcp_client_->remote_port = remote_port;
|
||||||
tcp_client_->on_error = std::bind(&UpStream::on_error, this, std::placeholders::_1, std::placeholders::_2);
|
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;
|
timer_ = nullptr;
|
||||||
#endif
|
#endif
|
||||||
tcp_client_->Close();
|
tcp_client_->Close();
|
||||||
delete tcp_client_;
|
if(tcp_client_.use_count() != 1) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
tcp_client_ = nullptr;
|
tcp_client_ = nullptr;
|
||||||
recv_bufflen_ = 0;
|
recv_bufflen_ = 0;
|
||||||
free(recv_buff_);
|
free(recv_buff_);
|
||||||
@ -96,7 +98,7 @@ void UpStream::SendStockMsg()
|
|||||||
work_node = work_node->next_node;
|
work_node = work_node->next_node;
|
||||||
|
|
||||||
if (pdelnode->msg) {
|
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;
|
delete pdelnode->msg;
|
||||||
}
|
}
|
||||||
if (pdelnode->hdr) {
|
if (pdelnode->hdr) {
|
||||||
|
@ -42,7 +42,7 @@ class UpStream
|
|||||||
if (top_node_) {
|
if (top_node_) {
|
||||||
SendStockMsg();
|
SendStockMsg();
|
||||||
}
|
}
|
||||||
f8::Net_SendProxyCMsg(tcp_client_, socket_handle, msgid, msg);
|
f8::Net_SendProxyCMsg(tcp_client_.get(), socket_handle, msgid, msg);
|
||||||
} else {
|
} else {
|
||||||
T* new_msg = new T();
|
T* new_msg = new T();
|
||||||
*new_msg = msg;
|
*new_msg = msg;
|
||||||
@ -67,7 +67,7 @@ class UpStream
|
|||||||
private:
|
private:
|
||||||
char *recv_buff_ = nullptr;
|
char *recv_buff_ = nullptr;
|
||||||
unsigned int recv_bufflen_ = 0;
|
unsigned int recv_bufflen_ = 0;
|
||||||
a8::TcpClient* tcp_client_ = nullptr;
|
std::shared_ptr<a8::TcpClient> tcp_client_;
|
||||||
timer_list* timer_ = nullptr;
|
timer_list* timer_ = nullptr;
|
||||||
|
|
||||||
UpStreamMsgNode* top_node_ = nullptr;
|
UpStreamMsgNode* top_node_ = nullptr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user