dl: fix memleak and cond dead lock