summaryrefslogtreecommitdiff
path: root/accel-pppd/triton
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2014-05-15 15:12:41 +0400
committerDmitry Kozlov <xeb@mail.ru>2014-05-15 15:12:41 +0400
commit0b3e64e4b056cf6b17c4bdc45100c11bcc116e8d (patch)
treeeb3223fcf159940242c73d6a47c68551601ab3f8 /accel-pppd/triton
parentec41e172a9da0de7cf5c28027928c698d0d1ebf8 (diff)
downloadaccel-ppp-0b3e64e4b056cf6b17c4bdc45100c11bcc116e8d.tar.gz
accel-ppp-0b3e64e4b056cf6b17c4bdc45100c11bcc116e8d.zip
triton: close file descriptors immediately in triton_unregister_handler
Diffstat (limited to 'accel-pppd/triton')
-rw-r--r--accel-pppd/triton/md.c23
-rw-r--r--accel-pppd/triton/triton_p.h1
2 files changed, 7 insertions, 17 deletions
diff --git a/accel-pppd/triton/md.c b/accel-pppd/triton/md.c
index a7eb5c8f..600b9680 100644
--- a/accel-pppd/triton/md.c
+++ b/accel-pppd/triton/md.c
@@ -96,23 +96,16 @@ static void *md_thread(void *arg)
if (r)
triton_thread_wakeup(h->ctx->thread);
}
-
- pthread_mutex_lock(&freed_list_lock);
- while (!list_empty(&freed_list)) {
- h = list_entry(freed_list.next, typeof(*h), entry);
- list_move(&h->entry, &freed_list2);
- }
- pthread_mutex_unlock(&freed_list_lock);
while (!list_empty(&freed_list2)) {
h = list_entry(freed_list2.next, typeof(*h), entry);
list_del(&h->entry);
- if (h->fd != -1) {
- r = epoll_ctl(epoll_fd, EPOLL_CTL_DEL, h->fd, NULL);
- close(h->fd);
- }
mempool_free(h);
}
+
+ pthread_mutex_lock(&freed_list_lock);
+ list_splice_init(&freed_list, &freed_list2);
+ pthread_mutex_unlock(&freed_list_lock);
}
return NULL;
@@ -139,14 +132,12 @@ void __export triton_md_register_handler(struct triton_context_t *ctx, struct tr
void __export triton_md_unregister_handler(struct triton_md_handler_t *ud, int c)
{
struct _triton_md_handler_t *h = (struct _triton_md_handler_t *)ud->tpd;
+
triton_md_disable_handler(ud, MD_MODE_READ | MD_MODE_WRITE);
-
+
if (c) {
- h->fd = ud->fd;
+ close(ud->fd);
ud->fd = -1;
- } else {
- triton_md_disable_handler(ud, MD_MODE_READ | MD_MODE_WRITE);
- h->fd = -1;
}
spin_lock(&h->ctx->lock);
diff --git a/accel-pppd/triton/triton_p.h b/accel-pppd/triton/triton_p.h
index d86f1bcc..443cedea 100644
--- a/accel-pppd/triton/triton_p.h
+++ b/accel-pppd/triton/triton_p.h
@@ -53,7 +53,6 @@ struct _triton_md_handler_t
struct _triton_context_t *ctx;
struct epoll_event epoll_event;
uint32_t trig_epoll_events;
- int fd;
int pending:1;
int trig_level:1;
struct triton_md_handler_t *ud;