* Close down the current netVC. Save aside the socket and SSL information * and create new netVC in the current thread/netVC */
| 1354 | * and create new netVC in the current thread/netVC |
| 1355 | */ |
| 1356 | UnixNetVConnection * |
| 1357 | UnixNetVConnection::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 | |
| 1394 | void * |
| 1395 | UnixNetVConnection::_prepareForMigration() |
no test coverage detected