Skip to content

Commit

Permalink
Metalink Plugin: Must not destroy the Transform Contp, only shutdown …
Browse files Browse the repository at this point in the history
…write on it while received WRITE_COMPLETE

The transform contp will be closed and destroied after TransformVC is closed.
The transformation plugin receives EVENT_IMMEDIATE when transform contp close
then the plugin could release 'TransformData' and call TSContDestroy().
  • Loading branch information
oknet authored and zwoop committed Aug 16, 2017
1 parent 90d8eee commit e115703
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions plugins/experimental/metalink/metalink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,7 @@ vconn_write_ready(TSCont contp, void * /* edata ATS_UNUSED */)

/* Can't reuse the TSTransformCreate() continuation because we
* don't know whether to destroy it in
* cache_open_write()/cache_open_write_failed() or
* transform_vconn_write_complete() */
* cache_open_write()/cache_open_write_failed() */
contp = TSContCreate(write_handler, nullptr);
TSContDataSet(contp, write_data);

Expand All @@ -476,18 +475,6 @@ vconn_write_ready(TSCont contp, void * /* edata ATS_UNUSED */)
return 0;
}

static int
transform_vconn_write_complete(TSCont contp, void * /* edata ATS_UNUSED */)
{
TransformData *data = (TransformData *)TSContDataGet(contp);
TSContDestroy(contp);

TSIOBufferDestroy(data->output_bufp);
TSfree(data);

return 0;
}

/* TSTransformCreate() handler: Compute the SHA-256 digest of the
* content */

Expand All @@ -500,8 +487,8 @@ transform_handler(TSCont contp, TSEvent event, void *edata)
return vconn_write_ready(contp, edata);

case TS_EVENT_VCONN_WRITE_COMPLETE:
return transform_vconn_write_complete(contp, edata);

TSVConnShutdown(TSTransformOutputVConnGet(contp), 0, 1);
break;
default:
TSAssert(!"Unexpected event");
}
Expand Down

0 comments on commit e115703

Please sign in to comment.