argus-authz / argus-pep-server

Argus PEP Server
5 stars 3 forks source link

Fix improper synchronization on the Gridmapdir #2

Closed marcocaberletti closed 8 years ago

marcocaberletti commented 8 years ago

Fix for: https://github.com/argus-authz/argus-pep-server/issues/3.

Resolved the syncronization issue of concurrent requests protecting the critical section with:

Synchronized method ensures that threads running on the same pep-server enter the critical section one at a time; lock file ensure mutual exclusion between thread of different pep-server.

Now, the workflow basically is:

  1. If the subject identifier file doesn't exist:
    • call createMapping();
    • in this function, try to get the lock;
    • if lock file already exist, the thread wait, because another thread is in the critical section;
    • got the lock, recheck subject identifier file: if already exists (another thread has created the mapping while this thread is waiting), go ahead, otherwise, create the mapping;
    • if hardlink count is correct, release the lock and return the account name;
  2. call getExistingMapping()