svn commit: samba r11602 - in branches/SAMBA_4_0/source/lib/stream:
.
tridge at samba.org
tridge at samba.org
Wed Nov 9 10:50:39 GMT 2005
Author: tridge
Date: 2005-11-09 10:50:39 +0000 (Wed, 09 Nov 2005)
New Revision: 11602
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=11602
Log:
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)
Modified:
branches/SAMBA_4_0/source/lib/stream/packet.c
branches/SAMBA_4_0/source/lib/stream/packet.h
Changeset:
Modified: branches/SAMBA_4_0/source/lib/stream/packet.c
===================================================================
--- branches/SAMBA_4_0/source/lib/stream/packet.c 2005-11-09 10:17:05 UTC (rev 11601)
+++ branches/SAMBA_4_0/source/lib/stream/packet.c 2005-11-09 10:50:39 UTC (rev 11602)
@@ -41,6 +41,9 @@
struct event_context *ev;
size_t packet_size;
void *private;
+ struct fd_event *fde;
+ BOOL serialise;
+ BOOL processing;
};
/*
@@ -115,7 +118,17 @@
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 @@
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 @@
}
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;
Modified: branches/SAMBA_4_0/source/lib/stream/packet.h
===================================================================
--- branches/SAMBA_4_0/source/lib/stream/packet.h 2005-11-09 10:17:05 UTC (rev 11601)
+++ branches/SAMBA_4_0/source/lib/stream/packet.h 2005-11-09 10:50:39 UTC (rev 11602)
@@ -38,6 +38,7 @@
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);
/*
More information about the samba-cvs
mailing list