Changeset 1617


Ignore:
Timestamp:
2000-10-26T19:40:20+13:00 (24 years ago)
Author:
jrm21
Message:

Added some flags so we don't connect to the z-server as often as we were...
z3950proto::filter is called 8 times for a get document request!!!!!
Actually, this also fixed a problem I was having connecting to a particular
zserver, as the server was returning an error on about the 7th call to filter()

Location:
trunk/gsdl/src/recpt
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/z3950proto.cpp

    r1453 r1617  
    3434#include "z3950cfg.h" // for reading in config files -
    3535// defines "struct z3950cfg *zserver_list" as the head of the list.
     36
     37// note! yyin is hash-defined in z3950cfg.h to something else, to avoid
     38// name conflicts with "other" yyins.
    3639extern FILE *yyin;
    3740extern "C" {
  • trunk/gsdl/src/recpt/z3950server.cpp

    r1371 r1617  
    4141  connected=false;
    4242  titles=NULL;
     43  gotsinglerecord=false;
    4344  // for now, assume that all records will have text associated with them.
    4445  meta["hastxt"]="1";
     
    157158                       int first, int count,
    158159                       int *nummatches, comerror_t &err) {
    159   char **c_str_titles;
     160  /* NOTE!!!!!! Because this code currently only works in cgi-bin mode,
     161     we only ever do one request. Therefore, it is CURRENTLY OK to store
     162     (cache) the retrieved titles, because if this function is ever called
     163     more than once, the arguments will be the same each time.
     164     (I think :)
     165  */
     166
     167  char **c_str_titles;
    160168  int i;
    161169  int last;
    162   if (titles!=NULL) delete (titles);
     170
     171  if (gotsinglerecord==true) {
     172    /* If true, then this whole execution was done to retrieve a single
     173       document. Therefore, the list of titles of all records matching the
     174       query isn't actually required. It's just that for some reason our
     175       filter (z3950proto::filter) gets called at least 7 times, with the
     176       7th being a "QueryFilter" for some reason... */
     177    nummatches=0;
     178    return NULL; /* shouldn't really return NULL, but nummatches is checked
     179            first (I hope) */
     180  }
     181
     182  //  if (titles!=NULL) delete (titles);
     183  if (titles!=NULL) return titles;
    163184  titles=new text_tarray;
    164185
     
    218239                 text_t &rettitle,
    219240                 text_t &rettext, comerror_t &err) {
     241
     242  static char **c_str_titles=NULL;
     243  static char *fulltext=NULL;
     244  /* NOTE!!!!!! Because this code currently only works in cgi-bin mode,
     245     we only ever do one request. Therefore, it is CURRENTLY OK to store
     246     (cache) the retrieved titles, because if this function is ever called
     247     more than once, the arguments will be the same each time.
     248     (I think :)
     249  */
     250
     251  gotsinglerecord=true; // well, not yet, but we've been called...
     252
    220253  if (connected==false) {
    221254    if (connect()==false) {
     
    239272  }
    240273
     274  if (c_str_titles==NULL)
     275    c_str_titles=z_getrecordTitles(ID,1); // check this return value.
     276 
    241277  if (rettitle!="unneeded") {
    242     char **c_str_titles;
    243278    //int dummy;
    244     c_str_titles=z_getrecordTitles(ID,1); // check this return value.
    245279    if (c_str_titles!=NULL && (int)c_str_titles[0]==1) {
    246280      rettitle.setcstr(c_str_titles[1]); // and check this
    247       free (c_str_titles);
    248       // rettitle="Dummy Title";
     281      //////      free (c_str_titles); - we want to "cache" it
    249282    } else {
    250283      // we didn't get something....
     
    253286  }
    254287
     288  if (fulltext==NULL)
     289    // get the text
     290    fulltext=z_getfullRecord(ID);
     291
    255292  if (rettext!="unneeded") {
    256     // get the text
    257     rettext.setcstr(z_getfullRecord(ID));
     293    rettext.setcstr(fulltext);
    258294  }
    259295  return (true);
  • trunk/gsdl/src/recpt/z3950server.h

    r1371 r1617  
    4141  bool connect();
    4242  bool connected; // tcp connection to the z39.50 server (target)
     43  bool gotsinglerecord; // if we do, then we don't need all titles...
    4344
    4445 public:
Note: See TracChangeset for help on using the changeset viewer.