Skip to content

Commit 8ddcef8

Browse files
committed
Change naming convention
1 parent 751bd91 commit 8ddcef8

File tree

2 files changed

+54
-54
lines changed

2 files changed

+54
-54
lines changed

Enyim.Caching/Memcached/MemcachedNode.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public bool Ping()
120120
//could not reconnect
121121
catch { return false; }
122122
}
123-
123+
124124
/// <summary>
125125
/// Acquires a new item from the pool
126126
/// </summary>
@@ -275,7 +275,7 @@ internal InternalPoolImpl(
275275
_logger = logger;
276276
_isDebugEnabled = _logger.IsEnabled(LogLevel.Debug);
277277
}
278-
278+
279279
internal void InitPool()
280280
{
281281
try
@@ -321,7 +321,7 @@ internal async Task InitPoolAsync()
321321
}
322322

323323
if (_logger.IsEnabled(LogLevel.Debug))
324-
_logger.LogDebug("Pool has been inited for {0} with {1} sockets", this.endPoint, this.minItems);
324+
_logger.LogDebug("Pool has been inited for {0} with {1} sockets", _endPoint, this.minItems);
325325

326326
}
327327
catch (Exception e)
@@ -356,7 +356,7 @@ public DateTime MarkedAsDeadUtc
356356
{
357357
get { return this.markedAsDeadUtc; }
358358
}
359-
359+
360360
/// <summary>
361361
/// Acquires a new item from the pool
362362
/// </summary>
@@ -473,11 +473,11 @@ public async Task<IPooledSocketResult> AcquireAsync()
473473
var result = new PooledSocketResult();
474474
var message = string.Empty;
475475

476-
if (_isDebugEnabled) _logger.LogDebug("Acquiring stream from pool. " + this.endPoint);
476+
if (_isDebugEnabled) _logger.LogDebug("Acquiring stream from pool. " + _endPoint);
477477

478478
if (!this.isAlive || this.isDisposed)
479479
{
480-
message = "Pool is dead or disposed, returning null. " + this.endPoint;
480+
message = "Pool is dead or disposed, returning null. " + _endPoint;
481481
result.Fail(message);
482482

483483
if (_isDebugEnabled) _logger.LogDebug(message);
@@ -489,7 +489,7 @@ public async Task<IPooledSocketResult> AcquireAsync()
489489

490490
if (!await this.semaphore.WaitAsync(this.queueTimeout))
491491
{
492-
message = "Pool is full, timeouting. " + this.endPoint;
492+
message = "Pool is full, timeouting. " + _endPoint;
493493
if (_isDebugEnabled) _logger.LogDebug(message);
494494
result.Fail(message, new TimeoutException());
495495

@@ -500,7 +500,7 @@ public async Task<IPooledSocketResult> AcquireAsync()
500500
// maybe we died while waiting
501501
if (!this.isAlive)
502502
{
503-
message = "Pool is dead, returning null. " + this.endPoint;
503+
message = "Pool is dead, returning null. " + _endPoint;
504504
if (_isDebugEnabled) _logger.LogDebug(message);
505505
result.Fail(message);
506506

@@ -537,7 +537,7 @@ public async Task<IPooledSocketResult> AcquireAsync()
537537
}
538538

539539
// free item pool is empty
540-
message = "Could not get a socket from the pool, Creating a new item. " + this.endPoint;
540+
message = "Could not get a socket from the pool, Creating a new item. " + _endPoint;
541541
if (_isDebugEnabled) _logger.LogDebug(message);
542542

543543

@@ -552,7 +552,7 @@ public async Task<IPooledSocketResult> AcquireAsync()
552552
}
553553
catch (Exception e)
554554
{
555-
message = "Failed to create socket. " + this.endPoint;
555+
message = "Failed to create socket. " + _endPoint;
556556
_logger.LogError(message, e);
557557

558558
// eventhough this item failed the failure policy may keep the pool alive
@@ -702,22 +702,22 @@ protected internal virtual PooledSocket CreateSocket()
702702
try
703703
{
704704
var ps = new PooledSocket(this.endPoint, this.config.ConnectionTimeout, this.config.ReceiveTimeout, _logger);
705-
ps.Connect();
705+
//ps.Connect();
706706
return ps;
707707
}
708708
catch (Exception ex)
709709
{
710710
_logger.LogError(ex, $"Create {nameof(PooledSocket)}");
711711
throw;
712712
}
713-
713+
714714
}
715715
protected internal virtual async Task<PooledSocket> CreateSocketAsync()
716716
{
717717
try
718718
{
719719
var ps = new PooledSocket(this.endPoint, this.config.ConnectionTimeout, this.config.ReceiveTimeout, _logger);
720-
await ps.ConnectAsync();
720+
//await ps.ConnectAsync();
721721
return ps;
722722
}
723723
catch (Exception ex)

Enyim.Caching/Memcached/PooledSocket.cs

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ public partial class PooledSocket : IDisposable
1717
{
1818
private readonly ILogger _logger;
1919

20-
private bool isAlive;
21-
private Socket socket;
22-
private EndPoint endpoint;
20+
private bool _isAlive;
21+
private Socket _socket;
22+
private EndPoint _endpoint;
2323

24-
private Stream inputStream;
25-
private AsyncSocketHelper helper;
24+
private Stream _inputStream;
25+
private AsyncSocketHelper _helper;
2626

2727
public PooledSocket(EndPoint endpoint, TimeSpan connectionTimeout, TimeSpan receiveTimeout, ILogger logger)
2828
{
2929
_logger = logger;
3030

31-
this.isAlive = true;
31+
_isAlive = true;
3232

3333
var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
3434
socket.NoDelay = true;
@@ -49,10 +49,10 @@ public PooledSocket(EndPoint endpoint, TimeSpan connectionTimeout, TimeSpan rece
4949
throw new TimeoutException($"Could not connect to {endpoint}.");
5050
}
5151

52-
this.socket = socket;
53-
this.endpoint = endpoint;
52+
_socket = socket;
53+
_endpoint = endpoint;
5454

55-
this.inputStream = new NetworkStream(socket);
55+
_inputStream = new NetworkStream(socket);
5656
}
5757

5858
private bool ConnectWithTimeout(Socket socket, EndPoint endpoint, int timeout)
@@ -89,24 +89,24 @@ void Cancel()
8989

9090
public int Available
9191
{
92-
get { return this.socket.Available; }
92+
get { return _socket.Available; }
9393
}
9494

9595
public void Reset()
9696
{
9797
// discard any buffered data
98-
this.inputStream.Flush();
98+
_inputStream.Flush();
9999

100-
if (this.helper != null) this.helper.DiscardBuffer();
100+
if (_helper != null) _helper.DiscardBuffer();
101101

102-
int available = this.socket.Available;
102+
int available = _socket.Available;
103103

104104
if (available > 0)
105105
{
106106
if (_logger.IsEnabled(LogLevel.Warning))
107107
_logger.LogWarning(
108108
"Socket bound to {0} has {1} unread data! This is probably a bug in the code. InstanceID was {2}.",
109-
this.socket.RemoteEndPoint, available, this.InstanceId);
109+
_socket.RemoteEndPoint, available, this.InstanceId);
110110

111111
byte[] data = new byte[available];
112112

@@ -127,7 +127,7 @@ public void Reset()
127127

128128
public bool IsAlive
129129
{
130-
get { return this.isAlive; }
130+
get { return _isAlive; }
131131
}
132132

133133
/// <summary>
@@ -158,20 +158,20 @@ protected void Dispose(bool disposing)
158158

159159
try
160160
{
161-
if (socket != null)
161+
if (_socket != null)
162162
try
163163
{
164-
this.socket.Dispose();
164+
_socket.Dispose();
165165
}
166166
catch
167167
{
168168
}
169169

170-
if (this.inputStream != null)
171-
this.inputStream.Dispose();
170+
if (_inputStream != null)
171+
_inputStream.Dispose();
172172

173-
this.inputStream = null;
174-
this.socket = null;
173+
_inputStream = null;
174+
_socket = null;
175175
this.CleanupCallback = null;
176176
}
177177
catch (Exception e)
@@ -195,7 +195,7 @@ void IDisposable.Dispose()
195195

196196
private void CheckDisposed()
197197
{
198-
if (this.socket == null)
198+
if (_socket == null)
199199
throw new ObjectDisposedException("PooledSocket");
200200
}
201201

@@ -209,11 +209,11 @@ public int ReadByte()
209209

210210
try
211211
{
212-
return this.inputStream.ReadByte();
212+
return _inputStream.ReadByte();
213213
}
214214
catch (IOException)
215215
{
216-
this.isAlive = false;
216+
_isAlive = false;
217217

218218
throw;
219219
}
@@ -225,11 +225,11 @@ public int ReadByteAsync()
225225

226226
try
227227
{
228-
return this.inputStream.ReadByte();
228+
return _inputStream.ReadByte();
229229
}
230230
catch (IOException)
231231
{
232-
this.isAlive = false;
232+
_isAlive = false;
233233
throw;
234234
}
235235
}
@@ -245,7 +245,7 @@ public async Task ReadAsync(byte[] buffer, int offset, int count)
245245
{
246246
try
247247
{
248-
int currentRead = this.inputStream.Read(buffer, offset, shouldRead);
248+
int currentRead = _inputStream.Read(buffer, offset, shouldRead);
249249
if (currentRead < 1)
250250
continue;
251251

@@ -255,7 +255,7 @@ public async Task ReadAsync(byte[] buffer, int offset, int count)
255255
}
256256
catch (IOException)
257257
{
258-
this.isAlive = false;
258+
_isAlive = false;
259259
throw;
260260
}
261261
}
@@ -279,7 +279,7 @@ public void Read(byte[] buffer, int offset, int count)
279279
{
280280
try
281281
{
282-
int currentRead = this.inputStream.Read(buffer, offset, shouldRead);
282+
int currentRead = _inputStream.Read(buffer, offset, shouldRead);
283283
if (currentRead < 1)
284284
continue;
285285

@@ -289,7 +289,7 @@ public void Read(byte[] buffer, int offset, int count)
289289
}
290290
catch (IOException)
291291
{
292-
this.isAlive = false;
292+
_isAlive = false;
293293
throw;
294294
}
295295
}
@@ -301,13 +301,13 @@ public void Write(byte[] data, int offset, int length)
301301

302302
SocketError status;
303303

304-
this.socket.Send(data, offset, length, SocketFlags.None, out status);
304+
_socket.Send(data, offset, length, SocketFlags.None, out status);
305305

306306
if (status != SocketError.Success)
307307
{
308-
this.isAlive = false;
308+
_isAlive = false;
309309

310-
ThrowHelper.ThrowSocketWriteError(this.endpoint, status);
310+
ThrowHelper.ThrowSocketWriteError(_endpoint, status);
311311
}
312312
}
313313

@@ -322,29 +322,29 @@ public void Write(IList<ArraySegment<byte>> buffers)
322322
for (int i = 0, C = buffers.Count; i < C; i++)
323323
total += buffers[i].Count;
324324

325-
if (this.socket.Send(buffers, SocketFlags.None, out status) != total)
325+
if (_socket.Send(buffers, SocketFlags.None, out status) != total)
326326
System.Diagnostics.Debugger.Break();
327327
#else
328328
this.socket.Send(buffers, SocketFlags.None, out status);
329329
#endif
330330

331331
if (status != SocketError.Success)
332332
{
333-
this.isAlive = false;
333+
_isAlive = false;
334334

335-
ThrowHelper.ThrowSocketWriteError(this.endpoint, status);
335+
ThrowHelper.ThrowSocketWriteError(_endpoint, status);
336336
}
337337
}
338338

339339
public async Task WriteSync(IList<ArraySegment<byte>> buffers)
340340
{
341341
try
342342
{
343-
await socket.SendAsync(buffers, SocketFlags.None);
343+
await _socket.SendAsync(buffers, SocketFlags.None);
344344
}
345345
catch (Exception ex)
346346
{
347-
isAlive = false;
347+
_isAlive = false;
348348
_logger.LogError(ex, nameof(PooledSocket.WriteSync));
349349
}
350350
}
@@ -365,10 +365,10 @@ public bool ReceiveAsync(AsyncIOArgs p)
365365
return false;
366366
}
367367

368-
if (this.helper == null)
369-
this.helper = new AsyncSocketHelper(this);
368+
if (_helper == null)
369+
_helper = new AsyncSocketHelper(this);
370370

371-
return this.helper.Read(p);
371+
return _helper.Read(p);
372372
}
373373
}
374374
}

0 commit comments

Comments
 (0)