mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-14 10:37:30 -07:00
Broken announcer fix, announcer debug removed.
This commit is contained in:
parent
78b8a38e73
commit
9aba4d0d59
11 changed files with 9 additions and 109 deletions
|
@ -36,9 +36,6 @@ if (empty($_SERVER['HTTP_USER_AGENT'])) {
|
|||
|
||||
// Ignore 'completed' event
|
||||
if (isset($_GET['event']) && $_GET['event'] === 'completed') {
|
||||
if (DBG_LOG) {
|
||||
dbg_log(' ', '!die-event-completed');
|
||||
}
|
||||
dummy_exit(mt_rand(600, 1200));
|
||||
}
|
||||
|
||||
|
@ -149,10 +146,6 @@ $peer_hash = md5(
|
|||
// Get cached peer info from previous announce (last peer info)
|
||||
$lp_info = CACHE('tr_cache')->get(PEER_HASH_PREFIX . $peer_hash);
|
||||
|
||||
if (DBG_LOG) {
|
||||
dbg_log(' ', '$lp_info-get_from-CACHE-' . ($lp_info ? 'hit' : 'miss'));
|
||||
}
|
||||
|
||||
// Drop fast announce
|
||||
if ($lp_info && (!isset($event) || $event !== 'stopped')) {
|
||||
drop_fast_announce($lp_info);
|
||||
|
@ -174,10 +167,6 @@ function drop_fast_announce($lp_info)
|
|||
|
||||
function msg_die($msg)
|
||||
{
|
||||
if (DBG_LOG) {
|
||||
dbg_log(' ', '!die-' . clean_filename($msg));
|
||||
}
|
||||
|
||||
$output = \Rych\Bencode\Bencode::encode([
|
||||
'min interval' => (int)1800,
|
||||
'failure reason' => (string)$msg,
|
||||
|
@ -196,9 +185,6 @@ $stopped = ($event === 'stopped');
|
|||
// Stopped event
|
||||
if ($stopped) {
|
||||
CACHE('tr_cache')->rm(PEER_HASH_PREFIX . $peer_hash);
|
||||
if (DBG_LOG) {
|
||||
dbg_log(' ', 'stopped');
|
||||
}
|
||||
}
|
||||
|
||||
// Get last peer info from DB
|
||||
|
@ -206,10 +192,6 @@ if (!CACHE('tr_cache')->used && !$lp_info) {
|
|||
$lp_info = DB()->fetch_row("
|
||||
SELECT * FROM " . BB_BT_TRACKER . " WHERE peer_hash = '$peer_hash' LIMIT 1
|
||||
");
|
||||
|
||||
if (DBG_LOG) {
|
||||
dbg_log(' ', '$lp_info-get_from-DB-' . ($lp_info ? 'hit' : 'miss'));
|
||||
}
|
||||
}
|
||||
|
||||
if ($lp_info) {
|
||||
|
@ -312,7 +294,7 @@ if ($lp_info) {
|
|||
}
|
||||
|
||||
// Up/Down speed
|
||||
$speed_up = $speed_down = $uploaded = $downloaded = 0;
|
||||
$speed_up = $speed_down = 0;
|
||||
|
||||
if ($lp_info && $lp_info['update_time'] < TIMENOW) {
|
||||
if ($uploaded > $lp_info['uploaded']) {
|
||||
|
@ -358,8 +340,8 @@ if ($lp_info) {
|
|||
$sql .= ($downloaded != $lp_info['downloaded']) ? ", downloaded = $downloaded" : '';
|
||||
$sql .= ", remain = $left";
|
||||
|
||||
$sql .= ($up_add) ? ", up_add = up_add + $up_add" : '';
|
||||
$sql .= ($down_add) ? ", down_add = down_add + $down_add" : '';
|
||||
$sql .= $up_add ? ", up_add = up_add + $up_add" : '';
|
||||
$sql .= $down_add ? ", down_add = down_add + $down_add" : '';
|
||||
|
||||
$sql .= ", speed_up = $speed_up";
|
||||
$sql .= ", speed_down = $speed_down";
|
||||
|
@ -370,10 +352,6 @@ if ($lp_info) {
|
|||
DB()->query($sql);
|
||||
|
||||
$peer_info_updated = DB()->affected_rows();
|
||||
|
||||
if (DBG_LOG) {
|
||||
dbg_log(' ', 'this_peer-update' . ($peer_info_updated ? '' : '-FAIL'));
|
||||
}
|
||||
}
|
||||
|
||||
if (!$lp_info || !$peer_info_updated) {
|
||||
|
@ -381,10 +359,6 @@ if (!$lp_info || !$peer_info_updated) {
|
|||
$values = "'$peer_hash', $topic_id, $user_id, '$ip_sql', $port, $seeder, $releaser, $tor_type, $uploaded, $downloaded, $left, $speed_up, $speed_down, $up_add, $down_add, $update_time";
|
||||
|
||||
DB()->query("REPLACE INTO " . BB_BT_TRACKER . " ($columns) VALUES ($values)");
|
||||
|
||||
if (DBG_LOG) {
|
||||
dbg_log(' ', 'this_peer-insert');
|
||||
}
|
||||
}
|
||||
|
||||
// Exit if stopped
|
||||
|
@ -406,17 +380,9 @@ $lp_info = array(
|
|||
|
||||
$lp_info_cached = CACHE('tr_cache')->set(PEER_HASH_PREFIX . $peer_hash, $lp_info, PEER_HASH_EXPIRE);
|
||||
|
||||
if (DBG_LOG && !$lp_info_cached) {
|
||||
dbg_log(' ', '$lp_info-caching-FAIL');
|
||||
}
|
||||
|
||||
// Get cached output
|
||||
$output = CACHE('tr_cache')->get(PEERS_LIST_PREFIX . $topic_id);
|
||||
|
||||
if (DBG_LOG) {
|
||||
dbg_log(' ', '$output-get_from-CACHE-' . ($output !== false ? 'hit' : 'miss'));
|
||||
}
|
||||
|
||||
if (!$output) {
|
||||
// Retrieve peers
|
||||
$numwant = (int)$bb_cfg['tracker']['numwant'];
|
||||
|
@ -471,14 +437,9 @@ if (!$output) {
|
|||
);
|
||||
|
||||
$peers_list_cached = CACHE('tr_cache')->set(PEERS_LIST_PREFIX . $topic_id, $output, PEERS_LIST_EXPIRE);
|
||||
|
||||
if (DBG_LOG && !$peers_list_cached) {
|
||||
dbg_log(' ', '$output-caching-FAIL');
|
||||
}
|
||||
}
|
||||
|
||||
// Return data to client
|
||||
echo \Rych\Bencode\Bencode::encode($output);
|
||||
|
||||
tracker_exit();
|
||||
exit;
|
||||
|
|
|
@ -37,45 +37,18 @@ if ($bb_cfg['tracker']['off']) {
|
|||
//
|
||||
// Functions
|
||||
//
|
||||
function tracker_exit()
|
||||
{
|
||||
global $DBS;
|
||||
|
||||
if (DBG_LOG && DBG_TRACKER) {
|
||||
if ($gen_time = utime() - TIMESTART) {
|
||||
$sql_init_perc = round($DBS->sql_inittime * 100 / $gen_time);
|
||||
$sql_total_perc = round($DBS->sql_timetotal * 100 / $gen_time);
|
||||
|
||||
$str = array();
|
||||
$str[] = substr(TIMENOW, -4, 4);
|
||||
$str[] = sprintf('%.4f', $gen_time);
|
||||
$str[] = sprintf('%.4f' . LOG_SEPR . '%02d%%', $DBS->sql_inittime, $sql_init_perc);
|
||||
$str[] = sprintf('%.4f' . LOG_SEPR . '%02d%%', $DBS->sql_timetotal, $sql_total_perc);
|
||||
$str[] = $DBS->num_queries;
|
||||
$str[] = sprintf('%.1f', sys('la'));
|
||||
$str = implode(LOG_SEPR, $str) . LOG_LF;
|
||||
dbg_log($str, '!!gentime');
|
||||
}
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
function silent_exit()
|
||||
{
|
||||
ob_end_clean();
|
||||
|
||||
tracker_exit();
|
||||
exit;
|
||||
}
|
||||
|
||||
function error_exit($msg = '')
|
||||
{
|
||||
if (DBG_LOG) {
|
||||
dbg_log(' ', '!err-' . clean_filename($msg));
|
||||
}
|
||||
|
||||
silent_exit();
|
||||
|
||||
echo \Rych\Bencode\Bencode::encode(['failure reason' => str_compact($msg)]);
|
||||
|
||||
tracker_exit();
|
||||
exit;
|
||||
}
|
||||
|
|
|
@ -46,10 +46,6 @@ $info_hash = $_GET['info_hash'];
|
|||
|
||||
function msg_die($msg)
|
||||
{
|
||||
if (DBG_LOG) {
|
||||
dbg_log(' ', '!die-' . clean_filename($msg));
|
||||
}
|
||||
|
||||
$output = \Rych\Bencode\Bencode::encode([
|
||||
'min interval' => (int)1800,
|
||||
'failure reason' => (string)$msg,
|
||||
|
@ -79,5 +75,4 @@ $output['files'][$info_hash] = array(
|
|||
|
||||
echo \Rych\Bencode\Bencode::encode($output);
|
||||
|
||||
tracker_exit();
|
||||
exit;
|
||||
|
|
|
@ -65,8 +65,6 @@ define('XS_TAG_ENDIF', 8);
|
|||
define('XS_TAG_BEGINELSE', 11);
|
||||
|
||||
// Debug
|
||||
define('DBG_LOG', false); // enable forum debug (off on production)
|
||||
define('DBG_TRACKER', false); // enable tracker debug (off on production)
|
||||
define('COOKIE_DBG', 'bb_dbg'); // debug cookie name
|
||||
define('SQL_DEBUG', true); // enable forum sql & cache debug
|
||||
define('SQL_LOG_ERRORS', true); // all SQL_xxx options enabled only if SQL_DEBUG == TRUE
|
||||
|
|
|
@ -58,7 +58,7 @@ if ($bb_cfg['tracker']['update_dlstat']) {
|
|||
topic_id, user_id, IF(releaser, $releaser, seeder), SUM(up_add), SUM(down_add), IF(releaser, SUM(up_add), 0), SUM(speed_up), SUM(speed_down)
|
||||
FROM " . BB_BT_TRACKER . "
|
||||
WHERE (up_add != 0 OR down_add != 0)
|
||||
GROUP BY topic_id, user_id, releaser, seeder
|
||||
GROUP BY topic_id, user_id
|
||||
");
|
||||
|
||||
// Reset up/down additions in tracker
|
||||
|
|
|
@ -61,10 +61,6 @@ class Memcache extends Common
|
|||
$this->connected = true;
|
||||
}
|
||||
|
||||
if (DBG_LOG) {
|
||||
dbg_log(' ', 'CACHE-connect' . ($this->connected ? '' : '-FAIL'));
|
||||
}
|
||||
|
||||
if (!$this->connected && $this->cfg['con_required']) {
|
||||
die('Could not connect to memcached server');
|
||||
}
|
||||
|
|
|
@ -65,10 +65,6 @@ class SqliteCommon extends Common
|
|||
$this->connected = true;
|
||||
}
|
||||
|
||||
if (DBG_LOG) {
|
||||
dbg_log(' ', $this->cfg['log_name'] . '-connect' . ($this->connected ? '' : '-FAIL'));
|
||||
}
|
||||
|
||||
if (!$this->connected && $this->cfg['con_required']) {
|
||||
trigger_error('SQLite not connected', E_USER_ERROR);
|
||||
}
|
||||
|
|
|
@ -60,10 +60,6 @@ class Memcache extends Common
|
|||
$this->connected = true;
|
||||
}
|
||||
|
||||
if (DBG_LOG) {
|
||||
dbg_log(' ', 'CACHE-connect' . ($this->connected ? '' : '-FAIL'));
|
||||
}
|
||||
|
||||
if (!$this->connected && $this->cfg['con_required']) {
|
||||
die('Could not connect to memcached server');
|
||||
}
|
||||
|
|
|
@ -65,10 +65,6 @@ class SqliteCommon extends Common
|
|||
$this->connected = true;
|
||||
}
|
||||
|
||||
if (DBG_LOG) {
|
||||
dbg_log(' ', $this->cfg['log_name'] . '-connect' . ($this->connected ? '' : '-FAIL'));
|
||||
}
|
||||
|
||||
if (!$this->connected && $this->cfg['con_required']) {
|
||||
trigger_error('SQLite not connected', E_USER_ERROR);
|
||||
}
|
||||
|
|
|
@ -805,7 +805,7 @@ class SqlDb
|
|||
$dbg =& $this->dbg[$id];
|
||||
|
||||
if ($mode == 'start') {
|
||||
if (SQL_CALC_QUERY_TIME || DBG_LOG || SQL_LOG_SLOW_QUERIES) {
|
||||
if (SQL_CALC_QUERY_TIME || SQL_LOG_SLOW_QUERIES) {
|
||||
$this->sql_starttime = utime();
|
||||
}
|
||||
if ($this->dbg_enabled) {
|
||||
|
@ -821,7 +821,7 @@ class SqlDb
|
|||
$this->explain('start');
|
||||
}
|
||||
} elseif ($mode == 'stop') {
|
||||
if (SQL_CALC_QUERY_TIME || DBG_LOG || SQL_LOG_SLOW_QUERIES) {
|
||||
if (SQL_CALC_QUERY_TIME || SQL_LOG_SLOW_QUERIES) {
|
||||
$this->cur_query_time = utime() - $this->sql_starttime;
|
||||
$this->sql_timetotal += $this->cur_query_time;
|
||||
$this->DBS['sql_timetotal'] += $this->cur_query_time;
|
||||
|
@ -855,13 +855,7 @@ class SqlDb
|
|||
public function trigger_error($msg = 'DB Error')
|
||||
{
|
||||
if (error_reporting()) {
|
||||
if (DBG_LOG === true) {
|
||||
$err = $this->sql_error();
|
||||
$msg .= "\n" . trim(sprintf('#%06d %s', $err['code'], $err['message']));
|
||||
} else {
|
||||
$msg .= ' [' . $this->debug_find_source() . ']';
|
||||
}
|
||||
|
||||
$msg .= ' [' . $this->debug_find_source() . ']';
|
||||
trigger_error($msg, E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -223,11 +223,6 @@
|
|||
<td>{L_SIZE}:</td>
|
||||
<td>{postrow.attach.tor_reged.TORRENT_SIZE}</td>
|
||||
</tr>
|
||||
<!-- BEGIN comment -->
|
||||
<tr class="row1 tCenter">
|
||||
<td colspan="3">{postrow.attach.tor_reged.comment.COMMENT}</td>
|
||||
</tr>
|
||||
<!-- END comment -->
|
||||
<tr class="row3 tCenter">
|
||||
<td colspan="3">
|
||||
<script type="text/javascript">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue