summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2014-06-03 21:43:27 +0400
committerDmitry Kozlov <xeb@mail.ru>2014-06-03 21:43:27 +0400
commitbd30f9451a3f775e7db30a9c405e4db9d4c259b8 (patch)
tree9700f1cc1c1a12c658e51176dd928a2a675d6a21
parent093c53e3e08abb609cae6e58b1b438616c57c17f (diff)
downloadaccel-ppp-bd30f9451a3f775e7db30a9c405e4db9d4c259b8.tar.gz
accel-ppp-bd30f9451a3f775e7db30a9c405e4db9d4c259b8.zip
get out of SPINLOCK_INITIALIZER as it is not cross-platform compatible
-rw-r--r--accel-pppd/extra/ipv6pool.c6
-rw-r--r--accel-pppd/logs/log_pgsql.c4
-rw-r--r--accel-pppd/logs/log_syslog.c4
-rw-r--r--accel-pppd/memdebug.c4
-rw-r--r--accel-pppd/session.c6
-rw-r--r--accel-pppd/triton/mempool.c9
-rw-r--r--accel-pppd/triton/spinlock.h22
-rw-r--r--accel-pppd/triton/triton.c7
8 files changed, 30 insertions, 32 deletions
diff --git a/accel-pppd/extra/ipv6pool.c b/accel-pppd/extra/ipv6pool.c
index 5a9dde96..9db7b400 100644
--- a/accel-pppd/extra/ipv6pool.c
+++ b/accel-pppd/extra/ipv6pool.c
@@ -31,7 +31,7 @@ struct dppool_item_t
static LIST_HEAD(ippool);
static LIST_HEAD(dppool);
-static spinlock_t pool_lock = SPINLOCK_INITIALIZER;
+static spinlock_t pool_lock;
static struct ipdb_t ipdb;
static void generate_ippool(struct in6_addr *addr, int mask, int prefix_len)
@@ -190,7 +190,9 @@ static void ippool_init(void)
{
struct conf_sect_t *s = conf_get_section("ipv6-pool");
struct conf_option_t *opt;
-
+
+ spinlock_init(&pool_lock);
+
if (!s)
return;
diff --git a/accel-pppd/logs/log_pgsql.c b/accel-pppd/logs/log_pgsql.c
index 1a62a9ab..0c2152e7 100644
--- a/accel-pppd/logs/log_pgsql.c
+++ b/accel-pppd/logs/log_pgsql.c
@@ -36,7 +36,7 @@ static PGconn *conn;
static LIST_HEAD(msg_queue);
static int queue_size;
static int sleeping = 0;
-static spinlock_t queue_lock = SPINLOCK_INITIALIZER;
+static spinlock_t queue_lock;
static char *log_buf;
static int need_close;
@@ -284,6 +284,8 @@ static void init(void)
{
char *opt;
+ spinlock_init(&queue_lock);
+
opt = conf_get_opt("log-pgsql", "conninfo");
if (!opt)
return;
diff --git a/accel-pppd/logs/log_syslog.c b/accel-pppd/logs/log_syslog.c
index cbab5252..b0b079aa 100644
--- a/accel-pppd/logs/log_syslog.c
+++ b/accel-pppd/logs/log_syslog.c
@@ -25,7 +25,7 @@ static struct triton_context_t syslog_ctx = {
static LIST_HEAD(msg_queue);
static int queue_size;
static int sleeping = 1;
-static spinlock_t queue_lock = SPINLOCK_INITIALIZER;
+static spinlock_t queue_lock;
static char *log_buf;
static int need_close;
static char *ident;
@@ -180,6 +180,8 @@ static void load_config()
static void init(void)
{
+ spinlock_init(&queue_lock);
+
log_buf = malloc(LOG_MAX_SIZE + 1);
load_config();
diff --git a/accel-pppd/memdebug.c b/accel-pppd/memdebug.c
index 1f4af364..4b374008 100644
--- a/accel-pppd/memdebug.c
+++ b/accel-pppd/memdebug.c
@@ -40,7 +40,7 @@ struct mem_t
};
static LIST_HEAD(mem_list);
-static spinlock_t mem_list_lock = SPINLOCK_INITIALIZER;
+static spinlock_t mem_list_lock;
static struct mem_t *_md_malloc(size_t size, const char *fname, int line)
{
@@ -242,6 +242,8 @@ void __export md_check(void *ptr)
static void __init init(void)
{
+ spinlock_init(&mem_list_lock);
+
signal(36, siginfo);
signal(37, siginfo2);
}
diff --git a/accel-pppd/session.c b/accel-pppd/session.c
index 267b960f..d8ee6dd8 100644
--- a/accel-pppd/session.c
+++ b/accel-pppd/session.c
@@ -43,7 +43,7 @@ int __export urandom_fd;
int __export ap_shutdown;
#if __WORDSIZE == 32
-static spinlock_t seq_lock = SPINLOCK_INITIALIZER;
+static spinlock_t seq_lock;
#endif
static long long unsigned seq;
static struct timespec seq_ts;
@@ -419,6 +419,10 @@ static void init(void)
{
FILE *f;
+#if __WORDSIZE == 32
+ spinlock_init(&seq_lock);
+#endif
+
sock_fd = socket(AF_INET, SOCK_DGRAM, 0);
if (sock_fd < 0) {
perror("socket");
diff --git a/accel-pppd/triton/mempool.c b/accel-pppd/triton/mempool.c
index 1ee00f31..4a3ec8b0 100644
--- a/accel-pppd/triton/mempool.c
+++ b/accel-pppd/triton/mempool.c
@@ -53,8 +53,8 @@ struct _item_t
};
static LIST_HEAD(pools);
-static spinlock_t pools_lock = SPINLOCK_INITIALIZER;
-static spinlock_t mmap_lock = SPINLOCK_INITIALIZER;
+static spinlock_t pools_lock;
+static spinlock_t mmap_lock;
static void *mmap_ptr;
static void *mmap_endptr;
@@ -343,7 +343,10 @@ static void __init init(void)
{
sigset_t set;
sigfillset(&set);
-
+
+ spinlock_init(&pools_lock);
+ spinlock_init(&mmap_lock);
+
struct sigaction sa = {
.sa_handler = sigclean,
.sa_mask = set,
diff --git a/accel-pppd/triton/spinlock.h b/accel-pppd/triton/spinlock.h
index b09d8276..529719ed 100644
--- a/accel-pppd/triton/spinlock.h
+++ b/accel-pppd/triton/spinlock.h
@@ -1,26 +1,7 @@
#ifndef __TRITON_SPINLOCK_H
#define __TRITON_SPINLOCK_H
-#if defined(FUTEX_SPINLOCK)
-
-/*#include <unistd.h>
-#include <sys/syscall.h>
-#include <linux/futex.h>
-typedef volatile int __attribute__((aligned)) spinlock_t;
-static inline void _spin_lock(spinlock_t *l)
-{
- syscall(SYS_futex, l, FUTEX_WAIT, r, NULL, NULL, 0);
-}
-static inline void _spin_unlock(spinlock_t *l)
-{
- syscall(SYS_futex, l, FUTEX_WAKE, 2, NULL, NULL, 0);
-}
-#define spin_lock(l) _spin_lock(l)
-#define spin_unlock(l) _spin_unlock(l)
-#define SPINLOCK_INITIALIZER 1
-#define spinlock_init(l) {*(l)=1;}*/
-
-#elif defined(GCC_SPINLOCK)
+#if defined(GCC_SPINLOCK)
typedef volatile int __attribute__((aligned)) spinlock_t;
#define spin_lock(l) {while(__sync_lock_test_and_set(l,1));}
@@ -34,7 +15,6 @@ typedef volatile int __attribute__((aligned)) spinlock_t;
typedef pthread_spinlock_t spinlock_t;
#define spin_lock(l) pthread_spin_lock(l)
#define spin_unlock(l) pthread_spin_unlock(l)
-#define SPINLOCK_INITIALIZER 1
#define spinlock_init(l) pthread_spin_init(l, 0)
#endif
diff --git a/accel-pppd/triton/triton.c b/accel-pppd/triton/triton.c
index b0adf573..05cbf210 100644
--- a/accel-pppd/triton/triton.c
+++ b/accel-pppd/triton/triton.c
@@ -16,13 +16,13 @@ int thread_count = 2;
int thread_count_max = 200;
int max_events = 64;
-static spinlock_t threads_lock = SPINLOCK_INITIALIZER;
+static spinlock_t threads_lock;
static LIST_HEAD(threads);
static LIST_HEAD(sleep_threads);
static LIST_HEAD(ctx_queue);
-static spinlock_t ctx_list_lock = SPINLOCK_INITIALIZER;
+static spinlock_t ctx_list_lock;
static LIST_HEAD(ctx_list);
static LIST_HEAD(init_list);
@@ -581,6 +581,9 @@ void __export triton_register_init(int order, void (*func)(void))
int __export triton_init(const char *conf_file)
{
+ spinlock_init(&threads_lock);
+ spinlock_init(&ctx_list_lock);
+
ctx_pool = mempool_create(sizeof(struct _triton_context_t));
call_pool = mempool_create(sizeof(struct _triton_ctx_call_t));