Skip to content

Strange SocketInitiatorThreadStart RemoveThread logic #978

@kirsan31

Description

@kirsan31

Hi, I looking into this code:

try
{
t.Connect();
t.Initiator.SetConnected(t.Session.SessionID);
t.Session.Log.Log(LogLevel.Information, "Connection succeeded");
t.Session.Next();
while (t.Read()) {
}
if (t.Initiator.IsStopped)
t.Initiator.RemoveThread(t);
t.Initiator.SetDisconnected(t.Session.SessionID);
}
catch (IOException ex) // Can be exception when connecting, during ssl authentication or when reading
{
LogThreadStartConnectionFailed(t, ex);
}
catch (SocketException ex)
{
LogThreadStartConnectionFailed(t, ex);
}
catch (System.Security.Authentication.AuthenticationException ex) // some certificate problems
{
LogThreadStartConnectionFailed(t, ex);
}
catch (Exception ex)
{
LogThreadStartConnectionFailed(t, ex);
}
finally
{
t.Initiator.RemoveThread(t);
t.Initiator.SetDisconnected(t.Session.SessionID);
}

On line 64 we see if (t.Initiator.IsStopped) condition for removal, but on line 86 we will remove it any way. SetDisconnected in normal case is called twice too. Are line 64 - 66 redundant?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions