This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch master
in repository openjk.

commit 8e38f7533772cdcb7d712f6b9c9b58b3580d6c46
Author: Simon McVittie <[email protected]>
Date:   Wed Dec 31 01:01:04 2014 +0000

    Use NET_Sleep() (or Sys_Sleep() for SP) to avoid busy-waiting
---
 ...ep-or-Sys_Sleep-for-SP-to-avoid-busy-wait.patch | 801 +++++++++++++++++++++
 debian/patches/series                              |   1 +
 2 files changed, 802 insertions(+)

diff --git 
a/debian/patches/Use-NET_Sleep-or-Sys_Sleep-for-SP-to-avoid-busy-wait.patch 
b/debian/patches/Use-NET_Sleep-or-Sys_Sleep-for-SP-to-avoid-busy-wait.patch
new file mode 100644
index 0000000..117bb96
--- /dev/null
+++ b/debian/patches/Use-NET_Sleep-or-Sys_Sleep-for-SP-to-avoid-busy-wait.patch
@@ -0,0 +1,801 @@
+From: Simon McVittie <[email protected]>
+Date: Wed, 31 Dec 2014 01:00:21 +0000
+Subject: Use NET_Sleep() (or Sys_Sleep() for SP) to avoid busy-waiting
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 8bit
+
+Backported and simplified from an assortment of ioquake3 commits,
+mostly by Thilo Schulz, with contributions from Zack Middleton and
+Özkan Sezer.
+---
+ code/qcommon/common.cpp       |  91 +++++++++++++++++++++------------
+ code/qcommon/qcommon.h        |   6 +--
+ code/win32/win_main.cpp       |   8 +++
+ codemp/null/null_net.c        |  11 ----
+ codemp/qcommon/common.cpp     | 116 +++++++++++++++++++++++++-----------------
+ codemp/qcommon/net_ip.cpp     |  92 ++++++++++++++++++++++++++++-----
+ codemp/qcommon/qcommon.h      |   6 +--
+ codemp/server/sv_main.cpp     |  32 +++++++++---
+ codemp/sys/sys_unix.cpp       |  17 -------
+ codemp/win32/win_main.cpp     |  18 -------
+ codemp/win32/win_main_ded.cpp |  16 ------
+ 11 files changed, 243 insertions(+), 170 deletions(-)
+
+diff --git a/code/qcommon/common.cpp b/code/qcommon/common.cpp
+index fb33c65..bf8a496 100644
+--- a/code/qcommon/common.cpp
++++ b/code/qcommon/common.cpp
+@@ -53,6 +53,7 @@ cvar_t       *sv_paused;
+ cvar_t        *com_skippingcin;
+ cvar_t        *com_speedslog;         // 1 = buffer log, 2 = flush after each 
print
+ cvar_t  *com_homepath;
++cvar_t        *com_busyWait;
+ 
+ #ifdef G2_PERFORMANCE_ANALYSIS
+ cvar_t        *com_G2Report;
+@@ -70,7 +71,6 @@ int          timeInPVSCheck;
+ int           numTraces;
+ 
+ int                   com_frameTime;
+-int                   com_frameMsec;
+ int                   com_frameNumber = 0;
+ 
+ qboolean      com_errorEntered = qfalse;
+@@ -873,25 +873,6 @@ int Com_EventLoop( void ) {
+                       Cbuf_AddText( (char *)ev.evPtr );
+                       Cbuf_AddText( "\n" );
+                       break;
+-              case SE_PACKET:
+-                      evFrom = *(netadr_t *)ev.evPtr;
+-                      buf.cursize = ev.evPtrLength - sizeof( evFrom );
+-
+-                      // we must copy the contents of the message out, because
+-                      // the event buffers are only large enough to hold the
+-                      // exact payload, but channel messages need to be large
+-                      // enough to hold fragment reassembly
+-                      if ( (unsigned)buf.cursize > (unsigned)buf.maxsize ) {
+-                              Com_Printf("Com_EventLoop: oversize packet\n");
+-                              continue;
+-                      }
+-                      memcpy( buf.data, (byte *)((netadr_t *)ev.evPtr + 1), 
buf.cursize );
+-                      if ( com_sv_running->integer ) {
+-                              Com_RunAndTimeServerPacket( &evFrom, &buf );
+-                      } else {
+-                              CL_PacketEvent( evFrom, &buf );
+-                      }
+-                      break;
+               }
+ 
+               // free any block data
+@@ -1160,6 +1141,7 @@ void Com_Init( char *commandLine ) {
+               com_buildScript = Cvar_Get( "com_buildScript", "0", 0 );
+ 
+               com_affinity = Cvar_Get( "com_affinity", "1", CVAR_ARCHIVE );
++              com_busyWait = Cvar_Get( "com_busyWait", "0", CVAR_ARCHIVE );
+ 
+               com_bootlogo = Cvar_Get( "com_bootlogo", "1", CVAR_ARCHIVE );
+               
+@@ -1350,6 +1332,26 @@ int Com_ModifyMsec( int msec, float &fraction )
+ 
+ /*
+ =================
++Com_TimeVal
++=================
++*/
++
++int Com_TimeVal(int minMsec)
++{
++      int timeVal;
++
++      timeVal = Sys_Milliseconds() - com_frameTime;
++
++      if(timeVal >= minMsec)
++              timeVal = 0;
++      else
++              timeVal = minMsec - timeVal;
++
++      return timeVal;
++}
++
++/*
++=================
+ Com_Frame
+ =================
+ */
+@@ -1375,7 +1377,8 @@ void Com_Frame( void ) {
+       {
+               int             timeBeforeFirstEvents = 0, timeBeforeServer = 
0, timeBeforeEvents = 0, timeBeforeClient = 0, timeAfter = 0;
+               int             msec, minMsec;
+-              static int      lastTime = 0;
++              int             timeVal;
++              static int      lastTime = 0, bias = 0;
+ 
+               // write config file if anything changed
+               Com_WriteConfiguration(); 
+@@ -1393,25 +1396,47 @@ void Com_Frame( void ) {
+                       timeBeforeFirstEvents = Sys_Milliseconds ();
+               }
+ 
+-              // we may want to spin here if things are going too fast
+-              if ( com_maxfps->integer > 0 ) {
++// Figure out how much time we have
++#if 0
++              // FIXME: enable this ioquake3 feature one day
++              if(com_minimized->integer && com_maxfpsMinimized->integer > 0)
++                      minMsec = 1000 / com_maxfpsMinimized->integer;
++              else if(com_unfocused->integer && com_maxfpsUnfocused->integer 
> 0)
++                      minMsec = 1000 / com_maxfpsUnfocused->integer;
++              else
++#endif
++              if(com_maxfps->integer > 0)
+                       minMsec = 1000 / com_maxfps->integer;
+-              } else {
++              else
+                       minMsec = 1;
+-              }
++
++              timeVal = com_frameTime - lastTime;
++              bias += timeVal - minMsec;
++
++              if (bias > minMsec)
++                      bias = minMsec;
++
++              // Adjust minMsec if previous frame took too long to render so
++              // that framerate is stable at the requested value.
++              minMsec -= bias;
++
++              timeVal = Com_TimeVal(minMsec);
+               do {
+-                      com_frameTime = Com_EventLoop();
+-                      if ( lastTime > com_frameTime ) {
+-                              lastTime = com_frameTime;               // 
possible on first frame
+-                      }
+-                      msec = com_frameTime - lastTime;
+-              } while ( msec < minMsec );
+-              Cbuf_Execute ();
++                      // Busy sleep the last millisecond for better timeout 
precision
++                      if(com_busyWait->integer || timeVal < 1)
++                              Sys_Sleep(0);
++                      else
++                              Sys_Sleep(timeVal - 1);
++              } while( (timeVal = Com_TimeVal(minMsec)) != 0 );
+ 
+               lastTime = com_frameTime;
++              com_frameTime = Com_EventLoop();
++
++              msec = com_frameTime - lastTime;
++
++              Cbuf_Execute ();
+ 
+               // mess with msec if needed
+-              com_frameMsec = msec;
+               float fractionMsec=0.0f;
+               msec = Com_ModifyMsec( msec, fractionMsec);
+       
+diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h
+index 2f87978..f1ed20e 100644
+--- a/code/qcommon/qcommon.h
++++ b/code/qcommon/qcommon.h
+@@ -572,6 +572,7 @@ unsigned   Com_BlockChecksum( const void *buffer, int 
length );
+ int                   Com_Filter(const char *filter, const char *name, int 
casesensitive);
+ int                   Com_FilterPath(const char *filter, const char *name, 
int casesensitive);
+ qboolean      Com_SafeMode( void );
++void          Com_RunAndTimeServerPacket(netadr_t *evFrom, msg_t *buf);
+ 
+ void          Com_StartupVariable( const char *match );
+ // checks for and removes command line "+set var arg" constructs
+@@ -602,7 +603,6 @@ extern     int             timeInPVSCheck;
+ extern        int             numTraces;
+ 
+ extern        int             com_frameTime;
+-extern        int             com_frameMsec;
+ 
+ extern        qboolean        com_errorEntered;
+ 
+@@ -778,8 +778,7 @@ typedef enum {
+       SE_CHAR,        // evValue is an ascii char
+       SE_MOUSE,       // evValue and evValue2 are reletive signed x / y moves
+       SE_JOYSTICK_AXIS,       // evValue is an axis number and evValue2 is 
the current state (-127 to 127)
+-      SE_CONSOLE,     // evPtr is a char*
+-      SE_PACKET       // evPtr is a netadr_t followed by data bytes to 
evPtrLength
++      SE_CONSOLE      // evPtr is a char*
+ } sysEventType_t;
+ 
+ typedef struct {
+@@ -843,6 +842,7 @@ const char *Sys_Basename( char *path );
+ 
+ char **Sys_ListFiles( const char *directory, const char *extension, char 
*filter, int *numfiles, qboolean wantsubs );
+ void  Sys_FreeFileList( char **filelist );
++void  Sys_Sleep(int msec);
+ 
+ qboolean Sys_LowPhysicalMemory();
+ qboolean Sys_FileOutOfDate( const char *psFinalFileName /* dest */, const 
char *psDataFileName /* src */ );
+diff --git a/code/win32/win_main.cpp b/code/win32/win_main.cpp
+index d29bc54..e063593 100644
+--- a/code/win32/win_main.cpp
++++ b/code/win32/win_main.cpp
+@@ -1037,6 +1037,14 @@ static int ParseCommandLine(char *cmdline, char **argv)
+ //=======================================================================
+ //int totalMsec, countMsec;
+ 
++void Sys_Sleep( int msec )
++{
++      if( msec <= 0 )
++              return;
++
++      Sleep( msec );
++}
++
+ #ifndef DEFAULT_BASEDIR
+ #     define DEFAULT_BASEDIR Sys_BinaryPath()
+ #endif
+diff --git a/codemp/null/null_net.c b/codemp/null/null_net.c
+index c8abf18..37a012a 100644
+--- a/codemp/null/null_net.c
++++ b/codemp/null/null_net.c
+@@ -30,14 +30,3 @@ Sys_SendPacket
+ */
+ void Sys_SendPacket( int length, void *data, netadr_t to ) {
+ }
+-
+-/*
+-==================
+-Sys_GetPacket
+-
+-Never called by the game logic, just the system event queing
+-==================
+-*/
+-qboolean      Sys_GetPacket ( netadr_t *net_from, msg_t *net_message ) {
+-      return false;
+-}
+diff --git a/codemp/qcommon/common.cpp b/codemp/qcommon/common.cpp
+index 55e15f9..f972d6b 100644
+--- a/codemp/qcommon/common.cpp
++++ b/codemp/qcommon/common.cpp
+@@ -18,7 +18,6 @@ cvar_t       *com_developer;
+ cvar_t        *com_dedicated;
+ cvar_t        *com_timescale;
+ cvar_t        *com_fixedtime;
+-cvar_t        *com_dropsim;           // 0.0 to 1.0, simulated packet drops
+ cvar_t        *com_journal;
+ cvar_t        *com_maxfps;
+ cvar_t        *com_timedemo;
+@@ -44,6 +43,7 @@ cvar_t       *com_minimized;
+ cvar_t  *com_homepath;
+ 
+ cvar_t *com_affinity;
++cvar_t *com_busyWait;
+ 
+ // com_speeds times
+ int           time_game;
+@@ -51,7 +51,6 @@ int          time_frontend;          // renderer frontend 
time
+ int           time_backend;           // renderer backend time
+ 
+ int                   com_frameTime;
+-int                   com_frameMsec;
+ int                   com_frameNumber;
+ 
+ qboolean      com_errorEntered = qfalse;
+@@ -897,36 +896,6 @@ int Com_EventLoop( void ) {
+                       }
+                       Cbuf_AddText( "\n" );
+                       break;
+-              case SE_PACKET:
+-                      // this cvar allows simulation of connections that
+-                      // drop a lot of packets.  Note that loopback 
connections
+-                      // don't go through here at all.
+-                      if ( com_dropsim->value > 0 ) {
+-                              static int seed;
+-
+-                              if ( Q_random( &seed ) < com_dropsim->value ) {
+-                                      break;          // drop this packet
+-                              }
+-                      }
+-
+-                      evFrom = *(netadr_t *)ev.evPtr;
+-                      buf.cursize = ev.evPtrLength - sizeof( evFrom );
+-
+-                      // we must copy the contents of the message out, because
+-                      // the event buffers are only large enough to hold the
+-                      // exact payload, but channel messages need to be large
+-                      // enough to hold fragment reassembly
+-                      if ( (unsigned)buf.cursize > (unsigned)buf.maxsize ) {
+-                              Com_Printf("Com_EventLoop: oversize packet\n");
+-                              continue;
+-                      }
+-                      Com_Memcpy( buf.data, (byte *)((netadr_t *)ev.evPtr + 
1), buf.cursize );
+-                      if ( com_sv_running->integer ) {
+-                              Com_RunAndTimeServerPacket( &evFrom, &buf );
+-                      } else {
+-                              CL_PacketEvent( evFrom, &buf );
+-                      }
+-                      break;
+               }
+ 
+               // free any block data
+@@ -1222,7 +1191,6 @@ void Com_Init( char *commandLine ) {
+               com_fixedtime = Cvar_Get ("fixedtime", "0", CVAR_CHEAT);
+               com_showtrace = Cvar_Get ("com_showtrace", "0", CVAR_CHEAT);
+ 
+-              com_dropsim = Cvar_Get ("com_dropsim", "0", CVAR_CHEAT);
+               com_viewlog = Cvar_Get( "viewlog", "0", 0 );
+               com_speeds = Cvar_Get ("com_speeds", "0", 0);
+               com_timedemo = Cvar_Get ("timedemo", "0", 0);
+@@ -1244,6 +1212,7 @@ void Com_Init( char *commandLine ) {
+ #endif
+ 
+               com_affinity = Cvar_Get( "com_affinity", "1", CVAR_ARCHIVE );
++              com_busyWait = Cvar_Get( "com_busyWait", "0", CVAR_ARCHIVE );
+ 
+               com_bootlogo = Cvar_Get( "com_bootlogo", "1", CVAR_ARCHIVE);
+ 
+@@ -1442,6 +1411,26 @@ extern int G2Time_PreciseFrame;
+ 
+ /*
+ =================
++Com_TimeVal
++=================
++*/
++
++int Com_TimeVal(int minMsec)
++{
++      int timeVal;
++
++      timeVal = Sys_Milliseconds() - com_frameTime;
++
++      if(timeVal >= minMsec)
++              timeVal = 0;
++      else
++              timeVal = minMsec - timeVal;
++
++      return timeVal;
++}
++
++/*
++=================
+ Com_Frame
+ =================
+ */
+@@ -1453,7 +1442,8 @@ void Com_Frame( void ) {
+               G2PerformanceTimer_PreciseFrame.Start();
+ #endif
+               int             msec, minMsec;
+-              static int      lastTime = 0;
++              int             timeVal;
++              static int      lastTime = 0, bias = 0;
+ 
+               int             timeBeforeFirstEvents;
+               int           timeBeforeServer;
+@@ -1488,25 +1478,57 @@ void Com_Frame( void ) {
+                       timeBeforeFirstEvents = Sys_Milliseconds ();
+               }
+ 
+-              // we may want to spin here if things are going too fast
+-              if ( !com_dedicated->integer && com_maxfps->integer > 0 && 
!com_timedemo->integer ) {
+-                      minMsec = 1000 / com_maxfps->integer;
+-              } else {
+-                      minMsec = 1;
++              // Figure out how much time we have
++              if(!com_timedemo->integer)
++              {
++                      if(com_dedicated->integer)
++                              minMsec = SV_FrameMsec();
++                      else
++                      {
++#if 0
++                              // FIXME: enable this ioquake3 feature one day
++                              if(com_minimized->integer && 
com_maxfpsMinimized->integer > 0)
++                                      minMsec = 1000 / 
com_maxfpsMinimized->integer;
++                              else if(com_unfocused->integer && 
com_maxfpsUnfocused->integer > 0)
++                                      minMsec = 1000 / 
com_maxfpsUnfocused->integer;
++                              else
++#endif
++                              if(com_maxfps->integer > 0)
++                                      minMsec = 1000 / com_maxfps->integer;
++                              else
++                                      minMsec = 1;
++
++                              timeVal = com_frameTime - lastTime;
++                              bias += timeVal - minMsec;
++
++                              if (bias > minMsec)
++                                      bias = minMsec;
++
++                              // Adjust minMsec if previous frame took too 
long to render so
++                              // that framerate is stable at the requested 
value.
++                              minMsec -= bias;
++                      }
+               }
++              else
++                      minMsec = 1;
++
++              timeVal = Com_TimeVal(minMsec);
+               do {
+-                      com_frameTime = Com_EventLoop();
+-                      if ( lastTime > com_frameTime ) {
+-                              lastTime = com_frameTime;               // 
possible on first frame
+-                      }
+-                      msec = com_frameTime - lastTime;
+-              } while ( msec < minMsec );
+-              Cbuf_Execute ();
++                      // Busy sleep the last millisecond for better timeout 
precision
++                      if(com_busyWait->integer || timeVal < 1)
++                              NET_Sleep(0);
++                      else
++                              NET_Sleep(timeVal - 1);
++              } while( (timeVal = Com_TimeVal(minMsec)) != 0 );
+ 
+               lastTime = com_frameTime;
++              com_frameTime = Com_EventLoop();
++
++              msec = com_frameTime - lastTime;
++
++              Cbuf_Execute ();
+ 
+               // mess with msec if needed
+-              com_frameMsec = msec;
+               msec = Com_ModifyMsec( msec );
+ 
+               //
+diff --git a/codemp/qcommon/net_ip.cpp b/codemp/qcommon/net_ip.cpp
+index 77b68a5..d405cda 100644
+--- a/codemp/qcommon/net_ip.cpp
++++ b/codemp/qcommon/net_ip.cpp
+@@ -71,6 +71,8 @@ static cvar_t        *net_socksPassword;
+ static cvar_t *net_ip;
+ static cvar_t *net_port;
+ 
++static cvar_t *net_dropsim;
++
+ static struct sockaddr        socksRelayAddr;
+ 
+ static SOCKET ip_socket = INVALID_SOCKET;
+@@ -213,21 +215,21 @@ qboolean Sys_StringToAdr( const char *s, netadr_t *a ) {
+ 
+ /*
+ ==================
+-Sys_GetPacket
++NET_GetPacket
+ 
+-Never called by the game logic, just the system event queing
++Receive one packet
+ ==================
+ */
+ #ifdef _DEBUG
+ int   recvfromCount;
+ #endif
+ 
+-qboolean Sys_GetPacket( netadr_t *net_from, msg_t *net_message ) {
++qboolean NET_GetPacket( netadr_t *net_from, msg_t *net_message, fd_set *fdr ) 
{
+       int ret, err;
+       socklen_t fromlen;
+       struct sockaddr from;
+ 
+-      if ( ip_socket == INVALID_SOCKET ) {
++      if ( ip_socket == INVALID_SOCKET || !FD_ISSET(ip_socket, fdr) ) {
+               return qfalse;
+       }
+ 
+@@ -878,6 +880,8 @@ static qboolean NET_GetCvars( void ) {
+       modified += net_socksPassword->modified;
+       net_socksPassword->modified = qfalse;
+ 
++      net_dropsim = Cvar_Get( "net_dropsim", "", CVAR_TEMP);
++
+       return modified ? qtrue : qfalse;
+ }
+ 
+@@ -982,31 +986,91 @@ void NET_Shutdown( void ) {
+ 
+ /*
+ ====================
++NET_Event
++
++Called from NET_Sleep which uses select() to determine which sockets have 
seen action.
++====================
++*/
++
++void NET_Event(fd_set *fdr)
++{
++      byte bufData[MAX_MSGLEN + 1];
++      netadr_t from;
++      msg_t netmsg;
++
++      while(1)
++      {
++              MSG_Init(&netmsg, bufData, sizeof(bufData));
++
++              if(NET_GetPacket(&from, &netmsg, fdr))
++              {
++                      if(net_dropsim->value > 0.0f && net_dropsim->value <= 
100.0f)
++                      {
++                              // com_dropsim->value percent of incoming 
packets get dropped.
++                              if(rand() < (int) (((double) RAND_MAX) / 100.0 
* (double) net_dropsim->value))
++                                      continue;          // drop this packet
++                      }
++
++                      if(com_sv_running->integer)
++                              Com_RunAndTimeServerPacket(&from, &netmsg);
++                      else
++                              CL_PacketEvent(from, &netmsg);
++              }
++              else
++                      break;
++      }
++}
++
++/*
++====================
+ NET_Sleep
+ 
+ sleeps msec or until net socket is ready
+ ====================
+ */
+ void NET_Sleep( int msec ) {
+-#ifndef _WIN32
+       struct timeval timeout;
+       fd_set  fdset;
++      int retval;
++      SOCKET highestfd = INVALID_SOCKET;
++#ifndef _WIN32
+       extern qboolean stdin_active;
++#endif
+ 
+-      if ( !com_dedicated->integer )
+-              return; // we're not a server, just run full speed
+-
+-      if ( ip_socket == INVALID_SOCKET )
+-              return;
++      if (msec < 0)
++              msec = 0;
+ 
+       FD_ZERO(&fdset);
+-      if (stdin_active)
++#ifndef _WIN32
++      if (stdin_active) {
+               FD_SET(0, &fdset); // stdin is processed too
+-      FD_SET(ip_socket, &fdset); // network socket
++              highestfd = 0;
++      }
++#endif
++      if (ip_socket != INVALID_SOCKET) {
++              FD_SET(ip_socket, &fdset); // network socket
++              highestfd = ip_socket;
++      }
++
++#ifdef _WIN32
++      if(highestfd == INVALID_SOCKET)
++      {
++              // windows ain't happy when select is called without valid FDs
++
++              SleepEx(msec, 0);
++              return;
++      }
++#endif
++
+       timeout.tv_sec = msec/1000;
+       timeout.tv_usec = (msec%1000)*1000;
+-      select(ip_socket+1, &fdset, NULL, NULL, &timeout);
+-#endif
++
++      retval = select(highestfd + 1, &fdset, NULL, NULL, &timeout);
++
++      if(retval == SOCKET_ERROR)
++              Com_Printf("Warning: select() syscall failed: %s\n", 
NET_ErrorString());
++      else if(retval > 0)
++              NET_Event(&fdset);
+ }
+ 
+ /*
+diff --git a/codemp/qcommon/qcommon.h b/codemp/qcommon/qcommon.h
+index 70522de..6cf7fcf 100644
+--- a/codemp/qcommon/qcommon.h
++++ b/codemp/qcommon/qcommon.h
+@@ -733,6 +733,7 @@ int                        Com_Filter(char *filter, char 
*name, int casesensitive);
+ int                   Com_FilterPath(char *filter, char *name, int 
casesensitive);
+ int                   Com_RealTime(qtime_t *qtime);
+ qboolean      Com_SafeMode( void );
++void          Com_RunAndTimeServerPacket(netadr_t *evFrom, msg_t *buf);
+ 
+ void          Com_StartupVariable( const char *match );
+ // checks for and removes command line "+set var arg" constructs
+@@ -773,7 +774,6 @@ extern     int             time_frontend;
+ extern        int             time_backend;           // renderer backend time
+ 
+ extern        int             com_frameTime;
+-extern        int             com_frameMsec;
+ 
+ extern        qboolean        com_errorEntered;
+ 
+@@ -953,6 +953,7 @@ void SV_Init( void );
+ void SV_Shutdown( char *finalmsg );
+ void SV_Frame( int msec );
+ void SV_PacketEvent( netadr_t from, msg_t *msg );
++int SV_FrameMsec( void );
+ qboolean SV_GameCommand( void );
+ 
+ 
+@@ -986,8 +987,7 @@ typedef enum {
+       SE_CHAR,        // evValue is an ascii char
+       SE_MOUSE,       // evValue and evValue2 are reletive signed x / y moves
+       SE_JOYSTICK_AXIS,       // evValue is an axis number and evValue2 is 
the current state (-127 to 127)
+-      SE_CONSOLE,     // evPtr is a char*
+-      SE_PACKET       // evPtr is a netadr_t followed by data bytes to 
evPtrLength
++      SE_CONSOLE      // evPtr is a char*
+ } sysEventType_t;
+ 
+ typedef struct sysEvent_s {
+diff --git a/codemp/server/sv_main.cpp b/codemp/server/sv_main.cpp
+index 1e77dd1..c87f8a3 100644
+--- a/codemp/server/sv_main.cpp
++++ b/codemp/server/sv_main.cpp
+@@ -8,7 +8,7 @@ server_t               sv;                                     
// local server
+ 
+ cvar_t        *sv_snapsMin;                   // minimum snapshots/sec a 
client can request, also limited by sv_snapsMax
+ cvar_t        *sv_snapsMax;                   // maximum snapshots/sec a 
client can request, also limited by sv_fps
+-cvar_t        *sv_fps;                                // time rate for 
running non-clients
++cvar_t        *sv_fps = NULL;                 // time rate for running 
non-clients
+ cvar_t        *sv_timeout;                    // seconds without any message
+ cvar_t        *sv_zombietime;                 // seconds to sink messages 
after disconnect
+ cvar_t        *sv_rconPassword;               // password for remote server 
commands
+@@ -995,6 +995,29 @@ void SV_CheckCvars( void ) {
+ 
+ /*
+ ==================
++SV_FrameMsec
++Return time in millseconds until processing of the next server frame.
++==================
++*/
++int SV_FrameMsec()
++{
++      if(sv_fps)
++      {
++              int frameMsec;
++
++              frameMsec = 1000.0f / sv_fps->value;
++
++              if(frameMsec < sv.timeResidual)
++                      return 0;
++              else
++                      return frameMsec - sv.timeResidual;
++      }
++      else
++              return 1;
++}
++
++/*
++==================
+ SV_Frame
+ 
+ Player movement occurs as a result of packet events, which
+@@ -1037,13 +1060,6 @@ void SV_Frame( int msec ) {
+ 
+       if (!com_dedicated->integer) SV_BotFrame( sv.time + sv.timeResidual );
+ 
+-      if ( com_dedicated->integer && sv.timeResidual < frameMsec && 
(!com_timescale || com_timescale->value >= 1) ) {
+-              // NET_Sleep will give the OS time slices until either get a 
packet
+-              // or time enough for a server frame has gone by
+-              NET_Sleep(frameMsec - sv.timeResidual);
+-              return;
+-      }
+-
+       // if time is about to hit the 32nd bit, kick all clients
+       // and clear sv.time, rather
+       // than checking for negative time wraparound everywhere.
+diff --git a/codemp/sys/sys_unix.cpp b/codemp/sys/sys_unix.cpp
+index b20f2eb..df278c3 100644
+--- a/codemp/sys/sys_unix.cpp
++++ b/codemp/sys/sys_unix.cpp
+@@ -187,13 +187,10 @@ EVENT LOOP
+ 
+ sysEvent_t    eventQue[MAX_QUED_EVENTS];
+ int                   eventHead, eventTail;
+-byte          sys_packetReceived[MAX_MSGLEN];
+ 
+ sysEvent_t Sys_GetEvent( void ) {
+       sysEvent_t      ev;
+       char            *s;
+-      msg_t           netmsg;
+-      netadr_t        adr;
+ 
+       // return if we have data
+       if ( eventHead > eventTail ) {
+@@ -213,20 +210,6 @@ sysEvent_t Sys_GetEvent( void ) {
+               Sys_QueEvent( 0, SE_CONSOLE, 0, 0, len, b );
+       }
+ 
+-      // check for network packets
+-      MSG_Init( &netmsg, sys_packetReceived, sizeof( sys_packetReceived ) );
+-      if ( Sys_GetPacket ( &adr, &netmsg ) ) {
+-              netadr_t                *buf;
+-              int                             len;
+-
+-              // copy out to a seperate buffer for qeueing
+-              len = sizeof( netadr_t ) + netmsg.cursize;
+-              buf = (netadr_t *)Z_Malloc( len,TAG_EVENT,qfalse );
+-              *buf = adr;
+-              memcpy( buf+1, netmsg.data, netmsg.cursize );
+-              Sys_QueEvent( 0, SE_PACKET, 0, 0, len, buf );
+-      }
+-
+       // return if we have data
+       if ( eventHead > eventTail ) {
+               eventTail++;
+diff --git a/codemp/win32/win_main.cpp b/codemp/win32/win_main.cpp
+index caef083..7c64108 100644
+--- a/codemp/win32/win_main.cpp
++++ b/codemp/win32/win_main.cpp
+@@ -641,7 +641,6 @@ EVENT LOOP
+ 
+ sysEvent_t    eventQue[MAX_QUED_EVENTS];
+ int                   eventHead, eventTail;
+-byte          sys_packetReceived[MAX_MSGLEN];
+ 
+ /*
+ ================
+@@ -689,8 +688,6 @@ sysEvent_t Sys_GetEvent( void ) {
+     MSG                       msg;
+       sysEvent_t      ev;
+       char            *s;
+-      msg_t           netmsg;
+-      netadr_t        adr;
+ 
+       // return if we have data
+       if ( eventHead > eventTail ) {
+@@ -723,21 +720,6 @@ sysEvent_t Sys_GetEvent( void ) {
+               Sys_QueEvent( 0, SE_CONSOLE, 0, 0, len, b );
+       }
+ 
+-      // check for network packets
+-      MSG_Init( &netmsg, sys_packetReceived, sizeof( sys_packetReceived ) );
+-      if ( Sys_GetPacket ( &adr, &netmsg ) ) {
+-              netadr_t                *buf;
+-              int                             len;
+-
+-              // copy out to a seperate buffer for qeueing
+-              // the readcount stepahead is for SOCKS support
+-              len = sizeof( netadr_t ) + netmsg.cursize - netmsg.readcount;
+-              buf = (netadr_t *)Z_Malloc( len, TAG_EVENT, qtrue );
+-              *buf = adr;
+-              memcpy( buf+1, &netmsg.data[netmsg.readcount], netmsg.cursize - 
netmsg.readcount );
+-              Sys_QueEvent( 0, SE_PACKET, 0, 0, len, buf );
+-      }
+-
+       // return if we have data
+       if ( eventHead > eventTail ) {
+               eventTail++;
+diff --git a/codemp/win32/win_main_ded.cpp b/codemp/win32/win_main_ded.cpp
+index 6304446..bc88d2d 100644
+--- a/codemp/win32/win_main_ded.cpp
++++ b/codemp/win32/win_main_ded.cpp
+@@ -782,7 +782,6 @@ EVENT LOOP
+ sysEvent_t    eventQue[MAX_QUED_EVENTS];
+ static int    eventHead=0;
+ static int    eventTail=0;
+-byte          sys_packetReceived[MAX_MSGLEN];
+ 
+ /*
+ ================
+@@ -864,21 +863,6 @@ sysEvent_t Sys_GetEvent( void ) {
+               Sys_QueEvent( 0, SE_CONSOLE, 0, 0, len, b );
+       }
+ 
+-      // check for network packets
+-      MSG_Init( &netmsg, sys_packetReceived, sizeof( sys_packetReceived ) );
+-      if ( Sys_GetPacket ( &adr, &netmsg ) ) {
+-              netadr_t                *buf;
+-              int                             len;
+-
+-              // copy out to a seperate buffer for qeueing
+-              // the readcount stepahead is for SOCKS support
+-              len = sizeof( netadr_t ) + netmsg.cursize - netmsg.readcount;
+-              buf = (netadr_t *)Z_Malloc( len, TAG_EVENT, qtrue );
+-              *buf = adr;
+-              memcpy( buf+1, &netmsg.data[netmsg.readcount], netmsg.cursize - 
netmsg.readcount );
+-              Sys_QueEvent( 0, SE_PACKET, 0, 0, len, buf );
+-      }
+-
+       // return if we have data
+       if ( eventHead > eventTail ) {
+               eventTail++;
diff --git a/debian/patches/series b/debian/patches/series
index e811ac2..06bc0dc 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -4,3 +4,4 @@ g_utils-stub-out-debug-code-to-write-to-a-misc-Windo.patch
 Allow-using-an-external-libjpeg-turbo-or-libjpeg8.patch
 Use-system-zlib-headers-if-we-re-using-system-zlib.patch
 Don-t-link-renderer-and-clients-to-a-bunch-of-unnece.patch
+Use-NET_Sleep-or-Sys_Sleep-for-SP-to-avoid-busy-wait.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-games/openjk.git

_______________________________________________
Pkg-games-commits mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

Reply via email to