BitTorrent won't return peers -- the priority of NOT
Jonas Kvarnstrom - January 30, 2008 - 10:29
| Project: | BitTorrent |
| Version: | 5.x-2.0-beta2 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
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:
<?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:
<?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']);
?>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.

#1
Thanks for all the bug reports / patches, I will make these changes and push out another version this weekend.
#2
The change has been made check out beta 3 :)
#3
#4
Automatically closed -- issue fixed for two weeks with no activity.