From b8527c1ea5a5d5cb5cc0037ae0aae02e52ab72b5 Mon Sep 17 00:00:00 2001 From: John Kohl Date: Wed, 20 Jul 1988 14:24:32 +0000 Subject: patches so it does packet fragmentation itself to insure that subscriptions are not split across packet boundaries --- lib/ZSubs.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 87 insertions(+), 13 deletions(-) (limited to 'lib/ZSubs.c') diff --git a/lib/ZSubs.c b/lib/ZSubs.c index 1bb3c1e..64999cd 100644 --- a/lib/ZSubs.c +++ b/lib/ZSubs.c @@ -44,6 +44,14 @@ Code_t ZCancelSubscriptions(port) CLIENT_CANCELSUB, 0)); } +static Code_t subscr_sendoff(); + +/* + * This routine must do its own fragmentation. Subscriptions must + * not be broken across packet boundaries, or else the server will + * mis-interpret them. + */ + Z_Subscriptions(sublist, nitems, port, opcode, authit) ZSubscription_t *sublist; int nitems; @@ -51,14 +59,20 @@ Z_Subscriptions(sublist, nitems, port, opcode, authit) char *opcode; int authit; { - int i, retval; - ZNotice_t notice, retnotice; + register int i, j; + int retval; + ZNotice_t notice; + char header[Z_MAXHEADERLEN]; char **list; - + int hdrlen; + int size_avail = Z_MAXPKTLEN-Z_FRAGFUDGE; /* space avail for data, + adjusted below */ + int size, start, numok; + list = (char **)malloc((unsigned)nitems*3*sizeof(char *)); if (!list) - return (ENOMEM); - + return (ENOMEM); + (void) bzero((char *)¬ice, sizeof(notice)); notice.z_kind = ACKED; notice.z_port = port; @@ -70,6 +84,19 @@ Z_Subscriptions(sublist, nitems, port, opcode, authit) notice.z_default_format = ""; notice.z_message_len = 0; + /* format the header to figure out how long it is */ + retval = Z_FormatHeader(¬ice, header, sizeof(header), &hdrlen, ZAUTH); + if (retval != ZERR_NONE && !authit) + retval = Z_FormatHeader(¬ice, header, sizeof(header), + &hdrlen, ZAUTH); + if (retval != ZERR_NONE) + return(retval); + + /* compute amount of room left */ + size_avail -= hdrlen; + size = size_avail; + + /* assemble subs into an array of pointers */ for (i=0;iz_uid)) != ZERR_NONE) return (retval); - if (retnotice.z_kind == SERVNAK) { ZFreeNotice(&retnotice); return (ZERR_SERVNAK); -- cgit v1.2.3