----------------------------------------------------------------------------
| 212 | |
| 213 | //---------------------------------------------------------------------------- |
| 214 | static void |
| 215 | cleanup(TSCont contp) |
| 216 | { |
| 217 | // shutdown vc and free memory |
| 218 | cache_scan_state *cstate = static_cast<cache_scan_state *>(TSContDataGet(contp)); |
| 219 | |
| 220 | if (cstate) { |
| 221 | // cancel any pending cache scan actions, since we will be destroying the |
| 222 | // continuation |
| 223 | if (cstate->pending_action) { |
| 224 | TSActionCancel(cstate->pending_action); |
| 225 | } |
| 226 | |
| 227 | if (cstate->net_vc) { |
| 228 | TSVConnShutdown(cstate->net_vc, 1, 1); |
| 229 | } |
| 230 | |
| 231 | if (cstate->req_buffer) { |
| 232 | TSIOBufferDestroy(cstate->req_buffer); |
| 233 | cstate->req_buffer = nullptr; |
| 234 | } |
| 235 | |
| 236 | if (cstate->key_to_delete) { |
| 237 | if (TSCacheKeyDestroy(cstate->key_to_delete) == TS_ERROR) { |
| 238 | TSError("[%s] Failed to destroy cache key", PLUGIN_NAME); |
| 239 | } |
| 240 | cstate->key_to_delete = nullptr; |
| 241 | } |
| 242 | |
| 243 | if (cstate->resp_buffer) { |
| 244 | TSIOBufferDestroy(cstate->resp_buffer); |
| 245 | cstate->resp_buffer = nullptr; |
| 246 | } |
| 247 | |
| 248 | TSVConnClose(cstate->net_vc); |
| 249 | TSfree(cstate); |
| 250 | } |
| 251 | TSContDestroy(contp); |
| 252 | } |
| 253 | |
| 254 | //---------------------------------------------------------------------------- |
| 255 | static int |
no test coverage detected