For MySQL before 5.0.2, the priority of NOT is very high. For example, "SELECT NOT 1 = 2" returns 0, since this means "SELECT (NOT 1) = 2", while "SELECT NOT (1 = 2)" returns 1.

From announce.php:

  $result = db_query("SELECT btau.peer_id, btau.ip, btau.port FROM {bt_tracker_active_users} btau WHERE btau.info_hash = %b AND NOT btau.peer_id = %b LIMIT %d", $request['info_hash'], $request['peer_id'], $request['numwant']);

For some versions of MYSQL, this means that the negation of btau.peer_id must be equal to the id of the client trying to find peers, which is not likely to hold. It should be changed to:

  $result = db_query("SELECT btau.peer_id, btau.ip, btau.port FROM {bt_tracker_active_users} btau WHERE btau.info_hash = %b AND NOT (btau.peer_id = %b) LIMIT %d", $request['info_hash'], $request['peer_id'], $request['numwant']);

which means that it should not be the case that the peer id is equal to the id of the client trying to find peers.

Comments

bradfordcp’s picture

Thanks for all the bug reports / patches, I will make these changes and push out another version this weekend.

bradfordcp’s picture

Status: Active » Closed (fixed)

The change has been made check out beta 3 :)

bradfordcp’s picture

Status: Closed (fixed) » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.