rbino / tigerbeetlex

An Elixir client for TigerBeetle
Apache License 2.0
36 stars 6 forks source link

Increase the reference count for the payload resource before submitting it #12

Closed rbino closed 1 year ago

rbino commented 1 year ago

As discussed on Tigerbeetle's Slack, the packet data must stay valid until the request is completed, but the current code is currently depending on the payload term staying valid until the end of the request since the resource is released as soon as it's created. A call to enif_keep_resource or equivalent should be added in the submit function, matched with a enif_release_resource in the on_completion callback.