alive_ack_queue implemented

This commit is contained in:
2026-04-11 16:10:39 +02:00
parent 52aa0cac10
commit e9e295c3bc
2 changed files with 33 additions and 5 deletions

View File

@@ -38,6 +38,7 @@ class Alive : public QThread
public:
Handler *handler;
ShmQueue *alive_queue;
ShmQueue *alive_ack_queue;
bool alive_timeout;
protected:
@@ -71,7 +72,7 @@ int main(int argc, char *argv[])
INFO1("Starting at %s", ctime(&my_time));
}
if (argc < 7) {
if (argc < 8) {
ERROR1("%s: wrong number of arguments\n", me);
exit(1);
}
@@ -82,17 +83,21 @@ int main(int argc, char *argv[])
const char *res_slot_str = argv[4];
const char *evt_slot_str = argv[5];
const char *alive_slot_str = argv[6];
const char *alive_ack_slot_str = argv[7];
size_t shm_size = atoi(shm_size_str);
int cmd_slot = atoi(cmd_slot_str);
int res_slot = atoi(res_slot_str);
int evt_slot = atoi(evt_slot_str);
int alive_slot = atoi(alive_slot_str);
int alive_ack_slot = atoi(alive_ack_slot_str);
MKLOGSTMT(LOG_INFO, fprintf(stderr, "%s %s %s %s %s %s %s\n", me, shm_name, shm_size_str, cmd_slot_str, res_slot_str, evt_slot_str, alive_slot_str));
MKLOGSTMT(LOG_INFO, fprintf(stderr, "%s %s %ld %d %d %d %d\n", me, shm_name, shm_size, cmd_slot, res_slot, evt_slot, alive_slot));
MKLOGSTMT(LOG_INFO, fprintf(stderr, "%s %s %s %s %s %s %s %s\n", me, shm_name, shm_size_str,
cmd_slot_str, res_slot_str, evt_slot_str, alive_slot_str, alive_ack_slot_str));
MKLOGSTMT(LOG_INFO, fprintf(stderr, "%s %s %lld %d %d %d %d %d\n", me, shm_name, shm_size,
cmd_slot, res_slot, evt_slot, alive_slot, alive_ack_slot));
if (!(shm_size > 0 && cmd_slot > 0 && res_slot > 0 && evt_slot > 0)) {
if (!(shm_size > 0 && cmd_slot > 0 && res_slot > 0 && evt_slot > 0 && alive_slot > 0 && alive_ack_slot > 0)) {
ERROR1("%s: Invalid shm size or slots\n", me);
exit(2);
}
@@ -111,6 +116,7 @@ int main(int argc, char *argv[])
alive->handler = handler;
alive->alive_timeout = false;
alive->alive_queue = new ShmQueue(handler->shm, alive_slot, false);
alive->alive_ack_queue = new ShmQueue(handler->shm, alive_ack_slot, false);
alive->start();
handler->webview_handler->initApp();
@@ -131,6 +137,7 @@ int main(int argc, char *argv[])
handler->event_queue->takeOwnership();
handler->shm->takeOwnership();
alive->alive_queue->takeOwnership();
alive->alive_ack_queue->takeOwnership();
}
INFO0("cleaning up shm\n");
@@ -417,6 +424,7 @@ void Alive::run()
go_on = false;
} else {
DEBUG1("Got alive ping: %d\n", ping_no);
alive_ack_queue->enqueue(ping_no);
}
}
}