public RemoteDirectoryIndexInput(RemoteDirectoryIndexInput cloneInput) { _name = cloneInput._name; _remoteSyncDirectory = cloneInput._remoteSyncDirectory; if (string.IsNullOrWhiteSpace(_name)) { throw new ArgumentNullException(nameof(cloneInput._name)); } if (_remoteSyncDirectory == null) { throw new ArgumentNullException(nameof(cloneInput._remoteSyncDirectory)); } _fileMutex = SyncMutexManager.GrabMutex(cloneInput._remoteSyncDirectory, cloneInput._name); _fileMutex.WaitOne(); try { #if FULLDEBUG Trace.WriteLine($"Creating clone for {cloneInput._name}"); #endif _indexInput = cloneInput._indexInput.Clone() as IndexInput; } catch (Exception) { // sometimes we get access denied on the 2nd stream...but not always. I haven't tracked it down yet // but this covers our tail until I do Trace.TraceError($"Dagnabbit, falling back to memory clone for {cloneInput._name}"); } finally { _fileMutex.ReleaseMutex(); } }
public override object Clone() { IndexInput clone = null; try { _fileMutex.WaitOne(); var input = new RemoteDirectoryIndexInput(this); clone = input; } catch (Exception err) { Trace.TraceError(err.ToString()); } finally { _fileMutex.ReleaseMutex(); } Debug.Assert(clone != null); return(clone); }