rstudio/rstudio — comment on commit 65b6b99362a538bd5aa691423b7d7bf3fe67e274
File: src/cpp/session/SessionSourceDatabaseSupervisor.cpp line 371
By jcheng5:

I looked at your changes on the multi branch and it looks fine to me. The race I was concerned was as follows:

1) Session A starts up (no other sessions are running)
2) Session A starts exiting--pushes changes to persistent dir, releases lock, begins erasing directory
3) Session B starts up and calls attachToSourceDatabase
4) Session A finishes erasing directory

In this case, Session B would check if sessionDirs.size() == 0, which is false, so it would end up with a virginal session dir when it really should have taken the persistent dir. It looks like you've addressed it to me.