Handle server repurposing under a lock

By moving the repurposing of the servers under the global server lock, the
repurposing of a server and allocation of a new server behave in the same
way.

Also fixed the wrong error message on server creation failure referring to
invalid server relationships.
This commit is contained in:
Markus Mäkelä
2017-08-04 11:24:54 +03:00
parent e133e758a6
commit 1743f4c1b7
3 changed files with 36 additions and 34 deletions

View File

@ -132,7 +132,6 @@ typedef struct server
int persistmax; /**< Maximum pool size actually achieved since startup */
uint8_t charset; /**< Default server character set */
bool is_active; /**< Server is active and has not been "destroyed" */
bool created_online; /**< Whether this server was created after startup */
bool proxy_protocol; /**< Send proxy-protocol header to backend when connecting client sessions. */
#if defined(SS_DEBUG)
skygw_chk_t server_chk_tail;
@ -254,16 +253,20 @@ extern SERVER* server_alloc(const char *name, const char *address, unsigned shor
*
* A server that has been destroyed will not be deleted but only deactivated.
*
* @param name Name of the server
* @param protocol Protocol used by the server
* @param name Name of the server
* @param protocol Protocol used by the server
* @param authenticator The authenticator module of the server
* @param auth_options Options for the authenticator
* @return Reusable SERVER or NULL if no servers matching the criteria were
* @param auth_options Options for the authenticator
* @param address The network address of the new server
* @param port The port of the new server
*
* @return Repurposed SERVER or NULL if no servers matching the criteria were
* found
* @see runtime_create_server
*/
SERVER* server_find_destroyed(const char *name, const char *protocol,
const char *authenticator, const char *auth_options);
SERVER* server_repurpose_destroyed(const char *name, const char *protocol,
const char *authenticator, const char *auth_options,
const char *address, const char *port);
/**
* @brief Serialize a server to a file
*