summaryrefslogtreecommitdiff
path: root/accel-pptpd/triton/md.c
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2010-09-20 01:09:07 +0400
committerDmitry Kozlov <xeb@mail.ru>2010-09-20 01:09:34 +0400
commitb96fbc3f966b012720d2b74b1dfd2a0ab95086cf (patch)
tree606750874faf65029f756dc0b401ee40cc4da89f /accel-pptpd/triton/md.c
parentd860a4beaf5f99d5045d03b931b4829426a2f7b0 (diff)
downloadaccel-ppp-b96fbc3f966b012720d2b74b1dfd2a0ab95086cf.tar.gz
accel-ppp-b96fbc3f966b012720d2b74b1dfd2a0ab95086cf.zip
fixed many bugs and memory leaks
Diffstat (limited to 'accel-pptpd/triton/md.c')
-rw-r--r--accel-pptpd/triton/md.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/accel-pptpd/triton/md.c b/accel-pptpd/triton/md.c
index 05d814cc..06b2b30b 100644
--- a/accel-pptpd/triton/md.c
+++ b/accel-pptpd/triton/md.c
@@ -8,6 +8,8 @@
#include "triton_p.h"
+#include "memdebug.h"
+
extern int max_events;
static int epoll_fd;
@@ -26,7 +28,7 @@ int md_init(void)
return -1;
}
- epoll_events = malloc(max_events * sizeof(struct epoll_event));
+ epoll_events = _malloc(max_events * sizeof(struct epoll_event));
if (!epoll_events) {
fprintf(stderr,"md:cann't allocate memory\n");
return -1;
@@ -54,6 +56,20 @@ static void *md_thread(void *arg)
{
int i,n,r;
struct _triton_md_handler_t *h;
+ sigset_t set;
+
+ sigfillset(&set);
+ pthread_sigmask(SIG_BLOCK, &set, NULL);
+
+ sigemptyset(&set);
+ sigaddset(&set, SIGQUIT);
+ sigaddset(&set, SIGSEGV);
+ sigaddset(&set, SIGFPE);
+ sigaddset(&set, SIGILL);
+ sigaddset(&set, SIGBUS);
+ sigdelset(&set, 35);
+ sigdelset(&set, 36);
+ pthread_sigmask(SIG_UNBLOCK, &set, NULL);
while(1) {
n = epoll_wait(epoll_fd, epoll_events, max_events, -1);
@@ -100,6 +116,8 @@ void __export triton_md_register_handler(struct triton_context_t *ctx, struct tr
spin_lock(&h->ctx->lock);
list_add_tail(&h->entry, &h->ctx->handlers);
spin_unlock(&h->ctx->lock);
+
+ __sync_fetch_and_add(&triton_stat.md_handler_count, 1);
}
void __export triton_md_unregister_handler(struct triton_md_handler_t *ud)
{
@@ -113,6 +131,8 @@ void __export triton_md_unregister_handler(struct triton_md_handler_t *ud)
spin_unlock(&h->ctx->lock);
sched_yield();
mempool_free(h);
+
+ __sync_fetch_and_sub(&triton_stat.md_handler_count, 1);
}
int __export triton_md_enable_handler(struct triton_md_handler_t *ud, int mode)
{