Handle events from TSHttpTxnServerIntercept. The intercept starts with TS_EVENT_NET_ACCEPT, and then continues with TSVConn events.
| 371 | // starts with TS_EVENT_NET_ACCEPT, and then continues with |
| 372 | // TSVConn events. |
| 373 | static int |
| 374 | StaticHitInterceptHook(TSCont contp, TSEvent event, void *edata) |
| 375 | { |
| 376 | VDEBUG("StaticHitInterceptHook: %p ", edata); |
| 377 | |
| 378 | argument_type arg(edata); |
| 379 | |
| 380 | VDEBUG("contp=%p, event=%s (%d), edata=%p", contp, TSHttpEventNameLookup(event), event, arg.ptr); |
| 381 | |
| 382 | switch (event) { |
| 383 | case TS_EVENT_NET_ACCEPT: { |
| 384 | // TS_EVENT_NET_ACCEPT will be delivered when the server intercept |
| 385 | // is set up by the core. We just need to allocate a statichit |
| 386 | // request state and start reading the VC. |
| 387 | StaticHitRequest *trq = static_cast<StaticHitRequest *>(TSContDataGet(contp)); |
| 388 | |
| 389 | TSStatIntIncrement(StatCountResponses, 1); |
| 390 | VDEBUG("allocated server intercept statichit trq=%p", trq); |
| 391 | |
| 392 | // This continuation was allocated in StaticHitTxnHook. Reset the |
| 393 | // data to keep track of this generator request. |
| 394 | TSContDataSet(contp, trq); |
| 395 | |
| 396 | // Start reading the request from the server intercept VC. |
| 397 | trq->readio.read(arg.vc, contp); |
| 398 | VIODEBUG(trq->readio.vio, "started reading statichit request"); |
| 399 | |
| 400 | return TS_EVENT_NONE; |
| 401 | } |
| 402 | |
| 403 | case TS_EVENT_NET_ACCEPT_FAILED: { |
| 404 | // TS_EVENT_NET_ACCEPT_FAILED will be delivered if the |
| 405 | // transaction is cancelled before we start tunnelling |
| 406 | // through the server intercept. One way that this can happen |
| 407 | // is if the intercept is attached early, and then we serve |
| 408 | // the document out of cache. |
| 409 | |
| 410 | // There's nothing to do here except nuke the continuation |
| 411 | // that was allocated in StaticHitTxnHook(). |
| 412 | |
| 413 | StaticHitRequest *trq = static_cast<StaticHitRequest *>(TSContDataGet(contp)); |
| 414 | delete trq; |
| 415 | |
| 416 | TSContDestroy(contp); |
| 417 | return TS_EVENT_NONE; |
| 418 | } |
| 419 | |
| 420 | case TS_EVENT_VCONN_READ_READY: { |
| 421 | argument_type cdata = TSContDataGet(contp); |
| 422 | StaticHitHttpHeader &rqheader = cdata.trq->rqheader; |
| 423 | |
| 424 | VDEBUG("reading vio=%p vc=%p, trq=%p", arg.vio, TSVIOVConnGet(arg.vio), cdata.trq); |
| 425 | |
| 426 | TSIOBufferBlock blk; |
| 427 | TSParseResult result = TS_PARSE_CONT; |
| 428 | |
| 429 | for (blk = TSIOBufferReaderStart(cdata.trq->readio.reader); blk; blk = TSIOBufferBlockNext(blk)) { |
| 430 | const char *ptr; |
nothing calls this directly
no test coverage detected