mirror of
https://github.com/UberGames/lilium-voyager.git
synced 2024-11-10 14:41:42 +00:00
* (bug #4346) Dedicated server uses 100% CPU when stdin is not a TTY
* com_speeds reports misleading values on dedicated server (Guillaume Bougard)
This commit is contained in:
parent
fa2a698aa3
commit
78df7a1de4
3 changed files with 38 additions and 15 deletions
|
@ -3065,6 +3065,12 @@ void Com_Frame( void ) {
|
||||||
if ( com_speeds->integer ) {
|
if ( com_speeds->integer ) {
|
||||||
timeAfter = Sys_Milliseconds ();
|
timeAfter = Sys_Milliseconds ();
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if ( com_speeds->integer ) {
|
||||||
|
timeAfter = Sys_Milliseconds ();
|
||||||
|
timeBeforeEvents = timeAfter;
|
||||||
|
timeBeforeClient = timeAfter;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -40,6 +40,7 @@ called before and after a stdout or stderr output
|
||||||
=============================================================
|
=============================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
extern qboolean stdinIsATTY;
|
||||||
static qboolean stdin_active;
|
static qboolean stdin_active;
|
||||||
// general flag to tell about tty console mode
|
// general flag to tell about tty console mode
|
||||||
static qboolean ttycon_on = qfalse;
|
static qboolean ttycon_on = qfalse;
|
||||||
|
@ -268,7 +269,6 @@ Initialize the console input (tty mode if possible)
|
||||||
void CON_Init( void )
|
void CON_Init( void )
|
||||||
{
|
{
|
||||||
struct termios tc;
|
struct termios tc;
|
||||||
const char* term = getenv("TERM");
|
|
||||||
|
|
||||||
// If the process is backgrounded (running non interactively)
|
// If the process is backgrounded (running non interactively)
|
||||||
// then SIGTTIN or SIGTOU is emitted, if not caught, turns into a SIGSTP
|
// then SIGTTIN or SIGTOU is emitted, if not caught, turns into a SIGSTP
|
||||||
|
@ -281,8 +281,7 @@ void CON_Init( void )
|
||||||
// Make stdin reads non-blocking
|
// Make stdin reads non-blocking
|
||||||
fcntl(STDIN_FILENO, F_SETFL, fcntl(STDIN_FILENO, F_GETFL, 0) | O_NONBLOCK );
|
fcntl(STDIN_FILENO, F_SETFL, fcntl(STDIN_FILENO, F_GETFL, 0) | O_NONBLOCK );
|
||||||
|
|
||||||
if (isatty(STDIN_FILENO) != 1
|
if (!stdinIsATTY)
|
||||||
|| (term && (!strcmp(term, "raw") || !strcmp(term, "dumb"))))
|
|
||||||
{
|
{
|
||||||
Com_Printf("tty console mode disabled\n");
|
Com_Printf("tty console mode disabled\n");
|
||||||
ttycon_on = qfalse;
|
ttycon_on = qfalse;
|
||||||
|
|
|
@ -37,6 +37,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
qboolean stdinIsATTY;
|
||||||
|
|
||||||
// Used to determine where to store user-specific files
|
// Used to determine where to store user-specific files
|
||||||
static char homePath[ MAX_OSPATH ] = { 0 };
|
static char homePath[ MAX_OSPATH ] = { 0 };
|
||||||
|
|
||||||
|
@ -464,16 +466,18 @@ Block execution for msec or until input is recieved.
|
||||||
*/
|
*/
|
||||||
void Sys_Sleep( int msec )
|
void Sys_Sleep( int msec )
|
||||||
{
|
{
|
||||||
fd_set fdset;
|
|
||||||
|
|
||||||
if( msec == 0 )
|
if( msec == 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if( stdinIsATTY )
|
||||||
|
{
|
||||||
|
fd_set fdset;
|
||||||
|
|
||||||
FD_ZERO(&fdset);
|
FD_ZERO(&fdset);
|
||||||
FD_SET(fileno(stdin), &fdset);
|
FD_SET(STDIN_FILENO, &fdset);
|
||||||
if( msec < 0 )
|
if( msec < 0 )
|
||||||
{
|
{
|
||||||
select((fileno(stdin) + 1), &fdset, NULL, NULL, NULL);
|
select(STDIN_FILENO + 1, &fdset, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -481,7 +485,16 @@ void Sys_Sleep( int msec )
|
||||||
|
|
||||||
timeout.tv_sec = msec/1000;
|
timeout.tv_sec = msec/1000;
|
||||||
timeout.tv_usec = (msec%1000)*1000;
|
timeout.tv_usec = (msec%1000)*1000;
|
||||||
select((fileno(stdin) + 1), &fdset, NULL, NULL, &timeout);
|
select(STDIN_FILENO + 1, &fdset, NULL, NULL, &timeout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// With nothing to select() on, we can't wait indefinitely
|
||||||
|
if( msec < 0 )
|
||||||
|
msec = 10;
|
||||||
|
|
||||||
|
usleep( msec * 1000 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -571,11 +584,16 @@ Unix specific initialisation
|
||||||
*/
|
*/
|
||||||
void Sys_PlatformInit( void )
|
void Sys_PlatformInit( void )
|
||||||
{
|
{
|
||||||
|
const char* term = getenv( "TERM" );
|
||||||
|
|
||||||
signal( SIGHUP, Sys_SigHandler );
|
signal( SIGHUP, Sys_SigHandler );
|
||||||
signal( SIGQUIT, Sys_SigHandler );
|
signal( SIGQUIT, Sys_SigHandler );
|
||||||
signal( SIGTRAP, Sys_SigHandler );
|
signal( SIGTRAP, Sys_SigHandler );
|
||||||
signal( SIGIOT, Sys_SigHandler );
|
signal( SIGIOT, Sys_SigHandler );
|
||||||
signal( SIGBUS, Sys_SigHandler );
|
signal( SIGBUS, Sys_SigHandler );
|
||||||
|
|
||||||
|
stdinIsATTY = isatty( STDIN_FILENO ) &&
|
||||||
|
!( term && ( !strcmp( term, "raw" ) || !strcmp( term, "dumb" ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue