@@ -180,7 +180,7 @@ class HexagonPageAllocator {
180180class HexagonRPCServer {
181181 public:
182182 explicit HexagonRPCServer (uint8_t * receive_buffer, size_t receive_buffer_size_bytes)
183- : io_{receive_buffer, receive_buffer_size_bytes}, rpc_server_{&io_} {};
183+ : io_{receive_buffer, receive_buffer_size_bytes}, rpc_server_{&io_} {}
184184
185185 /* !
186186 * \brief Wrtie to IOHandler.
@@ -191,16 +191,16 @@ class HexagonRPCServer {
191191 * Otherwise, returns -1;
192192 */
193193 int64_t Write (const uint8_t * data, size_t data_size_bytes) {
194+ if (!is_running_) {
195+ LOG (ERROR) << " ERROR: Write called but server is not running" ;
196+ }
194197 AEEResult rc = io_.SetReadBuffer (data, data_size_bytes);
195198 if (rc != AEE_SUCCESS) {
196199 LOG (ERROR) << " ERROR: SetReadBuffer failed: " << rc;
197200 return -1 ;
198201 }
199202
200- if (!rpc_server_.ProcessOnePacket ()) {
201- LOG (ERROR) << " ERROR: ProcessOnePacket failed" ;
202- return -1 ;
203- }
203+ is_running_ = rpc_server_.ProcessOnePacket ();
204204 return (int64_t )data_size_bytes;
205205 }
206206
@@ -212,10 +212,14 @@ class HexagonRPCServer {
212212 * \return The size of data that is read in bytes.
213213 */
214214 int64_t Read (uint8_t * buf, size_t read_size_bytes) {
215+ if (!is_running_) {
216+ LOG (ERROR) << " ERROR: Read called but server is not running" ;
217+ }
215218 return io_.ReadFromWriteBuffer (buf, read_size_bytes);
216219 }
217220
218221 private:
222+ bool is_running_ = true ;
219223 HexagonIOHandler io_;
220224 MinRPCServer<HexagonIOHandler, HexagonPageAllocator> rpc_server_;
221225};
0 commit comments