Skip to content

Commit e1e8e91

Browse files
committed
ggml : Fixed race-condition that leads to crashes when using ggml-rpc
1 parent 2f5a4e1 commit e1e8e91

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

ggml/src/ggml-rpc/ggml-rpc.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,8 @@ static bool parse_endpoint(const std::string & endpoint, std::string & host, int
386386
// RPC request : | rpc_cmd (1 byte) | request_size (8 bytes) | request_data (request_size bytes) |
387387
// No response
388388
static bool send_rpc_cmd(const std::shared_ptr<socket_t> & sock, enum rpc_cmd cmd, const void * input, size_t input_size) {
389+
static std::mutex send_rpc_cmd_mutex;
390+
std::lock_guard<std::mutex> lock(send_rpc_cmd_mutex);
389391
uint8_t cmd_byte = cmd;
390392
if (!send_data(sock->fd, &cmd_byte, sizeof(cmd_byte))) {
391393
return false;

0 commit comments

Comments
 (0)