Fixed concurrency issues in filters.
This commit is contained in:
@ -50,6 +50,7 @@
|
||||
#include <sys/time.h>
|
||||
#include <regex.h>
|
||||
#include <string.h>
|
||||
#include <atomic.h>
|
||||
|
||||
/** Defined in log_manager.cc */
|
||||
extern int lm_enabled_logfiles_bitmask;
|
||||
@ -304,7 +305,7 @@ char *remote, *userName;
|
||||
sprintf(my_session->filename, "%s.%d",
|
||||
my_instance->filebase,
|
||||
my_instance->sessions);
|
||||
my_instance->sessions++;
|
||||
atomic_add(&my_instance->sessions,1);
|
||||
|
||||
if (my_session->active)
|
||||
{
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <log_manager.h>
|
||||
#include <string.h>
|
||||
#include <regex.h>
|
||||
|
||||
#include <atomic.h>
|
||||
#include "maxconfig.h"
|
||||
|
||||
/** Defined in log_manager.cc */
|
||||
@ -97,6 +97,7 @@ typedef struct {
|
||||
*/
|
||||
typedef struct {
|
||||
DOWNSTREAM down; /* The downstream filter */
|
||||
SPINLOCK lock;
|
||||
int no_change; /* No. of unchanged requests */
|
||||
int replacements; /* No. of changed requests */
|
||||
int active; /* Is filter active */
|
||||
@ -356,13 +357,17 @@ char *sql, *newsql;
|
||||
{
|
||||
queue = modutil_replace_SQL(queue, newsql);
|
||||
queue = gwbuf_make_contiguous(queue);
|
||||
spinlock_acquire(&my_session->lock);
|
||||
log_match(my_instance,my_instance->match,sql,newsql);
|
||||
spinlock_release(&my_session->lock);
|
||||
free(newsql);
|
||||
my_session->replacements++;
|
||||
}
|
||||
else
|
||||
{
|
||||
spinlock_acquire(&my_session->lock);
|
||||
log_nomatch(my_instance,my_instance->match,sql);
|
||||
spinlock_release(&my_session->lock);
|
||||
my_session->no_change++;
|
||||
}
|
||||
free(sql);
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <filter.h>
|
||||
#include <modinfo.h>
|
||||
#include <modutil.h>
|
||||
#include <atomic.h>
|
||||
|
||||
/**
|
||||
* @file testfilter.c - a very simple test filter.
|
||||
@ -145,7 +146,7 @@ TEST_SESSION *my_session;
|
||||
|
||||
if ((my_session = calloc(1, sizeof(TEST_SESSION))) != NULL)
|
||||
{
|
||||
my_instance->sessions++;
|
||||
atomic_add(&my_instance->sessions,1);
|
||||
my_session->count = 0;
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <regex.h>
|
||||
#include <atomic.h>
|
||||
|
||||
/** Defined in log_manager.cc */
|
||||
extern int lm_enabled_logfiles_bitmask;
|
||||
@ -296,7 +297,7 @@ char *remote, *user;
|
||||
}
|
||||
sprintf(my_session->filename, "%s.%d", my_instance->filebase,
|
||||
my_instance->sessions);
|
||||
my_instance->sessions++;
|
||||
atomic_add(&my_instance->sessions,1);
|
||||
my_session->top = (TOPNQ **)calloc(my_instance->topN + 1,
|
||||
sizeof(TOPNQ *));
|
||||
for (i = 0; i < my_instance->topN; i++)
|
||||
|
Reference in New Issue
Block a user