mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-22 12:34:27 +00:00
miner.php add a socket RCV timeout for if cgminer is hung and the API thread is still running
This commit is contained in:
parent
09bdf81644
commit
8a35b4ac7a
22
miner.php
22
miner.php
@ -1,7 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
#
|
#
|
||||||
global $miner, $port, $readonly, $notify, $rigs, $socktimeoutsec;
|
global $miner, $port, $readonly, $notify, $rigs;
|
||||||
|
global $socksndtimeoutsec, $sockrcvtimeoutsec;
|
||||||
global $checklastshare, $hidefields;
|
global $checklastshare, $hidefields;
|
||||||
global $ignorerefresh, $changerefresh, $autorefresh;
|
global $ignorerefresh, $changerefresh, $autorefresh;
|
||||||
global $allowcustompages, $customsummarypages;
|
global $allowcustompages, $customsummarypages;
|
||||||
@ -38,12 +39,16 @@ $checklastshare = true;
|
|||||||
# e.g. $rigs = array('127.0.0.1:4028','myrig.com:4028:Sugoi');
|
# e.g. $rigs = array('127.0.0.1:4028','myrig.com:4028:Sugoi');
|
||||||
$rigs = array('127.0.0.1:4028');
|
$rigs = array('127.0.0.1:4028');
|
||||||
#
|
#
|
||||||
# This should be OK for most cases
|
# These should be OK for most cases
|
||||||
# However, the longer it is the longer you have to wait while php
|
# However, the longer SND is, the longer you have to wait while
|
||||||
# hangs if the target cgminer isn't runnning or listening
|
# php hangs if the target cgminer isn't runnning or listening
|
||||||
# Feel free to increase it if your network is very slow
|
# RCV should only ever be relevant if cgminer has hung but the
|
||||||
|
# API thread is still running, RCV would normally be >= SND
|
||||||
|
# Feel free to increase SND if your network is very slow
|
||||||
|
# or decrease RCV if that happens often to you
|
||||||
# Also, on some windows PHP, apparently the $usec is ignored
|
# Also, on some windows PHP, apparently the $usec is ignored
|
||||||
$socktimeoutsec = 10;
|
$socksndtimeoutsec = 10;
|
||||||
|
$sockrcvtimeoutsec = 40;
|
||||||
#
|
#
|
||||||
# List of fields NOT to be displayed
|
# List of fields NOT to be displayed
|
||||||
# You can use this to hide data you don't want to see or don't want
|
# You can use this to hide data you don't want to see or don't want
|
||||||
@ -260,7 +265,7 @@ $error = null;
|
|||||||
#
|
#
|
||||||
function getsock($addr, $port)
|
function getsock($addr, $port)
|
||||||
{
|
{
|
||||||
global $haderror, $error, $socktimeoutsec;
|
global $haderror, $error, $socksndtimeoutsec, $sockrcvtimeoutsec;
|
||||||
|
|
||||||
$error = null;
|
$error = null;
|
||||||
$socket = null;
|
$socket = null;
|
||||||
@ -277,7 +282,8 @@ function getsock($addr, $port)
|
|||||||
// Ignore if this fails since the socket connect may work anyway
|
// Ignore if this fails since the socket connect may work anyway
|
||||||
// and nothing is gained by aborting if the option cannot be set
|
// and nothing is gained by aborting if the option cannot be set
|
||||||
// since we don't know in advance if it can connect
|
// since we don't know in advance if it can connect
|
||||||
socket_set_option($socket, SOL_SOCKET, SO_SNDTIMEO, array('sec' => $socktimeoutsec, 'usec' => 0));
|
socket_set_option($socket, SOL_SOCKET, SO_SNDTIMEO, array('sec' => $socksndtimeoutsec, 'usec' => 0));
|
||||||
|
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => $sockrcvtimeoutsec, 'usec' => 0));
|
||||||
|
|
||||||
$res = socket_connect($socket, $addr, $port);
|
$res = socket_connect($socket, $addr, $port);
|
||||||
if ($res === false)
|
if ($res === false)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user