1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

r11602: added packet_set_serialise() to allow the generic packet layer to

handle optional request serialisation (this is something that is
commonly needed on stream connections)
This commit is contained in:
Andrew Tridgell 2005-11-09 10:50:39 +00:00 committed by Gerald (Jerry) Carter
parent b2b4969bdc
commit d860eb7956
2 changed files with 29 additions and 0 deletions

View File

@ -41,6 +41,9 @@ struct packet_context {
struct event_context *ev;
size_t packet_size;
void *private;
struct fd_event *fde;
BOOL serialise;
BOOL processing;
};
/*
@ -115,6 +118,16 @@ void packet_set_event_context(struct packet_context *pc, struct event_context *e
pc->ev = ev;
}
/*
tell the packet layer to serialise requests, so we don't process two requests at once on
one connection. You must have set the event_context
*/
void packet_set_serialise(struct packet_context *pc, struct fd_event *fde)
{
pc->serialise = True;
pc->fde = fde;
}
/*
tell the caller we have an error
@ -167,6 +180,10 @@ void packet_recv(struct packet_context *pc)
size_t nread;
DATA_BLOB blob;
if (pc->processing) {
return;
}
if (pc->packet_size != 0 && pc->num_read >= pc->packet_size) {
goto next_partial;
}
@ -263,7 +280,18 @@ next_partial:
pc->num_read -= pc->packet_size;
pc->packet_size = 0;
if (pc->serialise) {
EVENT_FD_NOT_READABLE(pc->fde);
pc->processing = True;
}
status = pc->callback(pc->private, blob);
if (pc->serialise) {
EVENT_FD_READABLE(pc->fde);
pc->processing = False;
}
if (!NT_STATUS_IS_OK(status)) {
packet_error(pc, status);
return;

View File

@ -38,6 +38,7 @@ void packet_set_full_request(struct packet_context *pc, packet_full_request_fn_t
void packet_set_tls(struct packet_context *pc, struct tls_context *tls);
void packet_set_socket(struct packet_context *pc, struct socket_context *sock);
void packet_set_event_context(struct packet_context *pc, struct event_context *ev);
void packet_set_serialise(struct packet_context *pc, struct fd_event *fde);
void packet_recv(struct packet_context *pc);
/*