summaryrefslogtreecommitdiff
path: root/accel-pppd/triton
diff options
context:
space:
mode:
Diffstat (limited to 'accel-pppd/triton')
-rw-r--r--accel-pppd/triton/conf_file.c13
-rw-r--r--accel-pppd/triton/mempool.c12
-rw-r--r--accel-pppd/triton/triton.c4
-rw-r--r--accel-pppd/triton/triton_p.h8
4 files changed, 21 insertions, 16 deletions
diff --git a/accel-pppd/triton/conf_file.c b/accel-pppd/triton/conf_file.c
index e1d9650b..b5c650ef 100644
--- a/accel-pppd/triton/conf_file.c
+++ b/accel-pppd/triton/conf_file.c
@@ -56,21 +56,21 @@ static int __conf_load(struct conf_ctx *ctx, const char *fname)
static int load_file(struct conf_ctx *ctx)
{
- char *str2, *raw;
+ char *str2;
char buf[1024] = {0};
static struct conf_sect_t *cur_sect = NULL;
while(1) {
int len;
- char *str;
+ char *str, *raw;
if (!fgets(buf, 1024, ctx->file))
break;
ctx->line++;
len = strlen(buf);
- if (buf[len - 1] == '\n')
+ if (len && buf[len - 1] == '\n')
buf[--len] = 0;
while (len && (buf[len - 1] == ' ' || buf[len - 1] == '\t'))
@@ -109,14 +109,14 @@ static int load_file(struct conf_ctx *ctx)
continue;
}
- if (*str == '}' && ctx->items != &cur_sect->items)
- return 0;
-
if (!cur_sect) {
fprintf(stderr, "conf_file:%s:%i: no section opened\n", ctx->fname, ctx->line);
return -1;
}
+ if (*str == '}' && ctx->items != &cur_sect->items)
+ return 0;
+
raw = _strdup(str);
str2 = skip_word(str);
if (*str2 == ' ') {
@@ -139,6 +139,7 @@ static int load_file(struct conf_ctx *ctx)
opt = find_item(cur_sect, str2);
if (!opt) {
fprintf(stderr, "conf_file:%s:%i: parent option not found\n", ctx->fname, ctx->line);
+ _free(raw);
return -1;
}
str2 = opt->val;
diff --git a/accel-pppd/triton/mempool.c b/accel-pppd/triton/mempool.c
index 923119aa..ea6d1e6d 100644
--- a/accel-pppd/triton/mempool.c
+++ b/accel-pppd/triton/mempool.c
@@ -32,7 +32,7 @@ struct _mempool_t
uint64_t magic;
#endif
spinlock_t lock;
- int mmap:1;
+ unsigned int mmap:1;
int objects;
};
@@ -55,8 +55,8 @@ struct _item_t
static LIST_HEAD(pools);
static spinlock_t pools_lock;
static spinlock_t mmap_lock;
-static void *mmap_ptr;
-static void *mmap_endptr;
+static uint8_t *mmap_ptr;
+static uint8_t *mmap_endptr;
static int mmap_grow(void);
static void mempool_clean(void);
@@ -113,8 +113,10 @@ void __export *mempool_alloc(mempool_t *pool)
if (p->mmap) {
spin_lock(&mmap_lock);
if (mmap_ptr + size >= mmap_endptr) {
- if (mmap_grow())
+ if (mmap_grow()) {
+ spin_unlock(&mmap_lock);
return NULL;
+ }
}
it = (struct _item_t *)mmap_ptr;
mmap_ptr += size;
@@ -256,7 +258,7 @@ static void sigclean(int num)
static int mmap_grow(void)
{
int size = sysconf(_SC_PAGESIZE) * (1 << PAGE_ORDER);
- void *ptr;
+ uint8_t *ptr;
if (mmap_endptr) {
ptr = mmap(mmap_endptr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
diff --git a/accel-pppd/triton/triton.c b/accel-pppd/triton/triton.c
index 7cd70558..a8819109 100644
--- a/accel-pppd/triton/triton.c
+++ b/accel-pppd/triton/triton.c
@@ -742,8 +742,10 @@ void __export triton_run()
for(i = 0; i < thread_count; i++) {
t = create_thread();
- if (!t)
+ if (!t) {
+ triton_log_error("triton_run:create_thread: %s", strerror(errno));
_exit(-1);
+ }
list_add_tail(&t->entry, &threads);
pthread_mutex_unlock(&t->sleep_lock);
diff --git a/accel-pppd/triton/triton_p.h b/accel-pppd/triton/triton_p.h
index a727e62e..bc39d626 100644
--- a/accel-pppd/triton/triton_p.h
+++ b/accel-pppd/triton/triton_p.h
@@ -61,9 +61,9 @@ struct _triton_md_handler_t
struct epoll_event epoll_event;
uint32_t trig_epoll_events;
int pending;
- int trig_level:1;
- int armed:1;
- int mod:1;
+ unsigned int trig_level:1;
+ unsigned int armed:1;
+ unsigned int mod:1;
struct triton_md_handler_t *ud;
};
@@ -74,7 +74,7 @@ struct _triton_timer_t
struct epoll_event epoll_event;
struct _triton_context_t *ctx;
int fd;
- int pending:1;
+ unsigned int pending:1;
struct triton_timer_t *ud;
};