Browse Source

Some premature optimization lead to always only 8bytes of ot_peers being copied

master
Dirk Engling 12 years ago
parent
commit
83d62ba0fb
2 changed files with 4 additions and 4 deletions
  1. +2
    -2
      ot_clean.c
  2. +2
    -2
      ot_vector.c

+ 2
- 2
ot_clean.c View File

@@ -33,7 +33,7 @@ static ssize_t clean_single_bucket( ot_peer *peers, size_t peer_count, time_t ti
while( peers < last_peer )
if( ( timediff = timedout + OT_PEERTIME( peers ) ) < OT_PEER_TIMEOUT ) {
OT_PEERTIME( peers ) = timediff;
*(uint64_t*)(insert_point++) = *(uint64_t*)(peers++);
memcpy( insert_point++, peers++, sizeof(ot_peer));
} else
if( OT_PEERFLAG( peers++ ) & PEER_FLAG_SEEDING )
(*removed_seeders)++;
@@ -133,4 +133,4 @@ void clean_deinit( void ) {
pthread_cancel( thread_id );
}

const char *g_version_clean_c = "$Source: /home/cvsroot/opentracker/ot_clean.c,v $: $Revision: 1.16 $\n";
const char *g_version_clean_c = "$Source: /home/cvsroot/opentracker/ot_clean.c,v $: $Revision: 1.17 $\n";

+ 2
- 2
ot_vector.c View File

@@ -244,7 +244,7 @@ void vector_redistribute_buckets( ot_peerlist * peer_list ) {
bucket_dest->space *= OT_VECTOR_GROW_RATIO;
}
peers_new = (ot_peer*)bucket_dest->data;
*(uint64_t*)(peers_new + bucket_dest->size++) = *(uint64_t*)(peers_old++);
memcpy(peers_new + bucket_dest->size++, peers_old++, sizeof(ot_peer));
}
}

@@ -289,4 +289,4 @@ void vector_fixup_peers( ot_vector * vector ) {
vector->data = realloc( vector->data, vector->space * sizeof( ot_peer ) );
}

const char *g_version_vector_c = "$Source: /home/cvsroot/opentracker/ot_vector.c,v $: $Revision: 1.14 $\n";
const char *g_version_vector_c = "$Source: /home/cvsroot/opentracker/ot_vector.c,v $: $Revision: 1.15 $\n";

Loading…
Cancel
Save