Fix couple of concurrency issues in TCP library

TcpServer::AcceptHandlerInternal inserts the new session into the
SesesionMap, releases the mutex and checks if the session has been
closed. If so, it subsequently calls DeleteSession on the session.
This can result in a duplicate delete if the application deletes
the session (by calling DeleteSession or ClearSessions) after the
mutex is released and also returns false from AcceptSession.

Fix is to not insert the session into SessionMap if AcceptSession
returns false.  Just need to make sure that we close the session.
Also ensure that we close the session if we are unable to make it
non-blocking.

TcpServer::ConnectHandler inserts the session into the SesesionMap,
releases the mutex and checks if the session has been closed.  If
so, it erases it from the SessionMap using the iterator returned
by the insert operation.  The iterator may not be valid anymore if
the application deletes the session (by calling DeleteSession or
ClearSessions) after the mutex is released.

Fix is to not use the iterator and instead erase from the SessionMap
by finding the session again.

Change-Id: I6c1754e75e46e29b37fd64fd89a12ffd572fa97e
Merge "Fix couple of concurrency issues in TCP library"