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:
Markus Mäkelä
2018-11-30 11:32:05 +02:00
parent ae3763da92
commit a6063b5e85
11 changed files with 21 additions and 107 deletions

View File

@ -50,6 +50,7 @@
#include <maxscale/limits.h>
#include <maxscale/log.h>
#include <maxscale/maxscale.h>
#include <maxscale/maxadmin.h>
#include <maxscale/paths.h>
#include <maxscale/pcre2.h>
#include <maxscale/router.hh>
@ -3831,8 +3832,8 @@ int create_new_listener(CONFIG_CONTEXT* obj)
int error_count = 0;
char* port = config_get_value(obj->parameters, CN_PORT);
char* socket = config_get_value(obj->parameters, CN_SOCKET);
const char* port = config_get_value(obj->parameters, CN_PORT);
const char* socket = config_get_value(obj->parameters, CN_SOCKET);
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));
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)))
{
MXS_ERROR("Creation of listener '%s' for service '%s' failed, because "

View File

@ -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 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
*/
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];
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)
{
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,
port,
protocol_name,
errno,
mxs_strerror(errno));
close(listener_socket);
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
dcb->fd = listener_socket;

View File

@ -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);
if (m_listener->session != NULL)
{
m_listener->session->state = SESSION_STATE_LISTENER;
rval = true;
}
else
{
@ -814,5 +817,5 @@ bool Listener::listen()
MXS_ERROR("[%s] Failed to listen on %s", m_service->name, config_bind.c_str());
}
return true;
return rval;
}