Make listener creation const-correct
The parameters passed to functions that create new listeners are now of type const char*.
This commit is contained in:
@ -59,9 +59,9 @@ typedef struct servlistener
|
|||||||
struct servlistener *next; /**< Next service protocol */
|
struct servlistener *next; /**< Next service protocol */
|
||||||
} SERV_LISTENER;
|
} SERV_LISTENER;
|
||||||
|
|
||||||
SERV_LISTENER *listener_alloc(struct service* service, char *name, char *protocol,
|
SERV_LISTENER* listener_alloc(struct service* service, const char* name, const char *protocol,
|
||||||
char *address, unsigned short port, char *authenticator,
|
const char *address, unsigned short port, const char *authenticator,
|
||||||
char* options, SSL_LISTENER *ssl);
|
const char* auth_options, SSL_LISTENER *ssl);
|
||||||
void listener_free(SERV_LISTENER* listener);
|
void listener_free(SERV_LISTENER* listener);
|
||||||
int listener_set_ssl_version(SSL_LISTENER *ssl_listener, char* version);
|
int listener_set_ssl_version(SSL_LISTENER *ssl_listener, char* version);
|
||||||
void listener_set_certificates(SSL_LISTENER *ssl_listener, char* cert, char* key, char* ca_cert);
|
void listener_set_certificates(SSL_LISTENER *ssl_listener, char* cert, char* key, char* ca_cert);
|
||||||
|
@ -192,10 +192,9 @@ extern SERVICE *service_alloc(const char *, const char *);
|
|||||||
extern int service_free(SERVICE *);
|
extern int service_free(SERVICE *);
|
||||||
extern SERVICE *service_find(const char *);
|
extern SERVICE *service_find(const char *);
|
||||||
extern int service_isvalid(SERVICE *);
|
extern int service_isvalid(SERVICE *);
|
||||||
extern int serviceAddProtocol(SERVICE *service, char *name, char *protocol,
|
extern bool serviceAddProtocol(SERVICE *service, const char *name, const char *protocol,
|
||||||
char *address, unsigned short port,
|
const char *address, unsigned short port, const char *authenticator,
|
||||||
char *authenticator, char *options,
|
const char *options, SSL_LISTENER *ssl);
|
||||||
SSL_LISTENER *ssl);
|
|
||||||
extern int serviceHasProtocol(SERVICE *service, const char *protocol,
|
extern int serviceHasProtocol(SERVICE *service, const char *protocol,
|
||||||
const char* address, unsigned short port);
|
const char* address, unsigned short port);
|
||||||
extern void serviceAddBackend(SERVICE *, SERVER *);
|
extern void serviceAddBackend(SERVICE *, SERVER *);
|
||||||
|
@ -55,61 +55,67 @@ static RSA *tmp_rsa_callback(SSL *s, int is_export, int keylength);
|
|||||||
* @return New listener object or NULL if unable to allocate
|
* @return New listener object or NULL if unable to allocate
|
||||||
*/
|
*/
|
||||||
SERV_LISTENER *
|
SERV_LISTENER *
|
||||||
listener_alloc(struct service* service, char* name, char *protocol, char *address,
|
listener_alloc(struct service* service, const char* name, const char *protocol,
|
||||||
unsigned short port, char *authenticator, char* auth_options, SSL_LISTENER *ssl)
|
const char *address, unsigned short port, const char *authenticator,
|
||||||
|
const char* auth_options, SSL_LISTENER *ssl)
|
||||||
{
|
{
|
||||||
|
char *my_address = NULL;
|
||||||
if (address)
|
if (address)
|
||||||
{
|
{
|
||||||
address = MXS_STRDUP(address);
|
my_address = MXS_STRDUP(address);
|
||||||
if (!address)
|
if (!my_address)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *my_authenticator = NULL;
|
||||||
|
|
||||||
if (authenticator)
|
if (authenticator)
|
||||||
{
|
{
|
||||||
authenticator = MXS_STRDUP(authenticator);
|
my_authenticator = MXS_STRDUP(authenticator);
|
||||||
}
|
}
|
||||||
else if ((authenticator = (char*)get_default_authenticator(protocol)) == NULL ||
|
else if ((authenticator = get_default_authenticator(protocol)) == NULL ||
|
||||||
(authenticator = MXS_STRDUP(authenticator)) == NULL)
|
(my_authenticator = MXS_STRDUP(authenticator)) == NULL)
|
||||||
{
|
{
|
||||||
MXS_ERROR("No authenticator defined for listener '%s' and could not get "
|
MXS_ERROR("No authenticator defined for listener '%s' and could not get "
|
||||||
"default authenticator for protocol '%s'.", name, protocol);
|
"default authenticator for protocol '%s'.", name, protocol);
|
||||||
|
MXS_FREE(my_address);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *auth_instance = NULL;
|
void *auth_instance = NULL;
|
||||||
|
|
||||||
if (!authenticator_init(&auth_instance, authenticator, auth_options))
|
if (!authenticator_init(&auth_instance, my_authenticator, auth_options))
|
||||||
{
|
{
|
||||||
MXS_ERROR("Failed to initialize authenticator module '%s' for "
|
MXS_ERROR("Failed to initialize authenticator module '%s' for "
|
||||||
"listener '%s'.", authenticator, name);
|
"listener '%s'.", my_authenticator, name);
|
||||||
MXS_FREE(address);
|
MXS_FREE(my_address);
|
||||||
MXS_FREE(authenticator);
|
MXS_FREE(my_authenticator);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
protocol = MXS_STRDUP(protocol);
|
char *my_protocol = MXS_STRDUP(protocol);
|
||||||
name = MXS_STRDUP(name);
|
char *my_name = MXS_STRDUP(name);
|
||||||
SERV_LISTENER *proto = (SERV_LISTENER*)MXS_MALLOC(sizeof(SERV_LISTENER));
|
SERV_LISTENER *proto = (SERV_LISTENER*)MXS_MALLOC(sizeof(SERV_LISTENER));
|
||||||
|
|
||||||
if (!protocol || !proto || !name || !authenticator)
|
if (!my_protocol || !proto || !my_name || !my_authenticator)
|
||||||
{
|
{
|
||||||
MXS_FREE(authenticator);
|
MXS_FREE(my_authenticator);
|
||||||
MXS_FREE(protocol);
|
MXS_FREE(my_protocol);
|
||||||
MXS_FREE(address);
|
MXS_FREE(my_address);
|
||||||
|
MXS_FREE(my_name);
|
||||||
MXS_FREE(proto);
|
MXS_FREE(proto);
|
||||||
MXS_FREE(name);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
proto->name = name;
|
proto->name = my_name;
|
||||||
proto->listener = NULL;
|
proto->listener = NULL;
|
||||||
proto->service = service;
|
proto->service = service;
|
||||||
proto->protocol = protocol;
|
proto->protocol = my_protocol;
|
||||||
proto->address = address;
|
proto->address = my_address;
|
||||||
proto->port = port;
|
proto->port = port;
|
||||||
proto->authenticator = authenticator;
|
proto->authenticator = my_authenticator;
|
||||||
proto->ssl = ssl;
|
proto->ssl = ssl;
|
||||||
proto->users = NULL;
|
proto->users = NULL;
|
||||||
proto->resources = NULL;
|
proto->resources = NULL;
|
||||||
|
@ -688,11 +688,11 @@ service_free(SERVICE *service)
|
|||||||
* @param ssl SSL configuration
|
* @param ssl SSL configuration
|
||||||
* @return TRUE if the protocol/port could be added
|
* @return TRUE if the protocol/port could be added
|
||||||
*/
|
*/
|
||||||
int
|
bool serviceAddProtocol(SERVICE *service, const char *name, const char *protocol,
|
||||||
serviceAddProtocol(SERVICE *service, char *name, char *protocol, char *address,
|
const char *address, unsigned short port, const char *authenticator,
|
||||||
unsigned short port, char *authenticator, char *options,
|
const char *options, SSL_LISTENER *ssl)
|
||||||
SSL_LISTENER *ssl)
|
|
||||||
{
|
{
|
||||||
|
bool rval = false;
|
||||||
SERV_LISTENER *proto = listener_alloc(service, name, protocol, address,
|
SERV_LISTENER *proto = listener_alloc(service, name, protocol, address,
|
||||||
port, authenticator, options, ssl);
|
port, authenticator, options, ssl);
|
||||||
|
|
||||||
@ -702,10 +702,10 @@ serviceAddProtocol(SERVICE *service, char *name, char *protocol, char *address,
|
|||||||
proto->next = service->ports;
|
proto->next = service->ports;
|
||||||
service->ports = proto;
|
service->ports = proto;
|
||||||
spinlock_release(&service->spin);
|
spinlock_release(&service->spin);
|
||||||
return 1;
|
rval = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user