X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=server%2Fseshigh.c;h=0fd64e9f9bd931fce2c7dda2fe188da72c2a05f7;hb=7f4183f05884c781eb395a17e4282485c618ded6;hp=a9dfd99fd0a91732e7cf2cd7b02586bc84e4c2b4;hpb=1c2df7a209b83db0b04700abff3512c0abf5d967;p=yaz-moved-to-github.git diff --git a/server/seshigh.c b/server/seshigh.c index a9dfd99..0fd64e9 100644 --- a/server/seshigh.c +++ b/server/seshigh.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: seshigh.c,v $ - * Revision 1.44 1995-08-17 12:45:25 quinn + * Revision 1.45 1995-08-21 09:11:00 quinn + * Smallish fixes to suppport new formats. + * + * Revision 1.44 1995/08/17 12:45:25 quinn * Fixed minor problems with GRS-1. Added support in c&s. * * Revision 1.43 1995/08/15 12:00:31 quinn @@ -756,7 +759,14 @@ static Z_Records *pack_records(association *a, char *setname, int start, bend_fetchresult *fres; Z_NamePlusRecord *thisrec; Z_DatabaseRecord *thisext; - + int this_length; + + /* + * we get the number of bytes allocated on the stream before any + * allocation done by the backend - this should give us a reasonable + * idea of the total size of the data so far. + */ + total_length = odr_total(a->encode); if (reclist.num_records == MAX_RECORDS - 1) { *pres = Z_PRES_PARTIAL_2; @@ -778,19 +788,23 @@ static Z_Records *pack_records(association *a, char *setname, int start, *pres = Z_PRES_FAILURE; return diagrec(a->proto, fres->errcode, fres->errstring); } + if (fres->len >= 0) + this_length = fres->len; + else + this_length = odr_total(a->encode) - total_length; logf(LOG_DEBUG, " fetched record, len=%d, total=%d", - fres->len, total_length); - if (fres->len + total_length > a->preferredMessageSize) + this_length, total_length); + if (this_length + total_length > a->preferredMessageSize) { /* record is small enough, really */ - if (fres->len <= a->preferredMessageSize) + if (this_length <= a->preferredMessageSize) { logf(LOG_DEBUG, " Dropped last normal-sized record"); *pres = Z_PRES_PARTIAL_2; break; } /* record can only be fetched by itself */ - if (fres->len < a->maximumRecordSize) + if (this_length < a->maximumRecordSize) { logf(LOG_DEBUG, " Record > prefmsgsz"); if (toget > 1) @@ -799,7 +813,6 @@ static Z_Records *pack_records(association *a, char *setname, int start, reclist.records[reclist.num_records] = surrogatediagrec(a->proto, fres->basename, 16, 0); reclist.num_records++; - total_length += 10; /* totally arbitrary */ continue; } } @@ -809,7 +822,6 @@ static Z_Records *pack_records(association *a, char *setname, int start, reclist.records[reclist.num_records] = surrogatediagrec(a->proto, fres->basename, 17, 0); reclist.num_records++; - total_length += 10; /* totally arbitrary */ continue; } } @@ -877,7 +889,6 @@ static Z_Records *pack_records(association *a, char *setname, int start, } reclist.records[reclist.num_records] = thisrec; reclist.num_records++; - total_length += fres->len; *next = fres->last_in_set ? 0 : recno + 1; } *num = reclist.num_records;