Skip to content

Commit 751b24a

Browse files
committed
Track scheduled events to (read|write)_vio.cont from Http2Stream
1 parent dc0fb99 commit 751b24a

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

proxy/http2/Http2Stream.cc

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,20 @@ Http2Stream::main_event_handler(int event, void *edata)
9999
if (lock.is_locked()) {
100100
read_vio.cont->handleEvent(event, &read_vio);
101101
} else {
102-
this_ethread()->schedule_imm(read_vio.cont, event, &read_vio);
102+
if (this->_read_vio_event) {
103+
this->_read_vio_event->cancel();
104+
}
105+
this->_read_vio_event = this_ethread()->schedule_imm(read_vio.cont, event, &read_vio);
103106
}
104107
} else if (_sm && write_vio.ntodo() > 0) {
105108
MUTEX_TRY_LOCK(lock, write_vio.mutex, this_ethread());
106109
if (lock.is_locked()) {
107110
write_vio.cont->handleEvent(event, &write_vio);
108111
} else {
109-
this_ethread()->schedule_imm(write_vio.cont, event, &write_vio);
112+
if (this->_write_vio_event) {
113+
this->_write_vio_event->cancel();
114+
}
115+
this->_write_vio_event = this_ethread()->schedule_imm(write_vio.cont, event, &write_vio);
110116
}
111117
}
112118
break;
@@ -119,7 +125,10 @@ Http2Stream::main_event_handler(int event, void *edata)
119125
if (lock.is_locked()) {
120126
write_vio.cont->handleEvent(event, &write_vio);
121127
} else {
122-
this_ethread()->schedule_imm(write_vio.cont, event, &write_vio);
128+
if (this->_write_vio_event) {
129+
this->_write_vio_event->cancel();
130+
}
131+
this->_write_vio_event = this_ethread()->schedule_imm(write_vio.cont, event, &write_vio);
123132
}
124133
}
125134
} else {
@@ -135,7 +144,10 @@ Http2Stream::main_event_handler(int event, void *edata)
135144
if (lock.is_locked()) {
136145
read_vio.cont->handleEvent(event, &read_vio);
137146
} else {
138-
this_ethread()->schedule_imm(read_vio.cont, event, &read_vio);
147+
if (this->_read_vio_event) {
148+
this->_read_vio_event->cancel();
149+
}
150+
this->_read_vio_event = this_ethread()->schedule_imm(read_vio.cont, event, &read_vio);
139151
}
140152
}
141153
} else {
@@ -937,6 +949,16 @@ Http2Stream::clear_io_events()
937949
buffer_full_write_event->cancel();
938950
buffer_full_write_event = nullptr;
939951
}
952+
953+
if (this->_read_vio_event) {
954+
this->_read_vio_event->cancel();
955+
this->_read_vio_event = nullptr;
956+
}
957+
958+
if (this->_write_vio_event) {
959+
this->_write_vio_event->cancel();
960+
this->_write_vio_event = nullptr;
961+
}
940962
}
941963

942964
void

proxy/http2/Http2Stream.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,10 @@ class Http2Stream : public ProxyTransaction
218218
ink_hrtime inactive_timeout_at = 0;
219219
Event *inactive_event = nullptr;
220220

221-
Event *read_event = nullptr;
222-
Event *write_event = nullptr;
221+
Event *read_event = nullptr;
222+
Event *write_event = nullptr;
223+
Event *_read_vio_event = nullptr;
224+
Event *_write_vio_event = nullptr;
223225
};
224226

225227
extern ClassAllocator<Http2Stream> http2StreamAllocator;

0 commit comments

Comments
 (0)