summaryrefslogtreecommitdiff
path: root/ot_livesync.c
diff options
context:
space:
mode:
Diffstat (limited to 'ot_livesync.c')
-rw-r--r--ot_livesync.c9
1 files changed, 9 insertions, 0 deletions
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 @@
8#include <sys/uio.h> 8#include <sys/uio.h>
9#include <string.h> 9#include <string.h>
10#include <pthread.h> 10#include <pthread.h>
11#include <unistd.h>
11 12
12/* Libowfat */ 13/* Libowfat */
13#include "socket.h" 14#include "socket.h"
@@ -57,6 +58,11 @@ void livesync_init( ) {
57} 58}
58 59
59void livesync_deinit() { 60void livesync_deinit() {
61 if( g_livesync_socket_in != -1 )
62 close( g_livesync_socket_in );
63 if( g_livesync_socket_out != -1 )
64 close( g_livesync_socket_out );
65
60 pthread_cancel( thread_id ); 66 pthread_cancel( thread_id );
61} 67}
62 68
@@ -147,6 +153,9 @@ static void * livesync_worker( void * args ) {
147 ot_peer *peer = (ot_peer*)(livesync_inbuffer + off + sizeof(ot_hash)); 153 ot_peer *peer = (ot_peer*)(livesync_inbuffer + off + sizeof(ot_hash));
148 ot_hash *hash = (ot_hash*)(livesync_inbuffer + off); 154 ot_hash *hash = (ot_hash*)(livesync_inbuffer + off);
149 155
156 if( !g_opentracker_running )
157 return NULL;
158
150 if( OT_PEERFLAG(peer) & PEER_FLAG_STOPPED ) 159 if( OT_PEERFLAG(peer) & PEER_FLAG_STOPPED )
151 remove_peer_from_torrent(hash, peer, NULL, FLAG_MCA); 160 remove_peer_from_torrent(hash, peer, NULL, FLAG_MCA);
152 else 161 else