I think this is right. It's odd to up the refcnt on every set_dtls. We're just setting the value. IIUC, the refcnt is meant to keep key alive since we're storing a ref to it in V.
This bug was probably harmless - just some wasted memory. You'd need 4 billion set_dtls calls followed by a poorly timed decref to cause serious trouble. =) Signed-off-by: Barret Rhoden <[email protected]> --- user/parlib/dtls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user/parlib/dtls.c b/user/parlib/dtls.c index afd8e2892bb2..4df4d54665ff 100644 --- a/user/parlib/dtls.c +++ b/user/parlib/dtls.c @@ -170,11 +170,11 @@ static inline void *__get_dtls(dtls_data_t *dtls_data, dtls_key_t key) static inline void __set_dtls(dtls_data_t *dtls_data, dtls_key_t key, void *dtls) { assert(key); - __sync_fetch_and_add(&key->ref_count, 1); struct dtls_value *v = __get_dtls(dtls_data, key); if (!v) { v = __allocate_dtls_value(dtls_data, key); + __sync_fetch_and_add(&key->ref_count, 1); v->key = key; TAILQ_INSERT_HEAD(&dtls_data->list, v, link); } -- 2.8.0.rc3.226.g39d4020 -- You received this message because you are subscribed to the Google Groups "Akaros" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/d/optout.
