1 #ifndef _XSEXECUTIONSERVER_HPP
2 #define _XSEXECUTIONSERVER_HPP
3 /*-------------------------------------------------------------------------
4 * drawElements Quality Program Execution Server
5 * ---------------------------------------------
7 * Copyright 2014 The Android Open Source Project
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 * \brief Test Execution Server.
24 *//*--------------------------------------------------------------------*/
27 #include "xsTcpServer.hpp"
28 #include "xsTestDriver.hpp"
29 #include "xsProtocol.hpp"
30 #include "xsTestProcess.hpp"
37 class ExecutionServer : public TcpServer
42 RUNMODE_SINGLE_EXEC = 0,
48 ExecutionServer (xs::TestProcess* testProcess, deSocketFamily family, int port, RunMode runMode);
49 ~ExecutionServer (void);
51 ConnectionHandler* createHandler (de::Socket* socket, const de::SocketAddress& clientAddress);
53 TestDriver* acquireTestDriver (void);
54 void releaseTestDriver (TestDriver* driver);
56 void connectionDone (ConnectionHandler* handler);
59 TestDriver m_testDriver;
60 de::Mutex m_testDriverLock;
67 MessageBuilder (void) { clear(); }
68 ~MessageBuilder (void) {}
70 void read (ByteBuffer& buffer);
73 bool isComplete (void) const;
74 MessageType getMessageType (void) const { return m_messageType; }
75 size_t getMessageSize (void) const { return m_messageSize; }
76 const deUint8* getMessageData (void) const;
77 size_t getMessageDataSize (void) const;
80 std::vector<deUint8> m_buffer;
81 MessageType m_messageType;
85 class ExecutionRequestHandler : public ConnectionHandler
88 ExecutionRequestHandler (ExecutionServer* server, de::Socket* socket);
89 ~ExecutionRequestHandler (void);
95 ExecutionRequestHandler (const ExecutionRequestHandler& handler);
96 ExecutionRequestHandler& operator= (const ExecutionRequestHandler& handler);
98 void processSession (void);
99 void processMessage (MessageType type, const deUint8* data, size_t dataSize);
101 inline TestDriver* getTestDriver (void) { if (!m_testDriver) acquireTestDriver(); return m_testDriver; }
102 void acquireTestDriver (void);
104 void initKeepAlives (void);
105 void keepAliveReceived (void);
106 void pollKeepAlives (void);
111 ExecutionServer* m_execServer;
112 TestDriver* m_testDriver;
114 ByteBuffer m_bufferIn;
115 ByteBuffer m_bufferOut;
118 MessageBuilder m_msgBuilder;
120 // \todo [2011-09-30 pyry] Move to some watchdog class instead.
121 deUint64 m_lastKeepAliveSent;
122 deUint64 m_lastKeepAliveReceived;
124 std::vector<deUint8> m_sendRecvTmpBuf;
129 #endif // _XSEXECUTIONSERVER_HPP