diff options
author | erdgeist <> | 2008-12-07 03:50:51 +0000 |
---|---|---|
committer | erdgeist <> | 2008-12-07 03:50:51 +0000 |
commit | c6947b160f99278057df0770b849b46264b72229 (patch) | |
tree | 8c5e543648458f7368d51906c53a9e1b45a8c364 /ot_livesync.c | |
parent | ad8c9ee1efac171e5f3a8f41a630254ac88357a8 (diff) |
Handle program end more politely
Diffstat (limited to 'ot_livesync.c')
-rw-r--r-- | ot_livesync.c | 9 |
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 | ||
59 | void livesync_deinit() { | 60 | void 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 |