Skip to content

Commit

Permalink
minor fix for HttpConnection Id
Browse files Browse the repository at this point in the history
  • Loading branch information
hex11 committed Aug 11, 2018
1 parent 28d18d2 commit 372f583
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion NaiveSocksCliShared/BuildInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ static BuildInfo()
}
}

public const string Version = "0.3.12.0";
public const string Version = "0.3.12.1";

public const bool Debug =
#if DEBUG
Expand Down
14 changes: 7 additions & 7 deletions NaiveSvrLib/NaiveSvrShared/HttpSvr/HttpConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ private async Task _requestingLoop()
} catch (Exception e) {
if (disconnecting || myStream.State.IsClosed)
break;
server.logException(e, Logging.Level.Warning, $"[{server.mark}#{id}({requestCount}) {remoteEP}] handling");
server.logException(e, Logging.Level.Warning, $"[{server.mark}#{Id}({requestCount}) {remoteEP}] handling");
if (ConnectionState == States.SwitchedProtocol)
break;
if (ConnectionState == States.Processing & outputStream.Position == 0) {
Expand Down Expand Up @@ -512,15 +512,15 @@ internal void writeResponseTo(TextWriter writer)
writer.Write("\r\n");
}

public int Id => id;
private int id = id_counter++;
private static int id_counter = 0;
public int Id { get; } = idGen.Get();

private static IncrNumberGenerator idGen = new IncrNumberGenerator();

public void info(string text) => log(text, Logging.Level.Info);

public virtual void log(string text, Logging.Level level)
{
server.log($"(#{id}|{remoteEP}({RequestCount})) {text}", level);
server.log($"(#{Id}|{remoteEP}({RequestCount})) {text}", level);
}

public Stream SwitchProtocol()
Expand All @@ -538,9 +538,9 @@ public override string ToString()
public virtual string ToString(bool verbose)
{
if (verbose)
return $"{{HttpConn #{id}|{remoteEP}({RequestCount})}}";
return $"{{HttpConn #{Id}|{remoteEP}({RequestCount})}}";
else
return $"{{HttpConn #{id}({RequestCount})}}";
return $"{{HttpConn #{Id}({RequestCount})}}";
}

#region IDisposable Support
Expand Down

0 comments on commit 372f583

Please sign in to comment.