From c6947b160f99278057df0770b849b46264b72229 Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Sun, 7 Dec 2008 03:50:51 +0000 Subject: Handle program end more politely --- ot_livesync.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'ot_livesync.c') diff --git a/ot_livesync.c b/ot_livesync.c index b447e83..f61f0ec 100644 --- a/ot_livesync.c +++ b/ot_livesync.c @@ -8,6 +8,7 @@ #include #include #include +#include /* Libowfat */ #include "socket.h" @@ -57,6 +58,11 @@ void livesync_init( ) { } void livesync_deinit() { + if( g_livesync_socket_in != -1 ) + close( g_livesync_socket_in ); + if( g_livesync_socket_out != -1 ) + close( g_livesync_socket_out ); + pthread_cancel( thread_id ); } @@ -147,6 +153,9 @@ static void * livesync_worker( void * args ) { ot_peer *peer = (ot_peer*)(livesync_inbuffer + off + sizeof(ot_hash)); ot_hash *hash = (ot_hash*)(livesync_inbuffer + off); + if( !g_opentracker_running ) + return NULL; + if( OT_PEERFLAG(peer) & PEER_FLAG_STOPPED ) remove_peer_from_torrent(hash, peer, NULL, FLAG_MCA); else -- cgit v1.2.3