Fix: Race condition where new peers were being added to a non-running torrentsession.
Fix: Race condition where new peers were being added to a non-running torrentsession.

Occasionally, a torrentsession finished/quit during the time between the
main loop getting it's pointer from the list of active session, and the
main loop attempting to add a new peer to it. This would cause a
deadlock.

Solution:  Wrapping the potentially blocking channel sends in a
select-case statement, and including an "ended"  channel as another
case. Channel "ended" is closed when the torrentsession is shutting
down, thus preventing the select-case statement from blocking.

ansonwzj/CPSC416Taipei,ansonwzj/CPSC416Taipei