Merge pull request #5219 from 10ne1/fix/sway-ipc-subscribe-race

fix(sway/ipc): don't mistake events for the subscribe reply
This commit is contained in:
Alexis Rouillard
2026-07-30 10:11:18 +02:00
committed by GitHub
+7
View File
@@ -193,6 +193,13 @@ void Ipc::sendCmd(uint32_t type, const std::string& payload) {
void Ipc::subscribe(const std::string& payload) {
auto res = Ipc::send(fd_event_, IPC_SUBSCRIBE, payload);
// Events subscribed to by a previous subscribe() call may arrive on the
// socket before the reply to this one; deliver them and keep reading until
// the subscribe reply is found.
while ((res.type >> 31) != 0U) {
signal_event.emit(res);
res = Ipc::recv(fd_event_);
}
if (res.payload != "{\"success\": true}") {
throw std::runtime_error("Unable to subscribe ipc event");
}