Skip to content
Snippets Groups Projects
Deucе's avatar
Deucе authored
This works around an issue on macOS and Linux where a select() or
poll() in thread X won't return when close() is called on the same
socket in thread Y.

We also set the descriptor/handle/whatever to an invalid value
while waiting for io threads to terminate so that a close() in one
thread won't cause other threads to possibly interact with a new
descriptor created after the close().  This isn't actually something
that can happen in SyncTERM, but it's worth protecting against.

Finally, don't call close() until after all io threads have
terminated.  This prevents the descriptor from becoming available
to other syscalls while threads are closing, and prevents operations
on an invalid descriptor.

This is still not safe on platforms where a descriptor value write
is not atomic, but I don't think I support any platform like that.

Reported as #212 in github, and 75 on SourceForge.
abc1fcbe
History

Synchronet Project

BBS-Related Software Source Repository

Directories within:

  • 3rdp - Third-party libraries
  • ctrl - Synchronet BBS configuration and run-time data files
  • docs - Synchronet BBS documentation (mostly legacy HTML)
  • exec - Synchronet BBS executable files (mostly JavaScript)
  • install - Synchronet BBS installation files
  • node1 - Synchronet BBS Terminal Server "node" configuration files
  • src - Source code (mostly C/C++)
  • text - Synchronet BBS text and menu files
  • web - Synchronet Legacy/Runemaster web UI
  • webv4 - echicken's web interface (v4) for Synchronet
  • xtrn - Synchronet BBS doors (mostly JavaScript)

Related web-sites:
Synchronet BBS Software
Synchronet Wiki
Synchronet Source Repository