mirror of
https://github.com/sogou/workflow.git
synced 2026-02-08 01:33:17 +08:00
Make sure WFServer's new_connection() returns a WFConnection, and protect CommConnection.
This commit is contained in:
@@ -31,8 +31,9 @@
|
||||
|
||||
class CommConnection
|
||||
{
|
||||
public:
|
||||
protected:
|
||||
virtual ~CommConnection() { }
|
||||
friend class Communicator;
|
||||
};
|
||||
|
||||
class CommTarget
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
int state;
|
||||
|
||||
private:
|
||||
virtual CommConnection *new_connection(int)
|
||||
virtual WFConnection *new_connection(int connect_fd)
|
||||
{
|
||||
return new WFConnection;
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
#include "WFMySQLServer.h"
|
||||
|
||||
CommConnection *WFMySQLServer::new_connection(int accept_fd)
|
||||
WFConnection *WFMySQLServer::new_connection(int accept_fd)
|
||||
{
|
||||
CommConnection *conn = this->WFServer::new_connection(accept_fd);
|
||||
WFConnection *conn = this->WFServer::new_connection(accept_fd);
|
||||
|
||||
if (conn)
|
||||
{
|
||||
@@ -37,7 +37,7 @@ CommConnection *WFMySQLServer::new_connection(int accept_fd)
|
||||
return conn;
|
||||
}
|
||||
|
||||
delete conn;
|
||||
this->delete_connection(conn);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual CommConnection *new_connection(int accept_fd);
|
||||
virtual WFConnection *new_connection(int accept_fd);
|
||||
virtual CommSession *new_session(long long seq, CommConnection *conn);
|
||||
};
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ int WFServerBase::create_listen_fd()
|
||||
return listen_fd;
|
||||
}
|
||||
|
||||
CommConnection *WFServerBase::new_connection(int accept_fd)
|
||||
WFConnection *WFServerBase::new_connection(int accept_fd)
|
||||
{
|
||||
if (++this->conn_count <= this->params.max_connections ||
|
||||
this->drain(1) == 1)
|
||||
@@ -150,6 +150,11 @@ CommConnection *WFServerBase::new_connection(int accept_fd)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void WFServerBase::delete_connection(WFConnection *conn)
|
||||
{
|
||||
delete (WFServerConnection *)conn;
|
||||
}
|
||||
|
||||
void WFServerBase::handle_unbound()
|
||||
{
|
||||
this->mutex.lock();
|
||||
|
||||
@@ -158,7 +158,8 @@ protected:
|
||||
WFServerParams params;
|
||||
|
||||
protected:
|
||||
virtual CommConnection *new_connection(int accept_fd);
|
||||
virtual WFConnection *new_connection(int accept_fd);
|
||||
void delete_connection(WFConnection *conn);
|
||||
|
||||
private:
|
||||
int init(const struct sockaddr *bind_addr, socklen_t addrlen,
|
||||
|
||||
Reference in New Issue
Block a user