Udp input cleanup

Clean up Unix datagram socket if we create one, and avoid a race condition.

**NOTE**: To avoid merge conflicts I branched this off of the process_input_env branch, which is used in #1112. Merging this PR will also merge that one. For best results, please review and merge #1112 first, then this PR will automatically update itself to only contain the UdpInput fixes, and it can be reviewed and merged on its own.
propagating