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

Method migrateToCurrentThread

src/iocore/net/UnixNetVConnection.cc:1356–1392  ·  view source on GitHub ↗

* Close down the current netVC. Save aside the socket and SSL information * and create new netVC in the current thread/netVC */

Source from the content-addressed store, hash-verified

1354 * and create new netVC in the current thread/netVC
1355 */
1356UnixNetVConnection *
1357UnixNetVConnection::migrateToCurrentThread(Continuation *cont, EThread *t)
1358{
1359 NetHandler *client_nh = get_NetHandler(t);
1360 ink_assert(client_nh);
1361 if (this->nh == client_nh) {
1362 // We're already there!
1363 return this;
1364 }
1365
1366 Connection hold_con;
1367 hold_con.move(this->con);
1368
1369 void *arg = this->_prepareForMigration();
1370
1371 // Do_io_close will signal the VC to be freed on the original thread
1372 // Since we moved the con context, the fd will not be closed
1373 // Go ahead and remove the fd from the original thread's epoll structure, so it is not
1374 // processed on two threads simultaneously
1375 this->ep.stop();
1376
1377 // Create new VC:
1378 UnixNetVConnection *newvc = static_cast<UnixNetVConnection *>(this->_getNetProcessor()->allocate_vc(t));
1379 ink_assert(newvc != nullptr);
1380 if (newvc->populate(hold_con, cont, arg) != EVENT_DONE) {
1381 newvc->do_io_close();
1382 newvc = nullptr;
1383 }
1384 if (newvc) {
1385 newvc->set_context(get_context());
1386 newvc->options = this->options;
1387 }
1388
1389 // Do not mark this closed until the end so it does not get freed by the other thread too soon
1390 this->do_io_close();
1391 return newvc;
1392}
1393
1394void *
1395UnixNetVConnection::_prepareForMigration()

Callers 1

_acquire_sessionMethod · 0.80

Calls 9

_prepareForMigrationMethod · 0.95
_getNetProcessorMethod · 0.95
do_io_closeMethod · 0.95
get_NetHandlerFunction · 0.85
moveMethod · 0.80
stopMethod · 0.45
allocate_vcMethod · 0.45
populateMethod · 0.45
set_contextMethod · 0.45

Tested by

no test coverage detected