MCPcopy Create free account
hub / github.com/apache/trafficserver / transfer_objects

Method transfer_objects

src/proxy/logging/LogObject.cc:1226–1280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1224}
1225
1226void
1227LogObjectManager::transfer_objects(LogObjectManager &old_mgr)
1228{
1229 Dbg(dbg_ctl_log_config_transfer, "transferring objects from LogObjectManager %p, to %p", &old_mgr, this);
1230
1231 if (dbg_ctl_log_config_transfer.on()) {
1232 Dbg(dbg_ctl_log_config_transfer, "TRANSFER OBJECTS: list of old objects");
1233 for (auto &_object : old_mgr._objects) {
1234 Dbg(dbg_ctl_log_config_transfer, "%s", _object->get_original_filename());
1235 }
1236
1237 Dbg(dbg_ctl_log_config_transfer, "TRANSFER OBJECTS : list of new objects");
1238 for (unsigned i = 0; i < this->_objects.size(); i++) {
1239 Dbg(dbg_ctl_log_config_transfer, "%s", _objects[i]->get_original_filename());
1240 }
1241 }
1242
1243 // Transfer the API objects from the old manager. The old manager will retain its refcount.
1244 for (auto &_APIobject : old_mgr._APIobjects) {
1245 manage_api_object(_APIobject);
1246 }
1247
1248 for (auto old_obj : old_mgr._objects) {
1249 LogObject *new_obj;
1250
1251 Dbg(dbg_ctl_log_config_transfer, "examining existing object %s", old_obj->get_base_filename());
1252
1253 // See if any of the new objects is just a copy of an old one. If so, transfer the
1254 // old one to the new manager and delete the new one. We don't use Vec::in here because
1255 // we need to compare the object hash, not the pointers.
1256 for (unsigned j = 0; j < _objects.size(); j++) {
1257 new_obj = _objects[j];
1258
1259 Dbg(dbg_ctl_log_config_transfer, "comparing existing object %s to new object %s", old_obj->get_base_filename(),
1260 new_obj->get_base_filename());
1261
1262 if (*new_obj == *old_obj) {
1263 Dbg(dbg_ctl_log_config_transfer, "keeping existing object %s", old_obj->get_base_filename());
1264
1265 old_obj->refcount_inc();
1266 this->_objects[j] = old_obj;
1267
1268 if (new_obj->refcount_dec() == 0) {
1269 delete new_obj;
1270 }
1271 break;
1272 }
1273 }
1274 }
1275
1276 if (dbg_ctl_log_config_transfer.on()) {
1277 Dbg(dbg_ctl_log_config_transfer, "Log Object List after transfer:");
1278 display();
1279 }
1280}
1281
1282unsigned
1283LogObjectManager::roll_files(long time_now)

Calls 6

get_original_filenameMethod · 0.80
get_base_filenameMethod · 0.80
refcount_incMethod · 0.80
refcount_decMethod · 0.80
onMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected