ccoverstreet / Jablko

Smart Home Interface powered by Go.
MIT License
1 stars 0 forks source link

Extra Card Appears #94

Closed ccoverstreet closed 3 years ago

ccoverstreet commented 3 years ago

Describe the bug When builtin/test is crashed out, the dashboard replaces it's card with the another copy of an installed JMOD.

To Reproduce Steps to reproduce the behavior:

  1. Break makefile of builtin/test
  2. Run
  3. Go to dashboard and see extra card

Expected behavior No card is displayed if the JMOD is down.

ccoverstreet commented 3 years ago

Figured out the issue. In subprocess.Start, GetAvailablePort is called which checks for available ports by attempting to listen on the port. The problem occurs when multiple processes are started in quick succession, as each process doesn't have enough time to claim the port before GetAvailablePort scans it. The solution to this was to add a lock protected map containing the ports already reserved by GetAvailablePort.