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
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

bradfordcp - January 30, 2008 - 14:30

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

#2

bradfordcp - February 4, 2008 - 22:19
Status:active» closed

The change has been made check out beta 3 :)

#3

bradfordcp - February 4, 2008 - 22:21
Status:closed» fixed

#4

Anonymous (not verified) - February 18, 2008 - 22:22
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.