mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-19 21:03:54 -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
|
// Ignore 'completed' event
|
||||||
if (isset($_GET['event']) && $_GET['event'] === 'completed') {
|
if (isset($_GET['event']) && $_GET['event'] === 'completed') {
|
||||||
if (DBG_LOG) {
|
|
||||||
dbg_log(' ', '!die-event-completed');
|
|
||||||
}
|
|
||||||
dummy_exit(mt_rand(600, 1200));
|
dummy_exit(mt_rand(600, 1200));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,10 +146,6 @@ $peer_hash = md5(
|
||||||
// Get cached peer info from previous announce (last peer info)
|
// Get cached peer info from previous announce (last peer info)
|
||||||
$lp_info = CACHE('tr_cache')->get(PEER_HASH_PREFIX . $peer_hash);
|
$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
|
// Drop fast announce
|
||||||
if ($lp_info && (!isset($event) || $event !== 'stopped')) {
|
if ($lp_info && (!isset($event) || $event !== 'stopped')) {
|
||||||
drop_fast_announce($lp_info);
|
drop_fast_announce($lp_info);
|
||||||
|
@ -174,10 +167,6 @@ function drop_fast_announce($lp_info)
|
||||||
|
|
||||||
function msg_die($msg)
|
function msg_die($msg)
|
||||||
{
|
{
|
||||||
if (DBG_LOG) {
|
|
||||||
dbg_log(' ', '!die-' . clean_filename($msg));
|
|
||||||
}
|
|
||||||
|
|
||||||
$output = \Rych\Bencode\Bencode::encode([
|
$output = \Rych\Bencode\Bencode::encode([
|
||||||
'min interval' => (int)1800,
|
'min interval' => (int)1800,
|
||||||
'failure reason' => (string)$msg,
|
'failure reason' => (string)$msg,
|
||||||
|
@ -196,9 +185,6 @@ $stopped = ($event === 'stopped');
|
||||||
// Stopped event
|
// Stopped event
|
||||||
if ($stopped) {
|
if ($stopped) {
|
||||||
CACHE('tr_cache')->rm(PEER_HASH_PREFIX . $peer_hash);
|
CACHE('tr_cache')->rm(PEER_HASH_PREFIX . $peer_hash);
|
||||||
if (DBG_LOG) {
|
|
||||||
dbg_log(' ', 'stopped');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get last peer info from DB
|
// Get last peer info from DB
|
||||||
|
@ -206,10 +192,6 @@ if (!CACHE('tr_cache')->used && !$lp_info) {
|
||||||
$lp_info = DB()->fetch_row("
|
$lp_info = DB()->fetch_row("
|
||||||
SELECT * FROM " . BB_BT_TRACKER . " WHERE peer_hash = '$peer_hash' LIMIT 1
|
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) {
|
if ($lp_info) {
|
||||||
|
@ -312,7 +294,7 @@ if ($lp_info) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Up/Down speed
|
// Up/Down speed
|
||||||
$speed_up = $speed_down = $uploaded = $downloaded = 0;
|
$speed_up = $speed_down = 0;
|
||||||
|
|
||||||
if ($lp_info && $lp_info['update_time'] < TIMENOW) {
|
if ($lp_info && $lp_info['update_time'] < TIMENOW) {
|
||||||
if ($uploaded > $lp_info['uploaded']) {
|
if ($uploaded > $lp_info['uploaded']) {
|
||||||
|
@ -358,8 +340,8 @@ if ($lp_info) {
|
||||||
$sql .= ($downloaded != $lp_info['downloaded']) ? ", downloaded = $downloaded" : '';
|
$sql .= ($downloaded != $lp_info['downloaded']) ? ", downloaded = $downloaded" : '';
|
||||||
$sql .= ", remain = $left";
|
$sql .= ", remain = $left";
|
||||||
|
|
||||||
$sql .= ($up_add) ? ", up_add = up_add + $up_add" : '';
|
$sql .= $up_add ? ", up_add = up_add + $up_add" : '';
|
||||||
$sql .= ($down_add) ? ", down_add = down_add + $down_add" : '';
|
$sql .= $down_add ? ", down_add = down_add + $down_add" : '';
|
||||||
|
|
||||||
$sql .= ", speed_up = $speed_up";
|
$sql .= ", speed_up = $speed_up";
|
||||||
$sql .= ", speed_down = $speed_down";
|
$sql .= ", speed_down = $speed_down";
|
||||||
|
@ -370,10 +352,6 @@ if ($lp_info) {
|
||||||
DB()->query($sql);
|
DB()->query($sql);
|
||||||
|
|
||||||
$peer_info_updated = DB()->affected_rows();
|
$peer_info_updated = DB()->affected_rows();
|
||||||
|
|
||||||
if (DBG_LOG) {
|
|
||||||
dbg_log(' ', 'this_peer-update' . ($peer_info_updated ? '' : '-FAIL'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$lp_info || !$peer_info_updated) {
|
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";
|
$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)");
|
DB()->query("REPLACE INTO " . BB_BT_TRACKER . " ($columns) VALUES ($values)");
|
||||||
|
|
||||||
if (DBG_LOG) {
|
|
||||||
dbg_log(' ', 'this_peer-insert');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exit if stopped
|
// 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);
|
$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
|
// Get cached output
|
||||||
$output = CACHE('tr_cache')->get(PEERS_LIST_PREFIX . $topic_id);
|
$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) {
|
if (!$output) {
|
||||||
// Retrieve peers
|
// Retrieve peers
|
||||||
$numwant = (int)$bb_cfg['tracker']['numwant'];
|
$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);
|
$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
|
// Return data to client
|
||||||
echo \Rych\Bencode\Bencode::encode($output);
|
echo \Rych\Bencode\Bencode::encode($output);
|
||||||
|
|
||||||
tracker_exit();
|
|
||||||
exit;
|
exit;
|
||||||
|
|
|
@ -37,45 +37,18 @@ if ($bb_cfg['tracker']['off']) {
|
||||||
//
|
//
|
||||||
// Functions
|
// 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()
|
function silent_exit()
|
||||||
{
|
{
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
|
|
||||||
tracker_exit();
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
function error_exit($msg = '')
|
function error_exit($msg = '')
|
||||||
{
|
{
|
||||||
if (DBG_LOG) {
|
|
||||||
dbg_log(' ', '!err-' . clean_filename($msg));
|
|
||||||
}
|
|
||||||
|
|
||||||
silent_exit();
|
silent_exit();
|
||||||
|
|
||||||
echo \Rych\Bencode\Bencode::encode(['failure reason' => str_compact($msg)]);
|
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)
|
function msg_die($msg)
|
||||||
{
|
{
|
||||||
if (DBG_LOG) {
|
|
||||||
dbg_log(' ', '!die-' . clean_filename($msg));
|
|
||||||
}
|
|
||||||
|
|
||||||
$output = \Rych\Bencode\Bencode::encode([
|
$output = \Rych\Bencode\Bencode::encode([
|
||||||
'min interval' => (int)1800,
|
'min interval' => (int)1800,
|
||||||
'failure reason' => (string)$msg,
|
'failure reason' => (string)$msg,
|
||||||
|
@ -79,5 +75,4 @@ $output['files'][$info_hash] = array(
|
||||||
|
|
||||||
echo \Rych\Bencode\Bencode::encode($output);
|
echo \Rych\Bencode\Bencode::encode($output);
|
||||||
|
|
||||||
tracker_exit();
|
|
||||||
exit;
|
exit;
|
||||||
|
|
|
@ -65,8 +65,6 @@ define('XS_TAG_ENDIF', 8);
|
||||||
define('XS_TAG_BEGINELSE', 11);
|
define('XS_TAG_BEGINELSE', 11);
|
||||||
|
|
||||||
// Debug
|
// 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('COOKIE_DBG', 'bb_dbg'); // debug cookie name
|
||||||
define('SQL_DEBUG', true); // enable forum sql & cache debug
|
define('SQL_DEBUG', true); // enable forum sql & cache debug
|
||||||
define('SQL_LOG_ERRORS', true); // all SQL_xxx options enabled only if SQL_DEBUG == TRUE
|
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)
|
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 . "
|
FROM " . BB_BT_TRACKER . "
|
||||||
WHERE (up_add != 0 OR down_add != 0)
|
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
|
// Reset up/down additions in tracker
|
||||||
|
|
|
@ -61,10 +61,6 @@ class Memcache extends Common
|
||||||
$this->connected = true;
|
$this->connected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DBG_LOG) {
|
|
||||||
dbg_log(' ', 'CACHE-connect' . ($this->connected ? '' : '-FAIL'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$this->connected && $this->cfg['con_required']) {
|
if (!$this->connected && $this->cfg['con_required']) {
|
||||||
die('Could not connect to memcached server');
|
die('Could not connect to memcached server');
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,10 +65,6 @@ class SqliteCommon extends Common
|
||||||
$this->connected = true;
|
$this->connected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DBG_LOG) {
|
|
||||||
dbg_log(' ', $this->cfg['log_name'] . '-connect' . ($this->connected ? '' : '-FAIL'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$this->connected && $this->cfg['con_required']) {
|
if (!$this->connected && $this->cfg['con_required']) {
|
||||||
trigger_error('SQLite not connected', E_USER_ERROR);
|
trigger_error('SQLite not connected', E_USER_ERROR);
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,10 +60,6 @@ class Memcache extends Common
|
||||||
$this->connected = true;
|
$this->connected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DBG_LOG) {
|
|
||||||
dbg_log(' ', 'CACHE-connect' . ($this->connected ? '' : '-FAIL'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$this->connected && $this->cfg['con_required']) {
|
if (!$this->connected && $this->cfg['con_required']) {
|
||||||
die('Could not connect to memcached server');
|
die('Could not connect to memcached server');
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,10 +65,6 @@ class SqliteCommon extends Common
|
||||||
$this->connected = true;
|
$this->connected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DBG_LOG) {
|
|
||||||
dbg_log(' ', $this->cfg['log_name'] . '-connect' . ($this->connected ? '' : '-FAIL'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$this->connected && $this->cfg['con_required']) {
|
if (!$this->connected && $this->cfg['con_required']) {
|
||||||
trigger_error('SQLite not connected', E_USER_ERROR);
|
trigger_error('SQLite not connected', E_USER_ERROR);
|
||||||
}
|
}
|
||||||
|
|
|
@ -805,7 +805,7 @@ class SqlDb
|
||||||
$dbg =& $this->dbg[$id];
|
$dbg =& $this->dbg[$id];
|
||||||
|
|
||||||
if ($mode == 'start') {
|
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();
|
$this->sql_starttime = utime();
|
||||||
}
|
}
|
||||||
if ($this->dbg_enabled) {
|
if ($this->dbg_enabled) {
|
||||||
|
@ -821,7 +821,7 @@ class SqlDb
|
||||||
$this->explain('start');
|
$this->explain('start');
|
||||||
}
|
}
|
||||||
} elseif ($mode == 'stop') {
|
} 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->cur_query_time = utime() - $this->sql_starttime;
|
||||||
$this->sql_timetotal += $this->cur_query_time;
|
$this->sql_timetotal += $this->cur_query_time;
|
||||||
$this->DBS['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')
|
public function trigger_error($msg = 'DB Error')
|
||||||
{
|
{
|
||||||
if (error_reporting()) {
|
if (error_reporting()) {
|
||||||
if (DBG_LOG === true) {
|
$msg .= ' [' . $this->debug_find_source() . ']';
|
||||||
$err = $this->sql_error();
|
|
||||||
$msg .= "\n" . trim(sprintf('#%06d %s', $err['code'], $err['message']));
|
|
||||||
} else {
|
|
||||||
$msg .= ' [' . $this->debug_find_source() . ']';
|
|
||||||
}
|
|
||||||
|
|
||||||
trigger_error($msg, E_USER_ERROR);
|
trigger_error($msg, E_USER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,11 +223,6 @@
|
||||||
<td>{L_SIZE}:</td>
|
<td>{L_SIZE}:</td>
|
||||||
<td>{postrow.attach.tor_reged.TORRENT_SIZE}</td>
|
<td>{postrow.attach.tor_reged.TORRENT_SIZE}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- BEGIN comment -->
|
|
||||||
<tr class="row1 tCenter">
|
|
||||||
<td colspan="3">{postrow.attach.tor_reged.comment.COMMENT}</td>
|
|
||||||
</tr>
|
|
||||||
<!-- END comment -->
|
|
||||||
<tr class="row3 tCenter">
|
<tr class="row3 tCenter">
|
||||||
<td colspan="3">
|
<td colspan="3">
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue