mirror of
https://github.com/samba-team/samba.git
synced 2025-09-20 17:44:21 +03:00
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.
This commit is contained in:
@@ -42,6 +42,7 @@ struct packet_context {
|
|||||||
bool serialise;
|
bool serialise;
|
||||||
int processing;
|
int processing;
|
||||||
bool recv_disable;
|
bool recv_disable;
|
||||||
|
bool recv_need_enable;
|
||||||
bool nofree;
|
bool nofree;
|
||||||
|
|
||||||
bool busy;
|
bool busy;
|
||||||
@@ -256,6 +257,7 @@ _PUBLIC_ void packet_recv(struct packet_context *pc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pc->recv_disable) {
|
if (pc->recv_disable) {
|
||||||
|
pc->recv_need_enable = true;
|
||||||
EVENT_FD_NOT_READABLE(pc->fde);
|
EVENT_FD_NOT_READABLE(pc->fde);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -464,7 +466,6 @@ next_partial:
|
|||||||
*/
|
*/
|
||||||
_PUBLIC_ void packet_recv_disable(struct packet_context *pc)
|
_PUBLIC_ void packet_recv_disable(struct packet_context *pc)
|
||||||
{
|
{
|
||||||
EVENT_FD_NOT_READABLE(pc->fde);
|
|
||||||
pc->recv_disable = true;
|
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)
|
_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;
|
pc->recv_disable = false;
|
||||||
if (pc->num_read != 0 && pc->packet_size >= pc->num_read) {
|
if (pc->num_read != 0 && pc->packet_size >= pc->num_read) {
|
||||||
event_add_timed(pc->ev, pc, timeval_zero(), packet_next_event, pc);
|
event_add_timed(pc->ev, pc, timeval_zero(), packet_next_event, pc);
|
||||||
|
Reference in New Issue
Block a user