Changeset 1270 for trunk/gsdl/src/recpt/receptionist.cpp
- Timestamp:
- 2000-07-06T09:49:36+12:00 (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/receptionist.cpp
r1268 r1270 28 28 /* 29 29 $Log$ 30 Revision 1.53 2000/07/05 21:49:34 sjboddie 31 Receptionist now caches collection information to avoid making multiple 32 get_collectinfo calls to collection server 33 30 34 Revision 1.52 2000/07/04 02:15:22 sjboddie 31 35 fixed bug causing segmentation fault when an invalid collection … … 286 290 } 287 291 288 292 void collectioninfo_t::clear () { 293 gsdl_gsdlhome.clear(); 294 gsdl_gdbmhome.clear(); 295 296 info_loaded = false; 297 info.clear(); 298 } 289 299 290 300 receptionist::receptionist () { … … 1034 1044 colinfo_tmap::iterator colend = configinfo.collectinfo.end(); 1035 1045 while (colhere != colend) { 1036 gsdlmacrodir = filename_cat ((*colhere).second.gsdl_gsdlhome, "macros"); 1037 maindirs.insert (gsdlmacrodir); 1046 if (!((*colhere).second.gsdl_gsdlhome).empty()) { 1047 gsdlmacrodir = filename_cat ((*colhere).second.gsdl_gsdlhome, "macros"); 1048 maindirs.insert (gsdlmacrodir); 1049 } 1038 1050 colhere ++; 1039 1051 } … … 1126 1138 1127 1139 } else { 1128 ColInfoResponse_t cinfo; 1129 comerror_t err; 1130 1131 collectproto->get_collectinfo (arg_c, cinfo, err, logout); 1132 1133 if (!cinfo.ccsCols.empty()) { 1134 args["ccs"] = 1; 1135 if (args["cc"].empty()) { 1136 text_tarray::const_iterator col_here = cinfo.ccsCols.begin(); 1137 text_tarray::const_iterator col_end = cinfo.ccsCols.end(); 1138 bool first = true; 1139 while (col_here != col_end) { 1140 // make sure it's a valid collection 1141 if (protocols.getrecptproto (*col_here, logout) != NULL) { 1142 if (!first) args["cc"].push_back (','); 1143 args["cc"] += *col_here; 1144 first = false; 1140 1141 ColInfoResponse_t *cinfo = get_collectinfo_ptr (collectproto, arg_c, logout); 1142 1143 if (cinfo != NULL) { 1144 if (!cinfo->ccsCols.empty()) { 1145 args["ccs"] = 1; 1146 if (args["cc"].empty()) { 1147 text_tarray::const_iterator col_here = cinfo->ccsCols.begin(); 1148 text_tarray::const_iterator col_end = cinfo->ccsCols.end(); 1149 bool first = true; 1150 while (col_here != col_end) { 1151 // make sure it's a valid collection 1152 if (protocols.getrecptproto (*col_here, logout) != NULL) { 1153 if (!first) args["cc"].push_back (','); 1154 args["cc"] += *col_here; 1155 first = false; 1156 } 1157 col_here ++; 1145 1158 } 1146 col_here ++;1147 1159 } 1148 1160 } 1161 } else { 1162 logout << "ERROR (receptionist::check_mainargs): get_collectinfo_ptr returned NULL\n"; 1149 1163 } 1150 1164 } … … 1331 1345 } 1332 1346 } 1347 1348 // gets collection info from cache if found or 1349 // calls collection server (and updates cache) 1350 // returns NULL if there's an error 1351 ColInfoResponse_t *receptionist::get_collectinfo_ptr (recptproto *collectproto, 1352 const text_t &collection, 1353 ostream &logout) { 1354 1355 // check the cache 1356 colinfo_tmap::iterator it = configinfo.collectinfo.find (collection); 1357 if ((it != configinfo.collectinfo.end()) && ((*it).second.info_loaded)) { 1358 // found it 1359 return &((*it).second.info); 1360 } 1361 1362 // not cached, get info from collection server 1363 if (collectproto == NULL) { 1364 logout << "ERROR: receptionist::get_collectinfo_ptr passed null collectproto\n"; 1365 return NULL; 1366 } 1367 1368 comerror_t err; 1369 if (it == configinfo.collectinfo.end()) { 1370 collectioninfo_t cinfo; 1371 collectproto->get_collectinfo (collection, cinfo.info, err, logout); 1372 if (err != noError) { 1373 outconvertclass text_t2ascii; 1374 logout << text_t2ascii << "ERROR (receptionist::getcollectinfo_ptr): \"" 1375 << get_comerror_string (err) << "\"while getting collectinfo\n"; 1376 return NULL; 1377 } 1378 cinfo.info_loaded = true; 1379 configinfo.collectinfo[collection] = cinfo; 1380 return &(configinfo.collectinfo[collection].info); 1381 } else { 1382 collectproto->get_collectinfo (collection, (*it).second.info, err, logout); 1383 if (err != noError) { 1384 outconvertclass text_t2ascii; 1385 logout << text_t2ascii << "ERROR (receptionist::getcollectinfo_ptr): \"" 1386 << get_comerror_string (err) << "\"while getting collectinfo\n"; 1387 return NULL; 1388 } 1389 (*it).second.info_loaded = true; 1390 return &((*it).second.info); 1391 } 1392 }
Note:
See TracChangeset
for help on using the changeset viewer.