diff options
author | Andrew Tridgell <tridge@samba.org> | 2010-09-07 11:55:47 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-09-07 12:55:27 +1000 |
commit | a8bac4a09a4a81c280c62fb4dcdbd0e61c782479 (patch) | |
tree | 3f17972292a4d07cc7cdb4ae0ad064805c1697d8 /source4 | |
parent | cad0219e69d2acc766583083c0738c2b9ea3901f (diff) | |
download | samba-a8bac4a09a4a81c280c62fb4dcdbd0e61c782479.tar.gz samba-a8bac4a09a4a81c280c62fb4dcdbd0e61c782479.tar.bz2 samba-a8bac4a09a4a81c280c62fb4dcdbd0e61c782479.zip |
s4-packet: make packet_recv_disable() a lot more efficient
this avoids doing an epoll system call when we want to prevent receipt
of packets on a socket, unless there actually is a packet to receive.
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/stream/packet.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/source4/lib/stream/packet.c b/source4/lib/stream/packet.c index 251d951e70..98343707c1 100644 --- a/source4/lib/stream/packet.c +++ b/source4/lib/stream/packet.c @@ -42,6 +42,7 @@ struct packet_context { bool serialise; int processing; bool recv_disable; + bool recv_need_enable; bool nofree; bool busy; @@ -256,6 +257,7 @@ _PUBLIC_ void packet_recv(struct packet_context *pc) } if (pc->recv_disable) { + pc->recv_need_enable = true; EVENT_FD_NOT_READABLE(pc->fde); return; } @@ -464,7 +466,6 @@ next_partial: */ _PUBLIC_ void packet_recv_disable(struct packet_context *pc) { - EVENT_FD_NOT_READABLE(pc->fde); pc->recv_disable = true; } @@ -473,7 +474,10 @@ _PUBLIC_ void packet_recv_disable(struct packet_context *pc) */ _PUBLIC_ void packet_recv_enable(struct packet_context *pc) { - EVENT_FD_READABLE(pc->fde); + if (pc->recv_need_enable) { + pc->recv_need_enable = false; + EVENT_FD_READABLE(pc->fde); + } pc->recv_disable = false; if (pc->num_read != 0 && pc->packet_size >= pc->num_read) { event_add_timed(pc->ev, pc, timeval_zero(), packet_next_event, pc); |