@@ -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
942964void
0 commit comments