q3map2: * buffered broadcast xml stream to dramatically increase compilation monitoring speed

This commit is contained in:
Garux 2018-03-13 22:51:30 +03:00
parent a02c1312c4
commit 5bf0dd5243
5 changed files with 64 additions and 31 deletions

View File

@ -537,7 +537,7 @@ void CWatchBSP::DoEBeginStep(){
} }
} }
m_eState = EBeginStep; m_eState = EBeginStep;
s_routine_id = gtk_timeout_add( 25, watchbsp_routine, this ); s_routine_id = gtk_timeout_add( 8, watchbsp_routine, this );
} }

View File

@ -45,12 +45,6 @@
// utf8 conversion // utf8 conversion
#include <glib.h> #include <glib.h>
#ifdef WIN32
HWND hwndOut = NULL;
qboolean lookedForServer = qfalse;
UINT wm_BroadcastCommand = -1;
#endif
socket_t *brdcst_socket; socket_t *brdcst_socket;
netmessage_t msg; netmessage_t msg;
@ -95,10 +89,12 @@ void xml_SendNode( xmlNodePtr node ){
while ( pos < (int)xml_buf->use ) while ( pos < (int)xml_buf->use )
{ {
// what size are we gonna send now? // what size are we gonna send now?
( xml_buf->use - pos < MAX_NETMESSAGE - 10 ) ? ( size = xml_buf->use - pos ) : ( size = MAX_NETMESSAGE - 10 ); if( xml_buf->use - pos < MAX_NETMESSAGE - 10 ){
//++timo just a debug thing size = xml_buf->use - pos;
if ( size == MAX_NETMESSAGE - 10 ) { }
Sys_FPrintf( SYS_NOXML, "Got to split the buffer\n" ); else{
size = MAX_NETMESSAGE - 10;
Sys_FPrintf( SYS_NOXML, "Got to split the buffer\n" ); //++timo just a debug thing
} }
memcpy( xmlbuf, xml_buf->content + pos, size ); memcpy( xmlbuf, xml_buf->content + pos, size );
xmlbuf[size] = '\0'; xmlbuf[size] = '\0';
@ -252,16 +248,63 @@ void Broadcast_Setup( const char *dest ){
void Broadcast_Shutdown(){ void Broadcast_Shutdown(){
if ( brdcst_socket ) { if ( brdcst_socket ) {
Sys_Printf( "Disconnecting\n" ); Sys_Printf( "Disconnecting\n" );
xml_message_flush();
Net_Disconnect( brdcst_socket ); Net_Disconnect( brdcst_socket );
brdcst_socket = NULL; brdcst_socket = NULL;
} }
} }
#define MAX_MESEGE MAX_NETMESSAGE / 2
char mesege[MAX_MESEGE];
size_t mesege_len = 0;
int mesege_flag = SYS_STD;
void xml_message_flush(){
if( mesege_len == 0 )
return;
xmlNodePtr node;
node = xmlNewNode( NULL, (xmlChar*)"message" );
{
mesege[mesege_len] = '\0';
mesege_len = 0;
gchar* utf8 = g_locale_to_utf8( mesege, -1, NULL, NULL, NULL );
xmlNodeAddContent( node, (xmlChar*)utf8 );
g_free( utf8 );
}
char level[2];
level[0] = (int)'0' + mesege_flag;
level[1] = 0;
xmlSetProp( node, (xmlChar*)"level", (xmlChar *)&level );
xml_SendNode( node );
}
void xml_message_push( int flag, const char* characters, size_t length ){
if( flag != mesege_flag ){
xml_message_flush();
mesege_flag = flag;
}
const char* end = characters + length;
while ( characters != end )
{
size_t space = MAX_MESEGE - 1 - mesege_len;
if ( space == 0 ) {
xml_message_flush();
}
else
{
size_t size = ( space < ( size_t )( end - characters ) ) ? space : ( size_t )( end - characters );
memcpy( mesege + mesege_len, characters, size );
mesege_len += size;
characters += size;
}
}
}
// all output ends up through here // all output ends up through here
void FPrintf( int flag, char *buf ){ void FPrintf( int flag, char *buf ){
xmlNodePtr node;
static qboolean bGotXML = qfalse; static qboolean bGotXML = qfalse;
char level[2];
printf( "%s", buf ); printf( "%s", buf );
@ -284,17 +327,7 @@ void FPrintf( int flag, char *buf ){
doc->children = xmlNewDocRawNode( doc, NULL, (xmlChar*)"q3map_feedback", NULL ); doc->children = xmlNewDocRawNode( doc, NULL, (xmlChar*)"q3map_feedback", NULL );
bGotXML = qtrue; bGotXML = qtrue;
} }
node = xmlNewNode( NULL, (xmlChar*)"message" ); xml_message_push( flag, buf, strlen( buf ) );
{
gchar* utf8 = g_locale_to_utf8( buf, -1, NULL, NULL, NULL );
xmlNodeAddContent( node, (xmlChar*)utf8 );
g_free( utf8 );
}
level[0] = (int)'0' + flag;
level[1] = 0;
xmlSetProp( node, (xmlChar*)"level", (xmlChar *)&level );
xml_SendNode( node );
} }
#ifdef DBG_XML #ifdef DBG_XML
@ -341,13 +374,14 @@ void Error( const char *error, ... ){
char tmp[4096]; char tmp[4096];
va_list argptr; va_list argptr;
va_start( argptr,error ); va_start( argptr, error );
vsprintf( tmp, error, argptr ); vsprintf( tmp, error, argptr );
va_end( argptr ); va_end( argptr );
sprintf( out_buffer, "************ ERROR ************\n%s\n", tmp ); sprintf( out_buffer, "************ ERROR ************\n%s\n", tmp );
FPrintf( SYS_ERR, out_buffer ); FPrintf( SYS_ERR, out_buffer );
xml_message_flush();
#ifdef DBG_XML #ifdef DBG_XML
DumpXML(); DumpXML();
@ -357,7 +391,5 @@ void Error( const char *error, ... ){
// a clean solution is to send a sync request node in the stream and wait for an answer before exiting // a clean solution is to send a sync request node in the stream and wait for an answer before exiting
Sys_Sleep( 1000 ); Sys_Sleep( 1000 );
Broadcast_Shutdown();
exit( 1 ); exit( 1 );
} }

View File

@ -29,6 +29,7 @@
// some useful xml routines // some useful xml routines
xmlNodePtr xml_NodeForVec( vec3_t v ); xmlNodePtr xml_NodeForVec( vec3_t v );
void xml_SendNode( xmlNodePtr node ); void xml_SendNode( xmlNodePtr node );
void xml_message_flush();
// print a message in q3map output and send the corresponding select information down the xml stream // print a message in q3map output and send the corresponding select information down the xml stream
// bError: do we end with an error on this one or do we go ahead? // bError: do we end with an error on this one or do we go ahead?
void xml_Select( char *msg, int entitynum, int brushnum, qboolean bError ); void xml_Select( char *msg, int entitynum, int brushnum, qboolean bError );

View File

@ -348,6 +348,7 @@ void ProcessWorldModel( void ){
Sys_FPrintf( SYS_NOXML, "******* leaked *******\n" ); Sys_FPrintf( SYS_NOXML, "******* leaked *******\n" );
Sys_FPrintf( SYS_NOXML, "**********************\n" ); Sys_FPrintf( SYS_NOXML, "**********************\n" );
polyline = LeakFile( tree ); polyline = LeakFile( tree );
xml_message_flush();
leaknode = xmlNewNode( NULL, (xmlChar*)"message" ); leaknode = xmlNewNode( NULL, (xmlChar*)"message" );
xmlNodeAddContent( leaknode, (xmlChar*)"MAP LEAKED\n" ); xmlNodeAddContent( leaknode, (xmlChar*)"MAP LEAKED\n" );
xmlAddChild( leaknode, polyline ); xmlAddChild( leaknode, polyline );
@ -356,7 +357,7 @@ void ProcessWorldModel( void ){
xmlSetProp( leaknode, (xmlChar*)"level", (xmlChar*) &level ); xmlSetProp( leaknode, (xmlChar*)"level", (xmlChar*) &level );
xml_SendNode( leaknode ); xml_SendNode( leaknode );
if ( leaktest ) { if ( leaktest ) {
Sys_Printf( "--- MAP LEAKED, ABORTING LEAKTEST ---\n" ); Sys_FPrintf( SYS_WRN, "--- MAP LEAKED, ABORTING LEAKTEST ---\n" );
exit( 0 ); exit( 0 );
} }
} }

View File

@ -87,6 +87,8 @@ char *Q_strncat( char *dst, size_t dlen, const char *src, size_t slen ) {
*/ */
static void ExitQ3Map( void ){ static void ExitQ3Map( void ){
/* flush xml send buffer, shut down connection */
Broadcast_Shutdown();
BSPFilesCleanup(); BSPFilesCleanup();
if ( mapDrawSurfs != NULL ) { if ( mapDrawSurfs != NULL ) {
free( mapDrawSurfs ); free( mapDrawSurfs );
@ -3904,9 +3906,6 @@ int main( int argc, char **argv ){
end = I_FloatTime(); end = I_FloatTime();
Sys_Printf( "%9.0f seconds elapsed\n", end - start ); Sys_Printf( "%9.0f seconds elapsed\n", end - start );
/* shut down connection */
Broadcast_Shutdown();
/* return any error code */ /* return any error code */
return r; return r;
} }