From dcb95ec1473eff3f455909cd81c3cd50b1e1159b Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 14 Jan 2017 11:07:57 -0300 Subject: removed duplicated functions in class hierarchy that were bound more than once added a check to detect this case in the future --- drivers/unix/stream_peer_tcp_posix.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'drivers/unix/stream_peer_tcp_posix.cpp') diff --git a/drivers/unix/stream_peer_tcp_posix.cpp b/drivers/unix/stream_peer_tcp_posix.cpp index f2a1417920..b494de6744 100644 --- a/drivers/unix/stream_peer_tcp_posix.cpp +++ b/drivers/unix/stream_peer_tcp_posix.cpp @@ -139,14 +139,14 @@ void StreamPeerTCPPosix::set_socket(int p_sockfd, IP_Address p_host, int p_port, peer_port = p_port; }; -Error StreamPeerTCPPosix::connect(const IP_Address& p_host, uint16_t p_port) { +Error StreamPeerTCPPosix::connect_to_host(const IP_Address& p_host, uint16_t p_port) { ERR_FAIL_COND_V( p_host == IP_Address(), ERR_INVALID_PARAMETER); sockfd = _socket_create(ip_type, SOCK_STREAM, IPPROTO_TCP); if (sockfd == -1) { ERR_PRINT("Socket creation failed!"); - disconnect(); + disconnect_from_host(); //perror("socket"); return FAILED; }; @@ -165,7 +165,7 @@ Error StreamPeerTCPPosix::connect(const IP_Address& p_host, uint16_t p_port) { if (::connect(sockfd, (struct sockaddr *)&their_addr,addr_size) == -1 && errno != EINPROGRESS) { ERR_PRINT("Connection to remote host failed!"); - disconnect(); + disconnect_from_host(); return FAILED; }; @@ -217,8 +217,8 @@ Error StreamPeerTCPPosix::write(const uint8_t* p_data,int p_bytes, int &r_sent, if (errno != EAGAIN) { perror("shit?"); - disconnect(); - ERR_PRINT("Server disconnected!\n"); + disconnect_from_host(); + ERR_PRINT("Server disconnect_from_hosted!\n"); return FAILED; }; @@ -243,7 +243,7 @@ Error StreamPeerTCPPosix::write(const uint8_t* p_data,int p_bytes, int &r_sent, Error StreamPeerTCPPosix::read(uint8_t* p_buffer, int p_bytes,int &r_received, bool p_block) { - if (!is_connected()) { + if (!is_connected_to_host()) { return FAILED; }; @@ -274,8 +274,8 @@ Error StreamPeerTCPPosix::read(uint8_t* p_buffer, int p_bytes,int &r_received, b if (errno != EAGAIN) { perror("shit?"); - disconnect(); - ERR_PRINT("Server disconnected!\n"); + disconnect_from_host(); + ERR_PRINT("Server disconnect_from_hosted!\n"); return FAILED; }; @@ -308,12 +308,12 @@ Error StreamPeerTCPPosix::read(uint8_t* p_buffer, int p_bytes,int &r_received, b void StreamPeerTCPPosix::set_nodelay(bool p_enabled) { - ERR_FAIL_COND(!is_connected()); + ERR_FAIL_COND(!is_connected_to_host()); int flag=p_enabled?1:0; setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (char*)&flag, sizeof(int)); } -bool StreamPeerTCPPosix::is_connected() const { +bool StreamPeerTCPPosix::is_connected_to_host() const { if (status == STATUS_NONE || status == STATUS_ERROR) { @@ -336,7 +336,7 @@ StreamPeerTCP::Status StreamPeerTCPPosix::get_status() const { }; -void StreamPeerTCPPosix::disconnect() { +void StreamPeerTCPPosix::disconnect_from_host() { if (sockfd != -1) close(sockfd); @@ -398,7 +398,7 @@ StreamPeerTCPPosix::StreamPeerTCPPosix() { StreamPeerTCPPosix::~StreamPeerTCPPosix() { - disconnect(); + disconnect_from_host(); }; #endif -- cgit v1.2.3