summaryrefslogtreecommitdiff
path: root/accel-pppd/triton/triton.c
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2014-05-12 13:50:15 +0400
committerDmitry Kozlov <xeb@mail.ru>2014-05-12 13:50:15 +0400
commit0c0bdd363b63319c7484f5cfbe6dd74a15b884be (patch)
tree1e5e4f596347cd80a57af5ca68b37eb27fcd91d5 /accel-pppd/triton/triton.c
parent7466e7f10fb4813a6112682dff13de5fbdd981a7 (diff)
downloadaccel-ppp-0c0bdd363b63319c7484f5cfbe6dd74a15b884be.tar.gz
accel-ppp-0c0bdd363b63319c7484f5cfbe6dd74a15b884be.zip
triton: improved epoll events handling
Diffstat (limited to 'accel-pppd/triton/triton.c')
-rw-r--r--accel-pppd/triton/triton.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/accel-pppd/triton/triton.c b/accel-pppd/triton/triton.c
index 8bde56da..ef9078b8 100644
--- a/accel-pppd/triton/triton.c
+++ b/accel-pppd/triton/triton.c
@@ -183,6 +183,7 @@ static void ctx_thread(struct _triton_context_t *ctx)
struct _triton_timer_t *t;
struct _triton_ctx_call_t *call;
uint64_t tt;
+ int events;
log_debug2("ctx %p %p: enter\n", ctx, ctx->thread);
@@ -199,23 +200,33 @@ static void ctx_thread(struct _triton_context_t *ctx)
t->ud->expire(t->ud);
continue;
}
+
if (!list_empty(&ctx->pending_handlers)) {
h = list_entry(ctx->pending_handlers.next, typeof(*h), entry2);
list_del(&h->entry2);
h->pending = 0;
+ events = h->trig_epoll_events;
spin_unlock(&ctx->lock);
+
__sync_sub_and_fetch(&triton_stat.md_handler_pending, 1);
- if (h->trig_epoll_events & (EPOLLIN | EPOLLERR | EPOLLHUP))
- if (h->ud && h->ud->read)
+
+ if ((events & (EPOLLIN | EPOLLERR | EPOLLHUP)) && (h->epoll_event.events & EPOLLIN)) {
+ if (h->ud && h->ud->read) {
if (h->ud->read(h->ud))
continue;
- if (h->trig_epoll_events & (EPOLLOUT | EPOLLERR | EPOLLHUP))
- if (h->ud && h->ud->write)
+ }
+ }
+
+ if ((events & (EPOLLOUT | EPOLLERR | EPOLLHUP)) && (h->epoll_event.events & EPOLLOUT)) {
+ if (h->ud && h->ud->write) {
if (h->ud->write(h->ud))
continue;
- h->trig_epoll_events = 0;
+ }
+ }
+
continue;
}
+
if (!list_empty(&ctx->pending_calls)) {
call = list_entry(ctx->pending_calls.next, typeof(*call), entry);
list_del(&call->entry);
@@ -224,6 +235,7 @@ static void ctx_thread(struct _triton_context_t *ctx)
mempool_free(call);
continue;
}
+
ctx->pending = 0;
spin_unlock(&ctx->lock);
break;