Skip to content

Commit 82dc277

Browse files
committed
Avoid stale client_vc
1 parent 3204235 commit 82dc277

File tree

4 files changed

+14
-26
lines changed

4 files changed

+14
-26
lines changed

iocore/net/UnixNetVConnection.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ read_signal_and_update(int event, UnixNetVConnection *vc)
8888
case VC_EVENT_ACTIVE_TIMEOUT:
8989
case VC_EVENT_INACTIVITY_TIMEOUT:
9090
Debug("inactivity_cop", "event %d: null read.vio cont, closing vc %p", event, vc);
91+
Warning("read: Closing orphaned vc %p", vc);
9192
vc->closed = 1;
9293
break;
9394
default:
@@ -119,6 +120,7 @@ write_signal_and_update(int event, UnixNetVConnection *vc)
119120
case VC_EVENT_ACTIVE_TIMEOUT:
120121
case VC_EVENT_INACTIVITY_TIMEOUT:
121122
Debug("inactivity_cop", "event %d: null write.vio cont, closing vc %p", event, vc);
123+
Warning("write: Closing orphaned vc %p", vc);
122124
vc->closed = 1;
123125
break;
124126
default:

proxy/http/Http1ClientSession.cc

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,6 @@ Http1ClientSession::free()
111111
conn_decrease = false;
112112
}
113113

114-
// Clean up the write VIO in case of inactivity timeout
115-
this->do_io_write(nullptr, 0, nullptr);
116-
117114
// Free the transaction resources
118115
this->trans.super_type::destroy();
119116

@@ -250,12 +247,13 @@ Http1ClientSession::do_io_close(int alerrno)
250247
slave_ka_vio = nullptr;
251248
}
252249
// Completed the last transaction. Just shutdown already
253-
if (transact_count == released_transactions) {
250+
// Or the do_io_close is due to a network error
251+
if (transact_count == released_transactions || alerrno == HTTP_ERRNO) {
254252
half_close = false;
255253
}
256254

257255
// Clean up the write VIO in case of inactivity timeout
258-
this->do_io_write(nullptr, 0, nullptr);
256+
this->do_io_write(this, 0, nullptr);
259257

260258
if (half_close && this->trans.get_sm()) {
261259
read_state = HCS_HALF_CLOSED;
@@ -315,11 +313,7 @@ Http1ClientSession::state_wait_for_close(int event, void *data)
315313
case VC_EVENT_ACTIVE_TIMEOUT:
316314
case VC_EVENT_INACTIVITY_TIMEOUT:
317315
half_close = false;
318-
this->do_io_close();
319-
if (client_vc != nullptr) {
320-
client_vc->do_io_close();
321-
client_vc = nullptr;
322-
}
316+
this->do_io_close(EHTTP_ERROR);
323317
break;
324318
case VC_EVENT_READ_READY:
325319
// Drain any data read
@@ -395,11 +389,7 @@ Http1ClientSession::state_keep_alive(int event, void *data)
395389
break;
396390

397391
case VC_EVENT_EOS:
398-
this->do_io_close();
399-
if (client_vc != nullptr) {
400-
client_vc->do_io_close();
401-
client_vc = nullptr;
402-
}
392+
this->do_io_close(EHTTP_ERROR);
403393
break;
404394

405395
case VC_EVENT_READ_COMPLETE:
@@ -411,7 +401,7 @@ Http1ClientSession::state_keep_alive(int event, void *data)
411401
case VC_EVENT_ACTIVE_TIMEOUT:
412402
case VC_EVENT_INACTIVITY_TIMEOUT:
413403
// Keep-alive timed out
414-
this->do_io_close();
404+
this->do_io_close(EHTTP_ERROR);
415405
break;
416406
}
417407

@@ -430,7 +420,7 @@ Http1ClientSession::release(ProxyTransaction *trans)
430420
ink_assert(read_state == HCS_ACTIVE_READER || read_state == HCS_INIT);
431421

432422
// Clean up the write VIO in case of inactivity timeout
433-
this->do_io_write(nullptr, 0, nullptr);
423+
this->do_io_write(this, 0, nullptr);
434424

435425
// Check to see there is remaining data in the
436426
// buffer. If there is, spin up a new state

proxy/http/HttpSM.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2763,7 +2763,7 @@ HttpSM::tunnel_handler_post(int event, void *data)
27632763
if (ua_entry->write_buffer) {
27642764
free_MIOBuffer(ua_entry->write_buffer);
27652765
ua_entry->write_buffer = nullptr;
2766-
ua_entry->vc->do_io_write(nullptr, 0, nullptr);
2766+
ua_entry->vc->do_io_write(this, 0, nullptr);
27672767
}
27682768
if (!p->handler_state) {
27692769
p->handler_state = HTTP_SM_POST_UA_FAIL;
@@ -3510,7 +3510,7 @@ HttpSM::tunnel_handler_post_ua(int event, HttpTunnelProducer *p)
35103510
// if it is active timeout case, we need to give another chance to send 408 response;
35113511
ua_txn->set_active_timeout(HRTIME_SECONDS(t_state.txn_conf->transaction_active_timeout_in));
35123512

3513-
p->vc->do_io_write(nullptr, 0, nullptr);
3513+
p->vc->do_io_write(this, 0, nullptr);
35143514
p->vc->do_io_shutdown(IO_SHUTDOWN_READ);
35153515

35163516
return 0;
@@ -3524,7 +3524,7 @@ HttpSM::tunnel_handler_post_ua(int event, HttpTunnelProducer *p)
35243524
// server and close the ua
35253525
p->handler_state = HTTP_SM_POST_UA_FAIL;
35263526
set_ua_abort(HttpTransact::ABORTED, event);
3527-
p->vc->do_io_write(nullptr, 0, nullptr);
3527+
p->vc->do_io_write(this, 0, nullptr);
35283528
p->vc->do_io_shutdown(IO_SHUTDOWN_READ);
35293529
tunnel.chain_abort_all(p);
35303530
server_session = nullptr;

proxy/http2/Http2ClientSession.cc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,8 @@ Http2ClientSession::do_io_close(int alerrno)
308308

309309
this->clear_session_active();
310310

311-
// Clean up the write VIO in case of inactivity timeout
312-
this->do_io_write(nullptr, 0, nullptr);
311+
// Point the write_vio at the session in case of inactivity timeout
312+
this->do_io_write(this, 0, nullptr);
313313
}
314314

315315
void
@@ -377,10 +377,6 @@ Http2ClientSession::main_event_handler(int event, void *edata)
377377
case VC_EVENT_EOS:
378378
this->set_dying_event(event);
379379
this->do_io_close();
380-
if (client_vc != nullptr) {
381-
client_vc->do_io_close();
382-
client_vc = nullptr;
383-
}
384380
retval = 0;
385381
break;
386382

0 commit comments

Comments
 (0)