Merge branch '2.1' into develop

This commit is contained in:
Johan Wikman
2017-03-03 13:37:14 +02:00
56 changed files with 2355 additions and 630 deletions

View File

@ -1,13 +1,13 @@
add_library(maxscale-common SHARED adminusers.c alloc.c authenticator.c atomic.c buffer.c config.c config_runtime.c dcb.c filter.c filter.cc externcmd.c paths.c hashtable.c hint.c housekeeper.c load_utils.c log_manager.cc maxscale_pcre2.c misc.c mlist.c modutil.c monitor.c queuemanager.c query_classifier.c poll.c random_jkiss.c resultset.c secrets.c server.c service.c session.c spinlock.c thread.c users.c utils.c skygw_utils.cc statistics.c listener.c ssl.c mysql_utils.c mysql_binlog.c modulecmd.c )
target_link_libraries(maxscale-common ${MARIADB_CONNECTOR_LIBRARIES} ${LZMA_LINK_FLAGS} ${PCRE2_LIBRARIES} ${CURL_LIBRARIES} ssl pthread crypt dl crypto inih z rt m stdc++)
if(WITH_JEMALLOC)
target_link_libraries(maxscale-common ${JEMALLOC_LIBRARIES})
elseif(WITH_TCMALLOC)
target_link_libraries(maxscale-common ${TCMALLOC_LIBRARIES})
endif()
target_link_libraries(maxscale-common ${MARIADB_CONNECTOR_LIBRARIES} ${LZMA_LINK_FLAGS} ${PCRE2_LIBRARIES} ${CURL_LIBRARIES} ssl pthread crypt dl crypto inih z rt m stdc++)
add_dependencies(maxscale-common pcre2 connector-c)
set_target_properties(maxscale-common PROPERTIES VERSION "1.0.0")
install_module(maxscale-common core)

View File

@ -143,7 +143,7 @@ static struct option long_options[] =
static bool syslog_configured = false;
static bool maxlog_configured = false;
static bool log_to_shm_configured = false;
static int last_signal = 0;
static volatile sig_atomic_t last_signal = 0;
static int cnf_preparser(void* data, const char* section, const char* name, const char* value);
static void log_flush_shutdown(void);
@ -381,7 +381,7 @@ sigchld_handler (int i)
}
}
int fatal_handling = 0;
volatile sig_atomic_t fatal_handling = 0;
static int signal_set(int sig, void (*handler)(int));
@ -405,12 +405,12 @@ sigfatal_handler(int i)
{
void *addrs[128];
int n, count = backtrace(addrs, 128);
int count = backtrace(addrs, 128);
char** symbols = backtrace_symbols(addrs, count);
if (symbols)
{
for (n = 0; n < count; n++)
for (int n = 0; n < count; n++)
{
MXS_ALERT(" %s\n", symbols[n]);
}
@ -2023,6 +2023,9 @@ int main(int argc, char **argv)
unlock_pidfile();
unlink_pidfile();
ERR_free_strings();
EVP_cleanup();
return_main:
mxs_log_flush_sync();
@ -2277,6 +2280,12 @@ bool pid_file_exists()
static int write_pid_file()
{
if (!mxs_mkdir_all(get_piddir(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH))
{
MXS_ERROR("Failed to create PID directory.");
return 1;
}
char logbuf[STRING_BUFFER_SIZE + PATH_MAX];
char pidstr[STRING_BUFFER_SIZE];

View File

@ -567,10 +567,11 @@ hashtable_read_lock(HASHTABLE *table)
while (table->writelock)
{
spinlock_release(&table->spin);
while (table->writelock)
while (atomic_add(&table->writelock, 1) != 0)
{
;
atomic_add(&table->writelock, -1);
}
atomic_add(&table->writelock, -1);
spinlock_acquire(&table->spin);
}
atomic_add(&table->n_readers, 1);
@ -614,10 +615,11 @@ hashtable_write_lock(HASHTABLE *table)
spinlock_acquire(&table->spin);
do
{
while (table->n_readers)
while (atomic_add(&table->n_readers, 1) != 0)
{
;
atomic_add(&table->n_readers, -1);
}
atomic_add(&table->n_readers, -1);
available = atomic_add(&table->writelock, 1);
if (available != 0)
{

View File

@ -94,7 +94,7 @@ typedef struct fake_event
struct fake_event *next; /*< The next event */
} fake_event_t;
thread_local int thread_id; /**< This thread's ID */
thread_local int current_thread_id; /**< This thread's ID */
static int *epoll_fd; /*< The epoll file descriptor */
static int next_epoll_fd = 0; /*< Which thread handles the next DCB */
static fake_event_t **fake_events; /*< Thread-specific fake event queue */
@ -656,9 +656,11 @@ poll_waitevents(void *arg)
{
struct epoll_event events[MAX_EVENTS];
int i, nfds, timeout_bias = 1;
thread_id = (intptr_t)arg;
current_thread_id = (intptr_t)arg;
int poll_spins = 0;
int thread_id = current_thread_id;
thread_data[thread_id].state = THREAD_IDLE;
while (1)
@ -1613,7 +1615,7 @@ void poll_send_message(enum poll_message msg, void *data)
for (int i = 0; i < nthr; i++)
{
if (i != thread_id)
if (i != current_thread_id)
{
while (poll_msg[i] & msg)
{
@ -1628,6 +1630,8 @@ void poll_send_message(enum poll_message msg, void *data)
static void poll_check_message()
{
int thread_id = current_thread_id;
if (poll_msg[thread_id] & POLL_MSG_CLEAN_PERSISTENT)
{
SERVER *server = (SERVER*)poll_msg_data;