MXS-2196: Remove listen entry point from protocol
The entry point was useless as all of the modules called the same function.
This commit is contained in:
@ -301,7 +301,7 @@ uint64_t dcb_get_session_id(DCB* dcb);
|
|||||||
char* dcb_role_name(DCB*); /* Return the name of a role */
|
char* dcb_role_name(DCB*); /* Return the name of a role */
|
||||||
int dcb_accept_SSL(DCB* dcb);
|
int dcb_accept_SSL(DCB* dcb);
|
||||||
int dcb_connect_SSL(DCB* dcb);
|
int dcb_connect_SSL(DCB* dcb);
|
||||||
int dcb_listen(DCB* listener, const char* config, const char* protocol_name);
|
int dcb_listen(DCB* listener, const char* config);
|
||||||
void dcb_enable_session_timeouts();
|
void dcb_enable_session_timeouts();
|
||||||
void dcb_process_idle_sessions(int thr);
|
void dcb_process_idle_sessions(int thr);
|
||||||
|
|
||||||
|
|||||||
@ -118,16 +118,6 @@ typedef struct mxs_protocol
|
|||||||
*/
|
*/
|
||||||
int32_t (* close)(struct dcb* dcb);
|
int32_t (* close)(struct dcb* dcb);
|
||||||
|
|
||||||
/**
|
|
||||||
* Listen on a network socket, only for client side protocol modules
|
|
||||||
*
|
|
||||||
* @param dcb DCB to listen with
|
|
||||||
* @param address Address to listen on in `address|port` format
|
|
||||||
*
|
|
||||||
* @return 1 on success, 0 on error
|
|
||||||
*/
|
|
||||||
int32_t (* listen)(struct dcb* dcb, char* address);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform user re-authentication
|
* Perform user re-authentication
|
||||||
*
|
*
|
||||||
|
|||||||
@ -50,6 +50,7 @@
|
|||||||
#include <maxscale/limits.h>
|
#include <maxscale/limits.h>
|
||||||
#include <maxscale/log.h>
|
#include <maxscale/log.h>
|
||||||
#include <maxscale/maxscale.h>
|
#include <maxscale/maxscale.h>
|
||||||
|
#include <maxscale/maxadmin.h>
|
||||||
#include <maxscale/paths.h>
|
#include <maxscale/paths.h>
|
||||||
#include <maxscale/pcre2.h>
|
#include <maxscale/pcre2.h>
|
||||||
#include <maxscale/router.hh>
|
#include <maxscale/router.hh>
|
||||||
@ -3831,8 +3832,8 @@ int create_new_listener(CONFIG_CONTEXT* obj)
|
|||||||
|
|
||||||
int error_count = 0;
|
int error_count = 0;
|
||||||
|
|
||||||
char* port = config_get_value(obj->parameters, CN_PORT);
|
const char* port = config_get_value(obj->parameters, CN_PORT);
|
||||||
char* socket = config_get_value(obj->parameters, CN_SOCKET);
|
const char* socket = config_get_value(obj->parameters, CN_SOCKET);
|
||||||
|
|
||||||
if (socket && port)
|
if (socket && port)
|
||||||
{
|
{
|
||||||
@ -3854,6 +3855,14 @@ int create_new_listener(CONFIG_CONTEXT* obj)
|
|||||||
Service* service = static_cast<Service*>(config_get_service(obj->parameters, CN_SERVICE));
|
Service* service = static_cast<Service*>(config_get_service(obj->parameters, CN_SERVICE));
|
||||||
mxb_assert(service);
|
mxb_assert(service);
|
||||||
|
|
||||||
|
// Remove this once maxadmin is removed
|
||||||
|
if (strcasecmp(protocol, "maxscaled") == 0 && socket
|
||||||
|
&& strcmp(socket, MAXADMIN_CONFIG_DEFAULT_SOCKET_TAG) == 0)
|
||||||
|
{
|
||||||
|
socket = MAXADMIN_DEFAULT_SOCKET;
|
||||||
|
address = "";
|
||||||
|
}
|
||||||
|
|
||||||
if (auto l = service_find_listener(service, socket, address, socket ? 0 : atoi(port)))
|
if (auto l = service_find_listener(service, socket, address, socket ? 0 : atoi(port)))
|
||||||
{
|
{
|
||||||
MXS_ERROR("Creation of listener '%s' for service '%s' failed, because "
|
MXS_ERROR("Creation of listener '%s' for service '%s' failed, because "
|
||||||
|
|||||||
@ -2606,10 +2606,10 @@ static int dcb_accept_one_connection(DCB* dcb, struct sockaddr* client_conn)
|
|||||||
*
|
*
|
||||||
* @param dcb Listener DCB that is being created
|
* @param dcb Listener DCB that is being created
|
||||||
* @param config Configuration for port to listen on
|
* @param config Configuration for port to listen on
|
||||||
* @param protocol_name Name of protocol that is listening
|
*
|
||||||
* @return 0 if new listener created successfully, otherwise -1
|
* @return 0 if new listener created successfully, otherwise -1
|
||||||
*/
|
*/
|
||||||
int dcb_listen(DCB* dcb, const char* config, const char* protocol_name)
|
int dcb_listen(DCB* dcb, const char* config)
|
||||||
{
|
{
|
||||||
char host[strlen(config) + 1];
|
char host[strlen(config) + 1];
|
||||||
strcpy(host, config);
|
strcpy(host, config);
|
||||||
@ -2667,17 +2667,16 @@ int dcb_listen(DCB* dcb, const char* config, const char* protocol_name)
|
|||||||
*/
|
*/
|
||||||
if (listen(listener_socket, INT_MAX) != 0)
|
if (listen(listener_socket, INT_MAX) != 0)
|
||||||
{
|
{
|
||||||
MXS_ERROR("Failed to start listening on [%s]:%u with protocol '%s': %d, %s",
|
MXS_ERROR("Failed to start listening on [%s]:%u: %d, %s",
|
||||||
host,
|
host,
|
||||||
port,
|
port,
|
||||||
protocol_name,
|
|
||||||
errno,
|
errno,
|
||||||
mxs_strerror(errno));
|
mxs_strerror(errno));
|
||||||
close(listener_socket);
|
close(listener_socket);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
MXS_NOTICE("Listening for connections at [%s]:%u with protocol %s", host, port, protocol_name);
|
MXS_NOTICE("Listening for connections at [%s]:%u", host, port);
|
||||||
|
|
||||||
// assign listener_socket to dcb
|
// assign listener_socket to dcb
|
||||||
dcb->fd = listener_socket;
|
dcb->fd = listener_socket;
|
||||||
|
|||||||
@ -796,13 +796,16 @@ bool Listener::listen()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_listener->func.listen(m_listener, &config_bind[0]))
|
bool rval = false;
|
||||||
|
|
||||||
|
if (dcb_listen(m_listener, config_bind.data()) == 0)
|
||||||
{
|
{
|
||||||
m_listener->session = session_alloc(m_service, m_listener);
|
m_listener->session = session_alloc(m_service, m_listener);
|
||||||
|
|
||||||
if (m_listener->session != NULL)
|
if (m_listener->session != NULL)
|
||||||
{
|
{
|
||||||
m_listener->session->state = SESSION_STATE_LISTENER;
|
m_listener->session->state = SESSION_STATE_LISTENER;
|
||||||
|
rval = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -814,5 +817,5 @@ bool Listener::listen()
|
|||||||
MXS_ERROR("[%s] Failed to listen on %s", m_service->name, config_bind.c_str());
|
MXS_ERROR("[%s] Failed to listen on %s", m_service->name, config_bind.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,7 +50,6 @@ static int cdc_error(DCB* dcb);
|
|||||||
static int cdc_hangup(DCB* dcb);
|
static int cdc_hangup(DCB* dcb);
|
||||||
static int cdc_accept(DCB* dcb);
|
static int cdc_accept(DCB* dcb);
|
||||||
static int cdc_close(DCB* dcb);
|
static int cdc_close(DCB* dcb);
|
||||||
static int cdc_listen(DCB* dcb, char* config);
|
|
||||||
static CDC_protocol* cdc_protocol_init(DCB* dcb);
|
static CDC_protocol* cdc_protocol_init(DCB* dcb);
|
||||||
static void cdc_protocol_done(DCB* dcb);
|
static void cdc_protocol_done(DCB* dcb);
|
||||||
static int do_auth(DCB* dcb, GWBUF* buffer, void* data);
|
static int do_auth(DCB* dcb, GWBUF* buffer, void* data);
|
||||||
@ -84,7 +83,6 @@ extern "C"
|
|||||||
cdc_accept, /* Accept */
|
cdc_accept, /* Accept */
|
||||||
NULL, /* Connect */
|
NULL, /* Connect */
|
||||||
cdc_close, /* Close */
|
cdc_close, /* Close */
|
||||||
cdc_listen, /* Create a listener */
|
|
||||||
NULL, /* Authentication */
|
NULL, /* Authentication */
|
||||||
cdc_default_auth, /* default authentication */
|
cdc_default_auth, /* default authentication */
|
||||||
NULL,
|
NULL,
|
||||||
@ -359,17 +357,6 @@ static int cdc_close(DCB* dcb)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* CDC protocol listener entry point
|
|
||||||
*
|
|
||||||
* @param listener The Listener DCB
|
|
||||||
* @param config Configuration (ip:port)
|
|
||||||
*/
|
|
||||||
static int cdc_listen(DCB* listener, char* config)
|
|
||||||
{
|
|
||||||
return (dcb_listen(listener, config, "CDC") < 0) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate a new CDC protocol structure
|
* Allocate a new CDC protocol structure
|
||||||
*
|
*
|
||||||
|
|||||||
@ -52,7 +52,6 @@ static int httpd_error(DCB* dcb);
|
|||||||
static int httpd_hangup(DCB* dcb);
|
static int httpd_hangup(DCB* dcb);
|
||||||
static int httpd_accept(DCB* dcb);
|
static int httpd_accept(DCB* dcb);
|
||||||
static int httpd_close(DCB* dcb);
|
static int httpd_close(DCB* dcb);
|
||||||
static int httpd_listen(DCB* dcb, char* config);
|
|
||||||
static int httpd_get_line(int sock, char* buf, int size);
|
static int httpd_get_line(int sock, char* buf, int size);
|
||||||
static void httpd_send_headers(DCB* dcb, int final, bool auth_ok);
|
static void httpd_send_headers(DCB* dcb, int final, bool auth_ok);
|
||||||
static char* httpd_default_auth();
|
static char* httpd_default_auth();
|
||||||
@ -79,7 +78,6 @@ extern "C"
|
|||||||
httpd_accept, /**< Accept */
|
httpd_accept, /**< Accept */
|
||||||
NULL, /**< Connect */
|
NULL, /**< Connect */
|
||||||
httpd_close, /**< Close */
|
httpd_close, /**< Close */
|
||||||
httpd_listen, /**< Create a listener */
|
|
||||||
NULL, /**< Authentication */
|
NULL, /**< Authentication */
|
||||||
httpd_default_auth, /**< Default authenticator */
|
httpd_default_auth, /**< Default authenticator */
|
||||||
NULL, /**< Connection limit reached */
|
NULL, /**< Connection limit reached */
|
||||||
@ -401,17 +399,6 @@ static int httpd_close(DCB* dcb)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* HTTTP daemon listener entry point
|
|
||||||
*
|
|
||||||
* @param listener The Listener DCB
|
|
||||||
* @param config Configuration (ip:port)
|
|
||||||
*/
|
|
||||||
static int httpd_listen(DCB* listener, char* config)
|
|
||||||
{
|
|
||||||
return (dcb_listen(listener, config, "HTTPD") < 0) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HTTPD get line from client
|
* HTTPD get line from client
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -84,7 +84,6 @@ extern "C"
|
|||||||
NULL, /* Accept */
|
NULL, /* Accept */
|
||||||
gw_create_backend_connection, /* Connect */
|
gw_create_backend_connection, /* Connect */
|
||||||
gw_backend_close, /* Close */
|
gw_backend_close, /* Close */
|
||||||
NULL, /* Listen */
|
|
||||||
gw_change_user, /* Authentication */
|
gw_change_user, /* Authentication */
|
||||||
gw_backend_default_auth, /* Default authenticator */
|
gw_backend_default_auth, /* Default authenticator */
|
||||||
NULL, /* Connection limit reached */
|
NULL, /* Connection limit reached */
|
||||||
|
|||||||
@ -59,7 +59,6 @@ static int thread_init(void);
|
|||||||
static void thread_finish(void);
|
static void thread_finish(void);
|
||||||
|
|
||||||
static int gw_MySQLAccept(DCB* listener);
|
static int gw_MySQLAccept(DCB* listener);
|
||||||
static int gw_MySQLListener(DCB* listener, char* config_bind);
|
|
||||||
static int gw_read_client_event(DCB* dcb);
|
static int gw_read_client_event(DCB* dcb);
|
||||||
static int gw_write_client_event(DCB* dcb);
|
static int gw_write_client_event(DCB* dcb);
|
||||||
static int gw_MySQLWrite_client(DCB* dcb, GWBUF* queue);
|
static int gw_MySQLWrite_client(DCB* dcb, GWBUF* queue);
|
||||||
@ -107,7 +106,6 @@ extern "C"
|
|||||||
gw_MySQLAccept, /* Accept */
|
gw_MySQLAccept, /* Accept */
|
||||||
NULL, /* Connect */
|
NULL, /* Connect */
|
||||||
gw_client_close, /* Close */
|
gw_client_close, /* Close */
|
||||||
gw_MySQLListener, /* Listen */
|
|
||||||
NULL, /* Authentication */
|
NULL, /* Authentication */
|
||||||
gw_default_auth, /* Default authenticator */
|
gw_default_auth, /* Default authenticator */
|
||||||
gw_connection_limit, /* Send error connection limit */
|
gw_connection_limit, /* Send error connection limit */
|
||||||
@ -1384,25 +1382,6 @@ return_1:
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Bind the DCB to a network port or a UNIX Domain Socket.
|
|
||||||
* @param listen_dcb Listener DCB
|
|
||||||
* @param config_bind Bind address in either IP:PORT format for network sockets or PATH
|
|
||||||
* for UNIX Domain Sockets
|
|
||||||
* @return 1 on success, 0 on error
|
|
||||||
*/
|
|
||||||
int gw_MySQLListener(DCB* listen_dcb, char* config_bind)
|
|
||||||
{
|
|
||||||
if (dcb_listen(listen_dcb, config_bind, "MySQL") < 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
listen_dcb->func.accept = gw_MySQLAccept;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @node Accept a new connection, using the DCB code for the basic work
|
* @node Accept a new connection, using the DCB code for the basic work
|
||||||
*
|
*
|
||||||
|
|||||||
@ -63,7 +63,6 @@ static int maxscaled_error(DCB* dcb);
|
|||||||
static int maxscaled_hangup(DCB* dcb);
|
static int maxscaled_hangup(DCB* dcb);
|
||||||
static int maxscaled_accept(DCB* dcb);
|
static int maxscaled_accept(DCB* dcb);
|
||||||
static int maxscaled_close(DCB* dcb);
|
static int maxscaled_close(DCB* dcb);
|
||||||
static int maxscaled_listen(DCB* dcb, char* config);
|
|
||||||
static char* mxsd_default_auth();
|
static char* mxsd_default_auth();
|
||||||
|
|
||||||
static bool authenticate_unix_socket(MAXSCALED* protocol, DCB* dcb)
|
static bool authenticate_unix_socket(MAXSCALED* protocol, DCB* dcb)
|
||||||
@ -181,7 +180,6 @@ extern "C"
|
|||||||
maxscaled_accept, /**< Accept */
|
maxscaled_accept, /**< Accept */
|
||||||
NULL, /**< Connect */
|
NULL, /**< Connect */
|
||||||
maxscaled_close, /**< Close */
|
maxscaled_close, /**< Close */
|
||||||
maxscaled_listen, /**< Create a listener */
|
|
||||||
NULL, /**< Authentication */
|
NULL, /**< Authentication */
|
||||||
mxsd_default_auth, /**< Default authenticator */
|
mxsd_default_auth, /**< Default authenticator */
|
||||||
NULL, /**< Connection limit reached */
|
NULL, /**< Connection limit reached */
|
||||||
@ -417,27 +415,3 @@ static int maxscaled_close(DCB* dcb)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Maxscale daemon listener entry point
|
|
||||||
*
|
|
||||||
* @param listener The Listener DCB
|
|
||||||
* @param config Configuration (ip:port)
|
|
||||||
* @return 0 on failure, 1 on success
|
|
||||||
*/
|
|
||||||
static int maxscaled_listen(DCB* listener, char* config)
|
|
||||||
{
|
|
||||||
const char* socket_path = NULL;
|
|
||||||
|
|
||||||
/* check for default UNIX socket */
|
|
||||||
if (strncmp(config, MAXADMIN_CONFIG_DEFAULT_SOCKET_TAG, MAXADMIN_CONFIG_DEFAULT_SOCKET_TAG_LEN) == 0)
|
|
||||||
{
|
|
||||||
socket_path = MAXADMIN_DEFAULT_SOCKET;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
socket_path = config;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (dcb_listen(listener, socket_path, "MaxScale Admin") < 0) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|||||||
@ -65,7 +65,6 @@ static int telnetd_error(DCB* dcb);
|
|||||||
static int telnetd_hangup(DCB* dcb);
|
static int telnetd_hangup(DCB* dcb);
|
||||||
static int telnetd_accept(DCB* dcb);
|
static int telnetd_accept(DCB* dcb);
|
||||||
static int telnetd_close(DCB* dcb);
|
static int telnetd_close(DCB* dcb);
|
||||||
static int telnetd_listen(DCB* dcb, char* config);
|
|
||||||
static char* telnetd_default_auth();
|
static char* telnetd_default_auth();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,7 +99,6 @@ extern "C"
|
|||||||
telnetd_accept, /**< Accept */
|
telnetd_accept, /**< Accept */
|
||||||
NULL, /**< Connect */
|
NULL, /**< Connect */
|
||||||
telnetd_close, /**< Close */
|
telnetd_close, /**< Close */
|
||||||
telnetd_listen, /**< Create a listener */
|
|
||||||
NULL, /**< Authentication */
|
NULL, /**< Authentication */
|
||||||
telnetd_default_auth, /**< Default authenticator */
|
telnetd_default_auth, /**< Default authenticator */
|
||||||
NULL, /**< Connection limit reached */
|
NULL, /**< Connection limit reached */
|
||||||
@ -330,17 +328,6 @@ static int telnetd_close(DCB* dcb)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Telnet daemon listener entry point
|
|
||||||
*
|
|
||||||
* @param listener The Listener DCB
|
|
||||||
* @param config Configuration (ip:port)
|
|
||||||
*/
|
|
||||||
static int telnetd_listen(DCB* listener, char* config)
|
|
||||||
{
|
|
||||||
return (dcb_listen(listener, config, "telnet") < 0) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Telnet command implementation
|
* Telnet command implementation
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user