user_recv_thread: set fd to -1 when closing (#461)

Fixes a busy loop of the usrsctp UDP recv thread attempting to shutdown
usrsctp with usrsctp_finish().

Usually, destroying the udp socket in recv_thread_destroy() would result
in the udp receive thread returning an error (-1) with errno set to
(-9) EDABF.  In other cases, sometimes recvmsg would return 0 without an
error being reported in errno.  My assumption here is that the fd number
would be reused for some other purpose.

Explicitly set the socket/fd variables to -1 when performing a
close()/closesocket() on them so that any future recv*() calls will
return with an error.

Also move the thread closure to the fd close block so that the threads
are definitley closed before we continue.
2 files changed
tree: f6dcd8f0bbd4d480c867b2cc8b00599360ee1f8c
  1. fuzzer/
  2. programs/
  3. usrsctplib/
  4. .gitignore
  5. bootstrap
  6. CMakeLists.txt
  7. configure.ac
  8. gen-def.py
  9. LICENSE.md
  10. Makefile.am
  11. Makefile.nmake
  12. Manual.md
  13. Manual.tex
  14. meson.build
  15. meson_options.txt
  16. README.md
  17. usrsctp.pc.in
README.md

usrsctp

Coverity Scan Build Status

This is a userland SCTP stack supporting FreeBSD, Linux, Mac OS X and Windows.

See manual for more information.

The status of continuous integration testing is available from our Buildbot.