Class DataDirectoryLock
Keeps other server processes off a data directory while this one uses it: LockFileName is held open exclusively, which on Linux is an flock that the kernel releases when the process ends, also when it is killed, so the lock never goes stale.
Implements
Inherited Members
Namespace: Uniform.Matrix.Server.Storage
Assembly: Uniform.Matrix.Server.dll
Syntax
public sealed class DataDirectoryLock : IDisposable
Remarks
ProcessFileName next to it tells which process holds it, for the message of the next one; it may be left behind, as only the lock counts.
Fields
| Edit this page View SourceLockFileName
Name of the lock file in the data directory.
Declaration
public const string LockFileName = "server.lock"
Field Value
| Type | Description |
|---|---|
| string |
ProcessFileName
Name of the file with the holder's process ID.
Declaration
public const string ProcessFileName = "server.pid"
Field Value
| Type | Description |
|---|---|
| string |
Properties
| Edit this page View SourceDirectory
The locked data directory.
Declaration
public string Directory { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
| Edit this page View SourceAcquire(string)
Lock directory for this process, creating it when missing; throw DataDirectoryInUseException when another process has it.
Declaration
public static DataDirectoryLock Acquire(string directory)
Parameters
| Type | Name | Description |
|---|---|---|
| string | directory |
Returns
| Type | Description |
|---|---|
| DataDirectoryLock |
Dispose()
Release the lock.
Declaration
public void Dispose()