summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-11-09 10:50:39 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:45:57 -0500
commita3fcb93df1571da51a0f525141c3010e7f2dcae6 (patch)
tree7919b40ffe1e48254fd51f8ffe751a78e0597df8
parent1fb239791379ba18858729b098b3d6af0e2d99a5 (diff)
downloadsamba-a3fcb93df1571da51a0f525141c3010e7f2dcae6.tar.gz
samba-a3fcb93df1571da51a0f525141c3010e7f2dcae6.tar.bz2
samba-a3fcb93df1571da51a0f525141c3010e7f2dcae6.zip
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 used to be commit d860eb795693d8c292eec2a639ece4793d28dc38)
-rw-r--r--source4/lib/stream/packet.c28
-rw-r--r--source4/lib/stream/packet.h1
2 files changed, 29 insertions, 0 deletions
diff --git a/source4/lib/stream/packet.c b/source4/lib/stream/packet.c
index 971135ff9b..50687d18fa 100644
--- a/source4/lib/stream/packet.c
+++ b/source4/lib/stream/packet.c
@@ -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;
}
@@ -262,8 +279,19 @@ 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;
diff --git a/source4/lib/stream/packet.h b/source4/lib/stream/packet.h
index 6d29264a28..b6ed8d6598 100644
--- a/source4/lib/stream/packet.h
+++ b/source4/lib/stream/packet.h
@@ -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);
/*