Fix potential deadlock in channel