summaryrefslogtreecommitdiff
path: root/ot_livesync.c
diff options
context:
space:
mode:
authorerdgeist <>2008-12-06 18:46:00 +0000
committererdgeist <>2008-12-06 18:46:00 +0000
commit08c71627839a9134367db354c8255f7a720e1ff3 (patch)
treeb429abf6b3c26c7f851b522f5d4fb6797ad02d29 /ot_livesync.c
parenta4ed31d517f77a21afe12918a9cb256489daac74 (diff)
Renamed OT_FLAG to OT_PEERFLAG to make code easier to read
Introduced READ16/32 and WRITE16/32 makros to abstract loading/storing from unaligned addresses away on cpu's that can actually load/store everywhere Removed all unnecessary memmoves, especially where it only moved 6 bytes in inner loop. I replaced them with WRITE16/32(READ16/32()) makros
Diffstat (limited to 'ot_livesync.c')
-rw-r--r--ot_livesync.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/ot_livesync.c b/ot_livesync.c
index 1b1efe0..b447e83 100644
--- a/ot_livesync.c
+++ b/ot_livesync.c
@@ -94,10 +94,11 @@ static void livesync_issuepacket( ) {
94 94
95/* Inform live sync about whats going on. */ 95/* Inform live sync about whats going on. */
96void livesync_tell( ot_hash * const info_hash, const ot_peer * const peer ) { 96void livesync_tell( ot_hash * const info_hash, const ot_peer * const peer ) {
97 memmove( livesync_outbuffer_pos , info_hash, sizeof(ot_hash)); 97 int i;
98 memmove( livesync_outbuffer_pos + sizeof(ot_hash), peer, sizeof(ot_peer)); 98 for(i=0;i<20;i+=4) WRITE32(livesync_outbuffer_pos+=4,0,READ32(info_hash,i));
99 99 WRITE32(livesync_outbuffer_pos+=4,0,READ32(peer,0));
100 livesync_outbuffer_pos += sizeof(ot_hash) + sizeof(ot_peer); 100 WRITE32(livesync_outbuffer_pos+=4,0,READ32(peer,4));
101
101 if( livesync_outbuffer_pos >= livesync_outbuffer_highwater ) 102 if( livesync_outbuffer_pos >= livesync_outbuffer_highwater )
102 livesync_issuepacket(); 103 livesync_issuepacket();
103} 104}
@@ -146,7 +147,7 @@ static void * livesync_worker( void * args ) {
146 ot_peer *peer = (ot_peer*)(livesync_inbuffer + off + sizeof(ot_hash)); 147 ot_peer *peer = (ot_peer*)(livesync_inbuffer + off + sizeof(ot_hash));
147 ot_hash *hash = (ot_hash*)(livesync_inbuffer + off); 148 ot_hash *hash = (ot_hash*)(livesync_inbuffer + off);
148 149
149 if( OT_FLAG(peer) & PEER_FLAG_STOPPED ) 150 if( OT_PEERFLAG(peer) & PEER_FLAG_STOPPED )
150 remove_peer_from_torrent(hash, peer, NULL, FLAG_MCA); 151 remove_peer_from_torrent(hash, peer, NULL, FLAG_MCA);
151 else 152 else
152 add_peer_to_torrent( hash, peer WANT_SYNC_PARAM(1)); 153 add_peer_to_torrent( hash, peer WANT_SYNC_PARAM(1));