| 279 | } |
| 280 | |
| 281 | void |
| 282 | FetchSM::InvokePluginExt(int fetch_event) |
| 283 | { |
| 284 | int event; |
| 285 | EThread *mythread = this_ethread(); |
| 286 | bool read_complete_event = (fetch_event == TS_EVENT_VCONN_READ_COMPLETE) || (fetch_event == TS_EVENT_VCONN_EOS); |
| 287 | |
| 288 | // |
| 289 | // Increasing *recursion* to prevent |
| 290 | // FetchSM being deleted by callback. |
| 291 | // |
| 292 | recursion++; |
| 293 | |
| 294 | if (fetch_flags & TS_FETCH_FLAGS_NEWLOCK) { |
| 295 | MUTEX_TAKE_LOCK(cont_mutex, mythread); |
| 296 | } |
| 297 | |
| 298 | bool const dechunk = 0 != (fetch_flags & TS_FETCH_FLAGS_DECHUNK); |
| 299 | bool chunked = false; |
| 300 | |
| 301 | if (!contp) { |
| 302 | goto out; |
| 303 | } |
| 304 | |
| 305 | if (fetch_event && !read_complete_event) { |
| 306 | contp->handleEvent(fetch_event, this); |
| 307 | goto out; |
| 308 | } |
| 309 | |
| 310 | if (!has_sent_header) { |
| 311 | if (fetch_event != TS_EVENT_VCONN_EOS) { |
| 312 | contp->handleEvent(TS_FETCH_EVENT_EXT_HEAD_DONE, this); |
| 313 | has_sent_header = true; |
| 314 | } else { |
| 315 | contp->handleEvent(fetch_event, this); |
| 316 | goto out; |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | // TS-3112: always check 'contp' after handleEvent() |
| 321 | // since handleEvent effectively calls the plugin (or H2 layer) |
| 322 | // which may call TSFetchDestroy in error conditions. |
| 323 | // TSFetchDestroy sets contp to NULL, but, doesn't destroy FetchSM yet, |
| 324 | // since, it¹s in a tight loop protected by 'recursion' counter. |
| 325 | // When handleEvent returns, 'recursion' is decremented and contp is |
| 326 | // already null, so, FetchSM gets destroyed. |
| 327 | if (!contp) { |
| 328 | goto out; |
| 329 | } |
| 330 | |
| 331 | if (!has_body()) { |
| 332 | contp->handleEvent(TS_FETCH_EVENT_EXT_BODY_DONE, this); |
| 333 | goto out; |
| 334 | } |
| 335 | |
| 336 | chunked = check_chunked(); |
| 337 | |
| 338 | Dbg(dbg_ctl, "[%s] chunked:%d, content_len: %" PRId64 ", received_len: %" PRId64 ", avail: %" PRId64 "", __FUNCTION__, |
nothing calls this directly
no test coverage detected