Conflict between margo_ref_incr and handle cache
Scenario:
- call
margo_create(&h)
to create a handle; - call
margo_ref_incr(h)
to increment its internal refcount; - call
margo_destroy(h)
to destroy it; The call tomargo_destroy
should decrease the reference count, NOT put the handle back in the cache. Otherwise when the handle is pulled back from the cache to be reused,HG_Reset
will fail. This problem appears in Thallium, in particular. It is harmless, to some extents only: when resetting fails, margo falls back to creating a new handle from scratch, so we just get some Mercury-related errors on stderr and the cache quickly fills up with handles that cannot be reset.
The solution would be to have Jerome provide a HG_Get_refcount
in Mercury so that margo can decide whether HG_Destroy
or cache_put
should be called within margo_destroy
.