MXS-1539: Preliminary implementation of thread-local user cache

The thread-local user cache removes most of the cross-thread communication
from the user authentication at the cost of increased memory use and extra
network usage when users are loaded.
This commit is contained in:
Markus Mäkelä
2017-11-23 14:03:23 +02:00
parent 513220805b
commit 4194c1c558
3 changed files with 64 additions and 79 deletions

View File

@ -102,14 +102,15 @@ static const char null_token[] = "NULL";
/** Flags for sqlite3_open_v2() */
static int db_flags = SQLITE_OPEN_READWRITE |
SQLITE_OPEN_CREATE |
SQLITE_OPEN_SHAREDCACHE;
SQLITE_OPEN_NOMUTEX;
typedef struct mysql_auth
{
sqlite3 *handle; /**< SQLite3 database handle */
sqlite3 **handles; /**< SQLite3 database handle */
char *cache_dir; /**< Custom cache directory location */
bool inject_service_user; /**< Inject the service user into the list of users */
bool skip_auth; /**< Authentication will always be successful */
bool check_permissions;
} MYSQL_AUTH;
/**
@ -124,6 +125,15 @@ typedef struct mysql_user_host_key
char hostname[MYSQL_HOST_MAXLEN + 1];
} MYSQL_USER_HOST;
/**
* @brief Get the thread-specific SQLite handle
*
* @param instance Authenticator instance
*
* @return The thread-specific handle
*/
sqlite3* get_handle(MYSQL_AUTH* instance);
/**
* @brief Add new MySQL user to the internal user database
*