Skip to content
Snippets Groups Projects
Commit d0e0e8c9 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Go back to using non-blocking periodic/polling user.tab lock attempts

This partially reverts commit 03b84df8.

I observed deadlocks on Linux attempting locks of user.tab on Samba share,
which also deadlocked my Windows nodes. Interestingly, the Windows nodes
never deadlocked on their own (after a week of testing) when using blocking
locks.

Double the frequency of lock retries - this has helped reduce the observed
user.tab lock failures on Vertrauen.
parent 5434b904
No related branches found
No related tags found
No related merge requests found
Pipeline #7403 passed
......@@ -48,8 +48,8 @@
#define USER_FIELD_SEPARATOR '\t'
static const char user_field_separator[2] = { USER_FIELD_SEPARATOR, '\0' };
#define LOOP_USERDAT 100
#define RETRY_DELAY(x) mswait(((x / 10) * 100) + xp_random(200))
#define LOOP_USERDAT 200
#define RETRY_DELAY(x) mswait(((x / 10) * 50) + xp_random(100))
char* userdat_filename(scfg_t* cfg, char* path, size_t size)
{
......@@ -279,8 +279,12 @@ bool lockuserdat(int file, unsigned user_number)
return false;
off_t offset = userdatoffset(user_number);
return xp_lockfile(file, offset, USER_RECORD_LINE_LEN, /* block: */true) == 0;
unsigned attempt=0;
while(attempt < LOOP_USERDAT && lock(file, offset, USER_RECORD_LINE_LEN) == -1) {
attempt++;
RETRY_DELAY(attempt);
}
return attempt < LOOP_USERDAT;
}
bool unlockuserdat(int file, unsigned user_number)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment