summaryrefslogtreecommitdiff
path: root/ot_livesync.c
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2024-04-03 22:25:30 +0200
committerDirk Engling <erdgeist@erdgeist.org>2024-04-03 22:25:30 +0200
commit2afc4893bf802700a1decfff57673cefc861c7e7 (patch)
tree9a0817371ac05062dbcf25107fcf5a6481feccc0 /ot_livesync.c
parenteb8834f7783cb85ae825976425800cd4af711263 (diff)
Prepare opentracker for dual stack capabilities
Diffstat (limited to 'ot_livesync.c')
-rw-r--r--ot_livesync.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/ot_livesync.c b/ot_livesync.c
index 75a5f9f..b87fa6d 100644
--- a/ot_livesync.c
+++ b/ot_livesync.c
@@ -127,13 +127,13 @@ static void livesync_handle_peersync( struct ot_workstruct *ws ) {
127 127
128 /* Now basic sanity checks have been done on the live sync packet 128 /* Now basic sanity checks have been done on the live sync packet
129 We might add more testing and logging. */ 129 We might add more testing and logging. */
130 while( off + (ssize_t)sizeof( ot_hash ) + (ssize_t)sizeof( ot_peer ) <= ws->request_size ) { 130 while( off + (ssize_t)sizeof( ot_hash ) + OT_PEER_SIZE4 <= ws->request_size ) {
131 memcpy( &ws->peer, ws->request + off + sizeof(ot_hash), sizeof( ot_peer ) ); 131 memcpy( &ws->peer, ws->request + off + sizeof(ot_hash), OT_PEER_SIZE4 );
132 ws->hash = (ot_hash*)(ws->request + off); 132 ws->hash = (ot_hash*)(ws->request + off);
133 133
134 if( !g_opentracker_running ) return; 134 if( !g_opentracker_running ) return;
135 135
136 if( OT_PEERFLAG(&ws->peer) & PEER_FLAG_STOPPED ) 136 if( OT_PEERFLAG(ws->peer) & PEER_FLAG_STOPPED )
137 remove_peer_from_torrent( FLAG_MCA, ws ); 137 remove_peer_from_torrent( FLAG_MCA, ws );
138 else 138 else
139 add_peer_to_torrent_and_return_peers( FLAG_MCA, ws, /* amount = */ 0 ); 139 add_peer_to_torrent_and_return_peers( FLAG_MCA, ws, /* amount = */ 0 );
@@ -143,7 +143,7 @@ static void livesync_handle_peersync( struct ot_workstruct *ws ) {
143 143
144 stats_issue_event(EVENT_SYNC, 0, 144 stats_issue_event(EVENT_SYNC, 0,
145 (ws->request_size - sizeof( g_tracker_id ) - sizeof( uint32_t ) ) / 145 (ws->request_size - sizeof( g_tracker_id ) - sizeof( uint32_t ) ) /
146 ((ssize_t)sizeof( ot_hash ) + (ssize_t)sizeof( ot_peer ))); 146 ((ssize_t)sizeof( ot_hash ) + OT_PEER_SIZE4));
147} 147}
148 148
149/* Tickle the live sync module from time to time, so no events get 149/* Tickle the live sync module from time to time, so no events get
@@ -164,9 +164,9 @@ void livesync_tell( struct ot_workstruct *ws ) {
164 pthread_mutex_lock(&g_outbuf_mutex); 164 pthread_mutex_lock(&g_outbuf_mutex);
165 165
166 memcpy( g_outbuf + g_outbuf_data, ws->hash, sizeof(ot_hash) ); 166 memcpy( g_outbuf + g_outbuf_data, ws->hash, sizeof(ot_hash) );
167 memcpy( g_outbuf + g_outbuf_data + sizeof(ot_hash), &ws->peer, sizeof(ot_peer) ); 167 memcpy( g_outbuf + g_outbuf_data + sizeof(ot_hash), &ws->peer, OT_PEER_SIZE4 );
168 168
169 g_outbuf_data += sizeof(ot_hash) + sizeof(ot_peer); 169 g_outbuf_data += sizeof(ot_hash) + OT_PEER_SIZE4;
170 170
171 if( g_outbuf_data >= LIVESYNC_OUTGOING_BUFFSIZE_PEERS - LIVESYNC_OUTGOING_WATERMARK_PEERS ) 171 if( g_outbuf_data >= LIVESYNC_OUTGOING_BUFFSIZE_PEERS - LIVESYNC_OUTGOING_WATERMARK_PEERS )
172 livesync_issue_peersync(); 172 livesync_issue_peersync();