diff --git a/vmpi/ichannel.h b/vmpi/ichannel.h deleted file mode 100644 index 1fa6c350..00000000 --- a/vmpi/ichannel.h +++ /dev/null @@ -1,49 +0,0 @@ -//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -//=============================================================================// - -#ifndef ICHANNEL_H -#define ICHANNEL_H -#ifdef _WIN32 -#pragma once -#endif - - -#include "tier1/utlvector.h" - - -class IChannel -{ -public: - // Note: this also releases any channels contained inside. So if you make a reliable - // channel that contains an unreliable channel and release the reliable one, - // it will automatically release the unreliable one it contains. - virtual void Release() = 0; - - // Send data to the destination. - virtual bool Send( const void *pData, int len ) = 0; - - // This version puts all the chunks into one packet and ships it off. - virtual bool SendChunks( void const * const *pChunks, const int *pChunkLengths, int nChunks ) = 0; - - // Check for any packets coming in from the destination. - // Returns false if no packet was received. - // - // flTimeout can be used to make it wait for data. - // - // Note: this is most efficient if you keep the buffer around between calls so it only - // reallocates it when it needs more space. - virtual bool Recv( CUtlVector &data, double flTimeout=0 ) = 0; - - // Returns false if the connection has been broken. - virtual bool IsConnected() = 0; - - // If IsConnected returns false, you can call this to find out why the socket got disconnected. - virtual void GetDisconnectReason( CUtlVector &reason ) = 0; -}; - - -#endif // ICHANNEL_H diff --git a/vmpi/imysqlwrapper.h b/vmpi/imysqlwrapper.h deleted file mode 100644 index 8dae91e5..00000000 --- a/vmpi/imysqlwrapper.h +++ /dev/null @@ -1,115 +0,0 @@ -//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -//=============================================================================// - -#ifndef MYSQL_WRAPPER_H -#define MYSQL_WRAPPER_H -#ifdef _WIN32 -#pragma once -#endif - - -#include "utlvector.h" -#include "interface.h" - - -class IMySQLRowSet; - - -class CColumnValue -{ -public: - - CColumnValue( IMySQLRowSet *pSQL, int iColumn ); - - const char* String(); - long Int32(); - -private: - IMySQLRowSet *m_pSQL; - int m_iColumn; -}; - - - -class IMySQLRowSet -{ -public: - virtual void Release() = 0; - - // Get the number of columns in the data returned from the last query (if it was a select statement). - virtual int NumFields() = 0; - - // Get the name of each column returned by the last query. - virtual const char* GetFieldName( int iColumn ) = 0; - - // Call this in a loop until it returns false to iterate over all rows the query returned. - virtual bool NextRow() = 0; - - // You can call this to start iterating over the result set from the start again. - // Note: after calling this, you have to call NextRow() to actually get the first row's value ready. - virtual bool SeekToFirstRow() = 0; - - virtual CColumnValue GetColumnValue( int iColumn ) = 0; - virtual CColumnValue GetColumnValue( const char *pColumnName ) = 0; - - virtual const char* GetColumnValue_String( int iColumn ) = 0; - virtual long GetColumnValue_Int( int iColumn ) = 0; - - // You can call this to get the index of a column for faster lookups with GetColumnValue( int ). - // Returns -1 if the column can't be found. - virtual int GetColumnIndex( const char *pColumnName ) = 0; -}; - - -class IMySQL : public IMySQLRowSet -{ -public: - virtual bool InitMySQL( const char *pDBName, const char *pHostName="", const char *pUserName="", const char *pPassword="" ) = 0; - virtual void Release() = 0; - - // These execute SQL commands. They return 0 if the query was successful. - virtual int Execute( const char *pString ) = 0; - - // This reads in all of the data in the last row set you queried with Execute and builds a separate - // copy. This is useful in some of the VMPI tools to have a thread repeatedly execute a slow query, then - // store off the results for the main thread to parse. - virtual IMySQLRowSet* DuplicateRowSet() = 0; - - // If you just inserted rows into a table with an AUTO_INCREMENT column, - // then this returns the (unique) value of that column. - virtual unsigned long InsertID() = 0; - - // Returns the last error message, if an error took place - virtual const char * GetLastError() = 0; -}; - - -#define MYSQL_WRAPPER_VERSION_NAME "MySQLWrapper001" - - -// ------------------------------------------------------------------------------------------------ // -// Inlines. -// ------------------------------------------------------------------------------------------------ // - -inline CColumnValue::CColumnValue( IMySQLRowSet *pSQL, int iColumn ) -{ - m_pSQL = pSQL; - m_iColumn = iColumn; -} - -inline const char* CColumnValue::String() -{ - return m_pSQL->GetColumnValue_String( m_iColumn ); -} - -inline long CColumnValue::Int32() -{ - return m_pSQL->GetColumnValue_Int( m_iColumn ); -} - - -#endif // MYSQL_WRAPPER_H diff --git a/vmpi/iphelpers.h b/vmpi/iphelpers.h deleted file mode 100644 index 3d5de02b..00000000 --- a/vmpi/iphelpers.h +++ /dev/null @@ -1,162 +0,0 @@ -//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// - -#ifndef IPHELPERS_H -#define IPHELPERS_H - - -#include "ichannel.h" - - -// Loops that poll sockets should Sleep for this amount of time between iterations -// so they don't hog all the CPU. -#define LOOP_POLL_INTERVAL 5 - - -// Useful for putting the arguments into a printf statement. -#define EXPAND_ADDR( x ) (x).ip[0], (x).ip[1], (x).ip[2], (x).ip[3], (x).port - - -// This is a simple wrapper layer for UDP sockets. -class CIPAddr -{ -public: - CIPAddr(); - CIPAddr( const int inputIP[4], const int inputPort ); - CIPAddr( int ip0, int ip1, int ip2, int ip3, int ipPort ); - - void Init( int ip0, int ip1, int ip2, int ip3, int ipPort ); - bool operator==( const CIPAddr &o ) const; - bool operator!=( const CIPAddr &o ) const; - - // Setup to send to the local machine on the specified port. - void SetupLocal( int inPort ); - -public: - - unsigned char ip[4]; - unsigned short port; -}; - - - -// The chunk walker provides an easy way to copy data out of the chunks as though it were a -// single contiguous chunk of memory.s -class CChunkWalker -{ -public: - CChunkWalker( void const * const *pChunks, const int *pChunkLengths, int nChunks ); - - int GetTotalLength() const; - void CopyTo( void *pOut, int nBytes ); - -private: - - void const * const *m_pChunks; - const int *m_pChunkLengths; - int m_nChunks; - - int m_iCurChunk; - int m_iCurChunkPos; - - int m_TotalLength; -}; - - -// This class makes loop that wait on something look nicer. ALL loops using this class -// should follow this pattern, or they can wind up with unforeseen delays that add a whole -// lot of lag. -// -// CWaitTimer waitTimer( 5.0 ); -// while ( 1 ) -// { -// do your thing here like Recv() from a socket. -// -// if ( waitTimer.ShouldKeepWaiting() ) -// Sleep() for some time interval like 5ms so you don't hog the CPU -// else -// BREAK HERE -// } -class CWaitTimer -{ -public: - CWaitTimer( double flSeconds ); - - bool ShouldKeepWaiting(); - -private: - unsigned long m_StartTime; - unsigned long m_WaitMS; -}; - - -// Helper function to get time in milliseconds. -unsigned long SampleMilliseconds(); - - -class ISocket -{ -public: - - // Call this when you're done. - virtual void Release() = 0; - - - // Bind the socket so you can send and receive with it. - // If you bind to port 0, then the system will select the port for you. - virtual bool Bind( const CIPAddr *pAddr ) = 0; - virtual bool BindToAny( const unsigned short port ) = 0; - - - // Broadcast some data. - virtual bool Broadcast( const void *pData, const int len, const unsigned short port ) = 0; - - // Send a packet. - virtual bool SendTo( const CIPAddr *pAddr, const void *pData, const int len ) = 0; - virtual bool SendChunksTo( const CIPAddr *pAddr, void const * const *pChunks, const int *pChunkLengths, int nChunks ) = 0; - - // Receive a packet. Returns the length received or -1 if no data came in. - // If pFrom is set, then it is filled in with the sender's IP address. - virtual int RecvFrom( void *pData, int maxDataLen, CIPAddr *pFrom ) = 0; - - // How long has it been since we successfully received a packet? - virtual double GetRecvTimeout() = 0; -}; - -// Create a connectionless socket that you can send packets out of. -ISocket* CreateIPSocket(); - -// This sets up the socket to receive multicast data on the specified group. -// By default, localInterface is INADDR_ANY, but if you want to specify a specific interface -// the data should come in through, you can. -ISocket* CreateMulticastListenSocket( - const CIPAddr &addr, - const CIPAddr &localInterface = CIPAddr() - ); - - -// Setup a CIPAddr from the string. The string can be a dotted IP address or -// a hostname, and it can be followed by a colon and a port number like "1.2.3.4:3443" -// or "myhostname.valvesoftware.com:2342". -// -// Note: if the string does not contain a port, then pOut->port will be left alone. -bool ConvertStringToIPAddr( const char *pStr, CIPAddr *pOut ); - -// Do a DNS lookup on the IP. -// You can optionally get a service name back too. -bool ConvertIPAddrToString( const CIPAddr *pIn, char *pOut, int outLen ); - - -void IP_GetLastErrorString( char *pStr, int maxLen ); - -void SockAddrToIPAddr( const struct sockaddr_in *pIn, CIPAddr *pOut ); -void IPAddrToSockAddr( const CIPAddr *pIn, struct sockaddr_in *pOut ); - - -#endif - diff --git a/vmpi/messbuf.h b/vmpi/messbuf.h deleted file mode 100644 index 0a27a07d..00000000 --- a/vmpi/messbuf.h +++ /dev/null @@ -1,52 +0,0 @@ -//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// -// MessageBuffer - handy for packing and upacking -// structures to be sent as messages -// -#ifndef _MESSAGEBUFFER -#define _MESSAGEBUFFER - -#include -#define DEFAULT_MESSAGE_BUFFER_SIZE 2048 - -class MessageBuffer { - public: - char * data; - - MessageBuffer(); - MessageBuffer(int size); - ~MessageBuffer(); - - int getSize(); - int getLen(); - int setLen(int len); - int getOffset(); - int setOffset(int offset); - - int write(void const * p, int bytes); - int update(int loc, void const * p, int bytes); - int extract(int loc, void * p, int bytes); - int read(void * p, int bytes); - - int WriteString( const char *pString ); - int ReadString( char *pOut, int bufferLength ); - - void clear(); - void clear(int minsize); - void reset(int minsize); - void print(FILE * ofile, int num); - - private: - void resize(int minsize); - int size; - int offset; - int len; -}; - -#endif diff --git a/vmpi/threadhelpers.h b/vmpi/threadhelpers.h deleted file mode 100644 index c6669a1c..00000000 --- a/vmpi/threadhelpers.h +++ /dev/null @@ -1,110 +0,0 @@ -//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -//=============================================================================// - -#ifndef THREADHELPERS_H -#define THREADHELPERS_H -#ifdef _WIN32 -#pragma once -#endif - - -#include "tier1/utllinkedlist.h" - - -#define SIZEOF_CS 24 // sizeof( CRITICAL_SECTION ) - - -class CCriticalSection -{ -public: - CCriticalSection(); - ~CCriticalSection(); - - -protected: - - friend class CCriticalSectionLock; - - void Lock(); - void Unlock(); - - -public: - char m_CS[SIZEOF_CS]; - - // Used to protect against deadlock in debug mode. -//#if defined( _DEBUG ) - CUtlLinkedList m_Locks; - char m_DeadlockProtect[SIZEOF_CS]; -//#endif -}; - - -// Use this to lock a critical section. -class CCriticalSectionLock -{ -public: - CCriticalSectionLock( CCriticalSection *pCS ); - ~CCriticalSectionLock(); - void Lock(); - void Unlock(); - -private: - CCriticalSection *m_pCS; - bool m_bLocked; -}; - - -template< class T > -class CCriticalSectionData : private CCriticalSection -{ -public: - // You only have access to the data between Lock() and Unlock(). - T* Lock() - { - CCriticalSection::Lock(); - return &m_Data; - } - - void Unlock() - { - CCriticalSection::Unlock(); - } - -private: - T m_Data; -}; - - - -// ------------------------------------------------------------------------------------------------ // -// CEvent. -// ------------------------------------------------------------------------------------------------ // -class CEvent -{ -public: - CEvent(); - ~CEvent(); - - bool Init( bool bManualReset, bool bInitialState ); - void Term(); - - void* GetEventHandle() const; - - // Signal the event. - bool SetEvent(); - - // Unset the event's signalled status. - bool ResetEvent(); - - -private: - void *m_hEvent; -}; - - -#endif // THREADHELPERS_H diff --git a/vmpi/vmpi.h b/vmpi/vmpi.h deleted file mode 100644 index 2951916c..00000000 --- a/vmpi/vmpi.h +++ /dev/null @@ -1,217 +0,0 @@ -//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -//=============================================================================// - -#ifndef VMPI_H -#define VMPI_H -#ifdef _WIN32 -#pragma once -#endif - - -#include "vmpi_defs.h" -#include "messbuf.h" -#include "iphelpers.h" - - -// These are called to handle incoming messages. -// Return true if you handled the message and false otherwise. -// Note: the first byte in each message is the packet ID. -typedef bool (*VMPIDispatchFn)( MessageBuffer *pBuf, int iSource, int iPacketID ); - -typedef void (*VMPI_Disconnect_Handler)( int procID, const char *pReason ); - - -// Which machine is the master. -#define VMPI_MASTER_ID 0 - -#define VMPI_SEND_TO_ALL -2 -#define VMPI_PERSISTENT -3 // If this is set as the destination for a packet, it is sent to all - // workers, and also to new workers that connect. - -#define MAX_VMPI_PACKET_IDS 32 - - -#define VMPI_TIMEOUT_INFINITE 0xFFFFFFFF - - -// Instantiate one of these to register a dispatch. -class CDispatchReg -{ -public: - CDispatchReg( int iPacketID, VMPIDispatchFn fn ); -}; - - -// Enums for all the command line parameters. -#define VMPI_PARAM_SDK_HIDDEN 0x0001 // Hidden in SDK mode. - -#define VMPI_PARAM( paramName, paramFlags, helpText ) paramName, -enum EVMPICmdLineParam -{ - k_eVMPICmdLineParam_FirstParam=0, - k_eVMPICmdLineParam_VMPIParam, - #include "vmpi_parameters.h" - k_eVMPICmdLineParam_LastParam -}; -#undef VMPI_PARAM - - -// Shared by all the tools. -extern bool g_bUseMPI; -extern bool g_bMPIMaster; // Set to true if we're the master in a VMPI session. -extern int g_iVMPIVerboseLevel; // Higher numbers make it spit out more data. - -extern bool g_bMPI_Stats; // Send stats to the MySQL database? -extern bool g_bMPI_StatsTextOutput; // Send text output in the stats? - -// These can be watched or modified to check bandwidth statistics. -extern int g_nBytesSent; -extern int g_nMessagesSent; -extern int g_nBytesReceived; -extern int g_nMessagesReceived; - -extern int g_nMulticastBytesSent; -extern int g_nMulticastBytesReceived; - -extern int g_nMaxWorkerCount; - - -enum VMPIRunMode -{ - VMPI_RUN_NETWORKED, - VMPI_RUN_LOCAL // Just make a local process and have it do the work. -}; - - -enum VMPIFileSystemMode -{ - VMPI_FILESYSTEM_MULTICAST, // Multicast out, find workers, have them do work. - VMPI_FILESYSTEM_BROADCAST, // Broadcast out, find workers, have them do work. - VMPI_FILESYSTEM_TCP // TCP filesystem. -}; - - -// If this precedes the dependency filename, then it will transfer all the files in the specified directory. -#define VMPI_DEPENDENCY_DIRECTORY_TOKEN '*' - - -// It's good to specify a disconnect handler here immediately. If you don't have a handler -// and the master disconnects, you'll lockup forever inside a dispatch loop because you -// never handled the master disconnecting. -// -// Note: runMode is only relevant for the VMPI master. The worker always connects to the master -// the same way. -bool VMPI_Init( - int &argc, - char **&argv, - const char *pDependencyFilename, - VMPI_Disconnect_Handler handler = NULL, - VMPIRunMode runMode = VMPI_RUN_NETWORKED, // Networked or local?, - bool bConnectingAsService = false - ); - -// Used when hosting a patch. -void VMPI_Init_PatchMaster( int argc, char **argv ); - -void VMPI_Finalize(); - -VMPIRunMode VMPI_GetRunMode(); -VMPIFileSystemMode VMPI_GetFileSystemMode(); - -// Note: this number can change on the master. -int VMPI_GetCurrentNumberOfConnections(); - - -// Dispatch messages until it gets one with the specified packet ID. -// If subPacketID is not set to -1, then the second byte must match that as well. -// -// Note: this WILL dispatch packets with matching packet IDs and give them a chance to handle packets first. -// -// If bWait is true, then this function either succeeds or Error() is called. If it's false, then if the first available message -// is handled by a dispatch, this function returns false. -bool VMPI_DispatchUntil( MessageBuffer *pBuf, int *pSource, int packetID, int subPacketID = -1, bool bWait = true ); - -// This waits for the next message and dispatches it. -// You can specify a timeout in milliseconds. If the timeout expires, the function returns false. -bool VMPI_DispatchNextMessage( unsigned long timeout=VMPI_TIMEOUT_INFINITE ); - -// This should be called periodically in modal loops that don't call other VMPI functions. This will -// check for disconnected sockets and call disconnect handlers so the app can error out if -// it loses all of its connections. -// -// This can be used in place of a Sleep() call by specifying a timeout value. -void VMPI_HandleSocketErrors( unsigned long timeout=0 ); - - - -enum VMPISendFlags -{ - k_eVMPISendFlags_GroupPackets = 0x0001 -}; - -// Use these to send data to one of the machines. -// If iDest is VMPI_SEND_TO_ALL, then the message goes to all the machines. -// Flags is a combination of the VMPISendFlags enums. -bool VMPI_SendData( void *pData, int nBytes, int iDest, int fVMPISendFlags=0 ); -bool VMPI_SendChunks( void const * const *pChunks, const int *pChunkLengths, int nChunks, int iDest, int fVMPISendFlags=0 ); -bool VMPI_Send2Chunks( const void *pChunk1, int chunk1Len, const void *pChunk2, int chunk2Len, int iDest, int fVMPISendFlags=0 ); // for convenience.. -bool VMPI_Send3Chunks( const void *pChunk1, int chunk1Len, const void *pChunk2, int chunk2Len, const void *pChunk3, int chunk3Len, int iDest, int fVMPISendFlags=0 ); - -// Flush any groups that were queued with k_eVMPISendFlags_GroupPackets. -// If msInterval is > 0, then it will check a timer and only flush that often (so you can call this a lot, and have it check). -void VMPI_FlushGroupedPackets( unsigned long msInterval=0 ); - -// This registers a function that gets called when a connection is terminated ungracefully. -void VMPI_AddDisconnectHandler( VMPI_Disconnect_Handler handler ); - -// Returns false if the process has disconnected ungracefully (disconnect handlers -// would have been called for it too). -bool VMPI_IsProcConnected( int procID ); - -// Returns true if the process is just a service (in which case it should only get file IO traffic). -bool VMPI_IsProcAService( int procID ); - -// Simple wrapper for Sleep() so people can avoid including windows.h -void VMPI_Sleep( unsigned long ms ); - -// VMPI sends machine names around first thing. -const char* VMPI_GetLocalMachineName(); -const char* VMPI_GetMachineName( int iProc ); -bool VMPI_HasMachineNameBeenSet( int iProc ); - -// Returns 0xFFFFFFFF if the ID hasn't been set. -unsigned long VMPI_GetJobWorkerID( int iProc ); -void VMPI_SetJobWorkerID( int iProc, unsigned long jobWorkerID ); - -// Search a command line to find arguments. Looks for pName, and if it finds it, returns the -// argument following it. If pName is the last argument, it returns pDefault. If it doesn't -// find pName, returns NULL. -const char* VMPI_FindArg( int argc, char **argv, const char *pName, const char *pDefault = "" ); - -// (Threadsafe) get and set the current stage. This info winds up in the VMPI database. -void VMPI_GetCurrentStage( char *pOut, int strLen ); -void VMPI_SetCurrentStage( const char *pCurStage ); - -// VMPI is always broadcasting this job in the background. -// This changes the password to 'debugworker' and allows more workers in. -// This can be used if workers are dying on certain work units. Then a programmer -// can run vmpi_service with -superdebug and debug the whole thing. -void VMPI_InviteDebugWorkers(); - -bool VMPI_IsSDKMode(); - -// Lookup a command line parameter string. -const char* VMPI_GetParamString( EVMPICmdLineParam eParam ); -int VMPI_GetParamFlags( EVMPICmdLineParam eParam ); -const char* VMPI_GetParamHelpString( EVMPICmdLineParam eParam ); -bool VMPI_IsParamUsed( EVMPICmdLineParam eParam ); // Returns true if the specified parameter is on the command line. - -// Can be called from error handlers and if -mpi_Restart is used, it'll automatically restart the process. -bool VMPI_HandleAutoRestart(); - - -#endif // VMPI_H diff --git a/vmpi/vmpi_defs.h b/vmpi/vmpi_defs.h deleted file mode 100644 index 150db22e..00000000 --- a/vmpi/vmpi_defs.h +++ /dev/null @@ -1,147 +0,0 @@ -//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -//=============================================================================// - -#ifndef VMPI_DEFS_H -#define VMPI_DEFS_H -#ifdef _WIN32 -#pragma once -#endif - - -// This goes in front of all packets. -#define VMPI_PROTOCOL_VERSION 5 - -// This represents the protocol between the service and its UI. -#define VMPI_SERVICE_UI_PROTOCOL_VERSION 1 - -// NOTE: the service version (embedded in vmpi_service.exe as a resource) is the version -// that is used to apply patches. -#define VMPI_SERVICE_IDS_VERSION_STRING 102 // This matches IDS_VERSION_STRING in vmpi_service.exe. - -// Known packet IDs in various systems. -#define VMPI_PACKETID_FILESYSTEM 0 // The file system reserves this packet ID. - // All application traffic must set its first byte to something other - // than this value. -#define VMPI_SHARED_PACKET_ID 10 - - -// Turn this on, and the various service apps will log stuff. -//#define VMPI_SERVICE_LOGS - - -// This value is put in the RunningTimeMS until the job is finished. This is how -// the job_search app knows if a job never finished. -#define RUNNINGTIME_MS_SENTINEL 0xFEDCBAFD - - - -#define VMPI_SERVICE_NAME_INTERNAL "VMPI" -#define VMPI_SERVICE_NAME "Valve MPI Service" - -// Stuff in the registry goes under here (in HKEY_LOCAL_MACHINE). -#define VMPI_SERVICE_KEY "Software\\Valve\\VMPI" -#define SERVICE_INSTALL_LOCATION_KEY "InstallLocation" - -// The VMPI service listens on one of these ports to talk to the UI. -#define VMPI_SERVICE_FIRST_UI_PORT 23300 -#define VMPI_SERVICE_LAST_UI_PORT 23310 - -// Port numbers that the master will use to broadcast unless -mpi_port is used. -#define VMPI_MASTER_FIRST_PORT 23311 -#define VMPI_MASTER_LAST_PORT 23330 - - -// Packet IDs for vmpi_service to talk to UI clients. -#define VMPI_SERVICE_TO_UI_CONSOLE_TEXT 0 // Print some text to the UI's console. -#define VMPI_SERVICE_TO_UI_STATE 1 // Updates state reflecting whether it's idle, busy, etc. -#define VMPI_SERVICE_TO_UI_PATCHING 2 // Updates state reflecting whether it's idle, busy, etc. -#define VMPI_SERVICE_TO_UI_EXIT 3 // Updates state reflecting whether it's idle, busy, etc. - - // Application state.. these are communicated between the service and the UI. - enum - { - VMPI_SERVICE_STATE_IDLE=0, - VMPI_SERVICE_STATE_BUSY, - VMPI_SERVICE_STATE_DISABLED - }; -#define VMPI_SERVICE_DISABLE 2 // Stop waiting for jobs.. -#define VMPI_SERVICE_ENABLE 3 -#define VMPI_SERVICE_UPDATE_PASSWORD 4 // New password. -#define VMPI_SERVICE_EXIT 5 // User chose "exit" from the menu. Kill the service. -#define VMPI_SERVICE_SKIP_CSX_JOBS 6 -#define VMPI_SERVICE_SCREENSAVER_MODE 7 - - -// The worker service waits on this range of ports. -#define VMPI_SERVICE_PORT 23397 -#define VMPI_LAST_SERVICE_PORT (VMPI_SERVICE_PORT + 15) - - -#define VMPI_WORKER_PORT_FIRST 22340 -#define VMPI_WORKER_PORT_LAST 22350 - -// The VMPI service downloader is still a worker but it uses this port range so the -// master knows it's just downloading the exes. -#define VMPI_SERVICE_DOWNLOADER_PORT_FIRST 22351 -#define VMPI_SERVICE_DOWNLOADER_PORT_LAST 22360 - -// Give it a small range so they can have multiple masters running. -#define VMPI_MASTER_PORT_FIRST 21140 -#define VMPI_MASTER_PORT_LAST 21145 -#define VMPI_MASTER_FILESYSTEM_BROADCAST_PORT 21146 - - - - -// Protocol. - -// The message format is: -// - VMPI_PROTOCOL_VERSION -// - null-terminated password string (or VMPI_PASSWORD_OVERRIDE followed by a zero to process it regardless of pw). -// - packet ID -// - payload - - -#define VMPI_PASSWORD_OVERRIDE -111 - - -#define VMPI_MESSAGE_BASE 71 - - -// This is the broadcast message from the main (rank 0) process looking for workers. -#define VMPI_LOOKING_FOR_WORKERS (VMPI_MESSAGE_BASE+0) - -// This is so an app can find out what machines are running the service. -#define VMPI_PING_REQUEST (VMPI_MESSAGE_BASE+2) -#define VMPI_PING_RESPONSE (VMPI_MESSAGE_BASE+3) - -// This tells the service to quit. -#define VMPI_STOP_SERVICE (VMPI_MESSAGE_BASE+6) - -// This tells the service to kill any process it has running. -#define VMPI_KILL_PROCESS (VMPI_MESSAGE_BASE+7) - -// This tells the service to patch itself. -#define VMPI_SERVICE_PATCH (VMPI_MESSAGE_BASE+8) - -// Sent back to the master via UDP to tell it if its job has started and ended. -#define VMPI_NOTIFY_START_STATUS (VMPI_MESSAGE_BASE+9) -#define VMPI_NOTIFY_END_STATUS (VMPI_MESSAGE_BASE+10) - -#define VMPI_FORCE_PASSWORD_CHANGE (VMPI_MESSAGE_BASE+11) - - -// These states are sent from the service to the services browser. -#define VMPI_STATE_IDLE 0 -#define VMPI_STATE_BUSY 1 -#define VMPI_STATE_PATCHING 2 -#define VMPI_STATE_DISABLED 3 -#define VMPI_STATE_SCREENSAVER_DISABLED 4 -#define VMPI_STATE_DOWNLOADING 5 - - -#endif // VMPI_DEFS_H diff --git a/vmpi/vmpi_dispatch.h b/vmpi/vmpi_dispatch.h deleted file mode 100644 index 9c62eecd..00000000 --- a/vmpi/vmpi_dispatch.h +++ /dev/null @@ -1,15 +0,0 @@ -//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -//=============================================================================// - -#ifndef VMPI_DISPATCH_H -#define VMPI_DISPATCH_H -#ifdef _WIN32 -#pragma once -#endif - - -#endif // VMPI_DISPATCH_H diff --git a/vmpi/vmpi_distribute_work.h b/vmpi/vmpi_distribute_work.h deleted file mode 100644 index 25dad5f0..00000000 --- a/vmpi/vmpi_distribute_work.h +++ /dev/null @@ -1,89 +0,0 @@ -//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -//=============================================================================// - -#ifndef VMPI_DISTRIBUTE_WORK_H -#define VMPI_DISTRIBUTE_WORK_H -#ifdef _WIN32 -#pragma once -#endif - - -#include "messbuf.h" -#include "utlvector.h" - - -class IWorkUnitDistributorCallbacks -{ -public: - // Called every 200ms or so as it does the work. - // Return true to stop distributing work. - virtual bool Update() { return false; } - - // Called when a subsequent number of work units is completed. - // e.g. results received in the following order will trigger - // the following calls to OnWorkUnitsCompleted: - // Work unit numbers: wu2 wu4 wu5 wu1 wu0 wu6 wu3 - // Calling OnWorkUnitsCompleted with arg: - - - - 3 - 7 - // because when wu0 is received we already have { wu0, wu1, wu2 } so we signal - // that 3 subsequent work units completed, like wise by the time when wu3 is - // received we already have a full set { wu0, wu1, wu2, wu3, wu4, wu5, wu6 } - // and signal that 7 work units completed. - virtual void OnWorkUnitsCompleted( uint64 numWorkUnits ) { return; } -}; - - -enum EWorkUnitDistributor -{ - k_eWorkUnitDistributor_Default, - k_eWorkUnitDistributor_SDK -}; - -// Tells which work unit distributor is going to be used. -EWorkUnitDistributor VMPI_GetActiveWorkUnitDistributor(); - - -// Before calling DistributeWork, you can set this and it'll call your virtual functions. -extern IWorkUnitDistributorCallbacks *g_pDistributeWorkCallbacks; - - -// You must append data to pBuf with the work unit results. -// Note: pBuf will be NULL if this is a local thread doing work on the master. -typedef void (*ProcessWorkUnitFn)( int iThread, uint64 iWorkUnit, MessageBuffer *pBuf ); - -// pBuf is ready to read the results written to the buffer in ProcessWorkUnitFn. -typedef void (*ReceiveWorkUnitFn)( uint64 iWorkUnit, MessageBuffer *pBuf, int iWorker ); - - -// Use a CDispatchReg to register this function with whatever packet ID you give to DistributeWork. -bool DistributeWorkDispatch( MessageBuffer *pBuf, int iSource, int iPacketID ); - - - -// This is the function vrad and vvis use to divide the work units and send them out. -// It maintains a sliding window of work units so it can always keep the clients busy. -// -// The workers implement processFn to do the job work in a work unit. -// This function must send back a packet formatted with: -// cPacketID (char), cSubPacketID (char), iWorkUnit (int), (app-specific data for the results) -// -// The masters implement receiveFn to receive a work unit's results. -// -// Returns time it took to finish the work. -double DistributeWork( - uint64 nWorkUnits, // how many work units to dole out - char cPacketID, // This packet ID must be reserved for DistributeWork and DistributeWorkDispatch - // must be registered with it. - ProcessWorkUnitFn processFn, // workers implement this to process a work unit and send results back - ReceiveWorkUnitFn receiveFn // the master implements this to receive a work unit - ); - - -// VMPI calls this before shutting down because any threads that DistributeWork has running must stop, -// otherwise it can crash if a thread tries to send data in the middle of shutting down. -void DistributeWork_Cancel(); - - -#endif // VMPI_DISTRIBUTE_WORK_H diff --git a/vmpi/vmpi_filesystem.h b/vmpi/vmpi_filesystem.h deleted file mode 100644 index caed6f95..00000000 --- a/vmpi/vmpi_filesystem.h +++ /dev/null @@ -1,53 +0,0 @@ -//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -//=============================================================================// - -#ifndef VMPI_FILESYSTEM_H -#define VMPI_FILESYSTEM_H -#ifdef _WIN32 -#pragma once -#endif - - -#include "interface.h" - - -class IFileSystem; -class MessageBuffer; - - -// Use this to read virtual files. -#define VMPI_VIRTUAL_FILES_PATH_ID "VMPI_VIRTUAL_FILES_PATH_ID" - - -// When you hook the file system with VMPI and are a worker, it blocks on file reads -// and uses MPI to communicate with the master to transfer files it needs over. -// -// The filesystem, by default (and it maxFileSystemMemoryUsage is left at zero), -// keeps the contents of the files that get opened in memory. You can pass in a -// value here to put a cap on it, in which case it'll unload the least-recently-used -// files when it hits the limit. -IFileSystem* VMPI_FileSystem_Init( int maxFileSystemMemoryUsage, IFileSystem *pPassThru ); - -// On the master machine, this really should be called before the app shuts down and -// global destructors are called. If it isn't, it might lock up waiting for a thread to exit. -// -// This returns the original filesystem you passed into VMPI_FileSystem_Init so you can uninitialize it. -IFileSystem* VMPI_FileSystem_Term(); - -// Causes it to error out on any Open() calls. -void VMPI_FileSystem_DisableFileAccess(); - -// Returns a factory that will hand out BASEFILESYSTEM_INTERFACE_VERSION when asked for it. -CreateInterfaceFn VMPI_FileSystem_GetFactory(); - -// This function creates a virtual file that workers can then open and read out of. -// NOTE: when reading from the file, you must use VMPI_VIRTUAL_FILES_PATH_ID as the path ID -// or else it won't find the file. -void VMPI_FileSystem_CreateVirtualFile( const char *pFilename, const void *pData, unsigned long fileLength ); - - -#endif // VMPI_FILESYSTEM_H diff --git a/vmpi/vmpi_parameters.h b/vmpi/vmpi_parameters.h deleted file mode 100644 index 735027e0..00000000 --- a/vmpi/vmpi_parameters.h +++ /dev/null @@ -1,31 +0,0 @@ -//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======= -// -// Purpose: -// -//============================================================================= - -VMPI_PARAM( mpi_Worker, 0, "Workers use this to connect to a VMPI job. Specify the IP address of the master. Example: -mpi_worker 1.2.3.4 or -mpi_worker 1.2.3.4:242" ) -VMPI_PARAM( mpi_Port, 0, "Use this on the master to force it to bind to a specified port. Otherwise it binds to 23311 (and ascending port numbers if 23311 doesn't work)." ) -VMPI_PARAM( mpi_Graphics, 0, "Show a graphical representation of work units [grey=work unit not sent yet, red=sent, green=completed, blue=in-process]" ) -VMPI_PARAM( mpi_Retry, 0, "Use this on the worker to have it retry connecting to the master forever. Otherwise it will exit if it can't connect to the master immediately." ) -VMPI_PARAM( mpi_AutoRestart, 0, "Use this on the worker to have it restart with the same command line parameters after completing a job. Useful in conjunction with -mpi_Retry to have an always-on worker ready to do work." ) -VMPI_PARAM( mpi_TrackEvents, 0, "Enables a debug menu during jobs (press D to access). Note: -mpi_Graphics automatically enables -mpi_TrackEvents." ) -VMPI_PARAM( mpi_ShowDistributeWorkStats, 0, "After finishing a stage in the work unit processing, shows statistics." ) -VMPI_PARAM( mpi_TimingWait, 0, "Causes the master to wait for a keypress to start so workers can connect before it starts. Used for performance measurements." ) -VMPI_PARAM( mpi_WorkerCount, 0, "Set the maximum number of workers allowed in the job." ) -VMPI_PARAM( mpi_AutoLocalWorker, 0, "Used on the master's machine. Automatically spawn a worker on the local machine. Used for testing." ) -VMPI_PARAM( mpi_FileTransmitRate, 0, "VMPI file transmission rate in kB/sec." ) -VMPI_PARAM( mpi_Verbose, 0, "Set to 0, 1, or 2 to control verbosity of debug output." ) -VMPI_PARAM( mpi_NoMasterWorkerThreads, 0, "Don't process work units locally (in the master). Only used by the SDK work unit distributor." ) -VMPI_PARAM( mpi_SDKMode, VMPI_PARAM_SDK_HIDDEN, "Force VMPI to run in SDK mode." ) -VMPI_PARAM( mpi_UseSDKDistributor, VMPI_PARAM_SDK_HIDDEN, "Use the SDK work unit distributor. Optimized for low numbers of workers and higher latency. Note that this will automatically be used in SDK distributions." ) -VMPI_PARAM( mpi_UseDefaultDistributor, VMPI_PARAM_SDK_HIDDEN, "Use the default work unit distributor. Optimized for high numbers of workers, higher numbers of work units, and lower latency. Note that this will automatically be used in non-SDK distributions." ) -VMPI_PARAM( mpi_NoTimeout, VMPI_PARAM_SDK_HIDDEN, "Don't timeout VMPI sockets. Used for testing." ) -VMPI_PARAM( mpi_DontSetThreadPriorities, VMPI_PARAM_SDK_HIDDEN, "Don't set worker thread priorities to idle." ) -VMPI_PARAM( mpi_GroupPackets, VMPI_PARAM_SDK_HIDDEN, "Delay and group some of the worker packets instead of sending immediately." ) -VMPI_PARAM( mpi_Stats, VMPI_PARAM_SDK_HIDDEN, "Enables the use of a database to store compile statistics." ) -VMPI_PARAM( mpi_Stats_TextOutput, VMPI_PARAM_SDK_HIDDEN, "Enables the workers storing all of their text output into the stats database." ) -VMPI_PARAM( mpi_pw, VMPI_PARAM_SDK_HIDDEN, "Non-SDK only. Sets a password on the VMPI job. Workers must also use the same -mpi_pw [password] argument or else the master will ignore their requests to join the job." ) -VMPI_PARAM( mpi_CalcShuffleCRC, VMPI_PARAM_SDK_HIDDEN, "Calculate a CRC for shuffled work unit arrays in the SDK work unit distributor." ) -VMPI_PARAM( mpi_Job_Watch, VMPI_PARAM_SDK_HIDDEN, "Automatically launches vmpi_job_watch.exe on the job." ) -VMPI_PARAM( mpi_Local, VMPI_PARAM_SDK_HIDDEN, "Similar to -mpi_AutoLocalWorker, but the automatically-spawned worker's console window is hidden." ) \ No newline at end of file