Skip to content

Commit

Permalink
Fixed a heisenbug in mkhash due to aliased pointers.
Browse files Browse the repository at this point in the history
Ignore-this: ba86d7808cfc477c84bf1171391b78c

darcs-hash:20090518153646-20ca2-0f6617cb721ae8b4d251657795bbfe685a1fad64.gz
  • Loading branch information
scudette committed May 18, 2009
1 parent c45a993 commit e643c9e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/include/class.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ super.add as well.
superclass ##_Alloc((superclass)this); \
((Object)this)->__class__ = (Object)&__ ## class; \
((Object)this)->__super__ = (Object)&__ ## superclass; \
((Object)this)->__size = sizeof(struct class);
((Object)this)->__size = sizeof(struct class); \
((Object)this)->__name__ = #class;

#endif

Expand Down
2 changes: 1 addition & 1 deletion src/include/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ struct tcp_struct {
unsigned int data_offset;

/** The payload data portion */
unsigned int data_len;
int data_len;
char *data;
} __attribute__((packed));

Expand Down
13 changes: 5 additions & 8 deletions src/network/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,15 +373,12 @@ TCPHashTable TCPHashTable_Con(TCPHashTable self, int initial_con_id) {
return self;
};

static u_int32_t mkhash (const struct tuple4 *addr) {
u_int32_t *data = (u_int32_t *)addr;
u_int32_t res=0;
int i;

for (i = 0; i < sizeof(struct tuple4) / sizeof(u_int32_t); i++)
res += data[i];
// This can not be static as it hits a gcc optimization bug
static u_int32_t mkhash (struct tuple4 *addr) {
u_int32_t res= addr->source + addr->dest + addr->saddr + addr->daddr;
res += res >> 8;

return res % (TCP_STREAM_TABLE_SIZE);
return (res % (TCP_STREAM_TABLE_SIZE));
};

TCPStream TCPHashTable_find_stream(TCPHashTable self, IP ip) {
Expand Down

0 comments on commit e643c9e

Please sign in to comment.