From patchwork Thu Sep 16 07:26:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 1528657 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=kF8IZurz; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=VXpkcHpg; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::b3c; helo=mail-yb1-xb3c.google.com; envelope-from=swupdate+bncbcl4hcw73qcbbghdrofamgqe7ngwdty@googlegroups.com; receiver=) Received: from mail-yb1-xb3c.google.com (mail-yb1-xb3c.google.com [IPv6:2607:f8b0:4864:20::b3c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H97tP4R4Tz9sR4 for ; Thu, 16 Sep 2021 17:26:20 +1000 (AEST) Received: by mail-yb1-xb3c.google.com with SMTP id d93-20020a25a366000000b0059fff274d9asf11513936ybi.4 for ; Thu, 16 Sep 2021 00:26:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1631777177; cv=pass; d=google.com; s=arc-20160816; b=ZQH2n59k6qAXmxdJXs4Mbn2RbrYxNHJDBQeAI9tLFp0HAFYLW0VeDXao6X7b9SXGse mMimFqGdlNIFZ4PlrlHuwxi6xCbEte+ez81/vdZWO+8JaF7z4V68ol0fGjMkdu9Q3/aN G6ZUyZ/CIySYBXWlMOkE2PzRUaEBOijEOfj/jqCuHA7FF/JMNVgM3T7bXtEE+lJMHsCk H3RCOWwqTaJ9MNcf3wN0zOH66LEIvD76G+E3VoOw+IYYTOPU4IiuzRGvaynAzI6l1dll /DysD4TElLeGhlRGcQP/XMbePp1dl5enMgQ/ACJYyBGnV22sKl73gVt9qC6FFbM03mek li6g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:message-id:date :subject:cc:to:from:sender:dkim-signature:dkim-signature; bh=QulcMPvBcmLo5EZGhOxSEjs9Bhx49uFvGXeygUzM8NU=; b=CripN11mvm27QGqaSc4XMsUtgdy3Wgm19uTcrLfa92FdbvyD1J3g5vLsioie5LlbII +h7c5gmd3KfoiIs378NEoaot/fspmiQFhBYbIpQekiNY0igq6m0EJZ5Vpk8/omuHijhV sWi8hE4fCTQOX/r5LsJjgwzVZ4I/pjesPsKsWfkKYzs5m/YSX97//tgmaGcF5oOf6sPU YABVfhGcGu5kPMFDcDpX7hfaDOlf/lw32LNedGLL/lKy9eiVBlSVEdr35+4AjZfmkqSn aJOKHBYxUQcRMDUT2Cs89EAS429l62MoAF9zmvO8grjoLkfFXNbfNWU4NdLiCBoIKahM RjhQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LZk9AONs; spf=pass (google.com: domain of james.hilliard1@gmail.com designates 2607:f8b0:4864:20::130 as permitted sender) smtp.mailfrom=james.hilliard1@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=QulcMPvBcmLo5EZGhOxSEjs9Bhx49uFvGXeygUzM8NU=; b=kF8IZurzGfz0c8dVGh20IUur1DloUVX0/9SKkUmEmIKaKwfU+OG+tXO/vhGToZzWn7 6rSyQV9+Vmb8Aa1Yp0LaGW7FazI4eDoSGPv5IntYSVPUW9xamVaEOz+JfvJhr7pl6QOT LwaEhW/I0Uvh3yx59Bo1eVXB/Z0jUF6WHHCltMWsOOmAPqWMzKhSnxpBEW6HbBniolUJ IIRGuQMI7p8526ivAbWav0qN+hPOfEW6g8CryAQhV0dvn//zTQtbUtxVMVGYgT9ZnVBm Ud2FtjQkiLjiJMe7NjHWuhGrbzhNWYx9VO2S/u+xv900KaKTrZ6d4ydXO/GIEv5JINGp aYNw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=QulcMPvBcmLo5EZGhOxSEjs9Bhx49uFvGXeygUzM8NU=; b=VXpkcHpg8HQP02ZnzZLylOaICFOGJn6YaPGWvFRx0w9tChh2hdic4bjNsxtnhDquF4 Uf/wMHRt8ev7LKRcoJ1wy/WFXA+STO/XtGeOR/FU6kqYtukIVBo9GyYtySqy6KIaKwgi ITDBx1zEc1LLTwLpI7Z83FSxXeLes/Dw/Z6HyD0iLVglmjI1DULtHR5EgURmSOGnUOgK LrQWItyCGrutL8zpAMvn8Nij/whQE8mOZKOBi4u3iV4wtriuBYRSiCCgd3EK6Pm26rOK YCtAjJ1W60ZX4tkf76JviX2O1hY48AlgREhePkMXTvXfzDA1+2SQXlEF+OwLlSOz/Xah bctA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=QulcMPvBcmLo5EZGhOxSEjs9Bhx49uFvGXeygUzM8NU=; b=fPnDkxfNwZXuQbi3TPG3JLFMxygToXP76CltkoViFHBVzwLgFimbiYy9ebllHPz5eP JYzlqUqRctVd1IoaHCO1WS/RFgHTYX+HIR1iFvb/AQoyub2jCVft5zJdk8diU0ig29rq iK16m6YTc9AuXjumxhol/d39HIqAwwZQ0rcCSS9kkZ+9lE9MpST/DGLFYln3IwdB0cA0 ZA3yzmHNicFMnU/azS7iw8LZcjM8/IyOUfTqlxwt4QNMcs4oXnN2Z3CEOVXgl+kE2aXi GecaznEybSkQxdiMOsfeFumQ0x39hlyb69USNGmhQ4ox+TQa8BPeF/gDlC6WIc0EhmLr DfxQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM531ccim4OQU/ZQHpJffybUR3PeFxGvi1VjA0MA4jLlqO5IGTAWsF OTxO+kxnyUbEY0iD2JId3HM= X-Google-Smtp-Source: ABdhPJws2m1/g22tzHSV4KH+OKn1W0KnOrp809I+CxaVAnSCse4jcT0WzegeB3Uxidx16TEl/67pOA== X-Received: by 2002:a25:61d6:: with SMTP id v205mr5480165ybb.262.1631777176922; Thu, 16 Sep 2021 00:26:16 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a25:e6c6:: with SMTP id d189ls96832ybh.1.gmail; Thu, 16 Sep 2021 00:26:16 -0700 (PDT) X-Received: by 2002:a5b:f4b:: with SMTP id y11mr5087048ybr.352.1631777176374; Thu, 16 Sep 2021 00:26:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631777176; cv=none; d=google.com; s=arc-20160816; b=bN74TSflkSPr8386KQri6rMFGsfaIghQqYQMoun0LBtCQC3uFsnOX/c2pap7pg1Vqx PkBZBSIMOJk/FLO7Goxg1yAabERayyS6TOjFxoHMfGMcbUiDbkeYpSaLvdkSudMGuw/c ym26ue/TC0+D8hLXQh+ldnM0gaPKLeiWQOZudofYO9YvEJVBwWKbwfqqz+DnRx/8Ftgu I48npRph25n1jPiX1NocU0b3rxPZW+xaTfGeRK4E981Ba72Kc3fVHuIhBGVwLyDMOiZn z9iakW1CHzcoCSCWIosz2h6+qdCLqZfkSqHJBhXUpLdJnQnTG4BBFzSY+wJJY2MbRdaV yFvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=PROMLdb4SoBGDUHPwljWDiiAQ8nXB4q06AFcZs26vWA=; b=dQPFMfTCR54NPmwfal9ybVfQWN6jidtICzzNaUHo8hYaAlZq62XrB8am5EaYRTBAJh UHak7wZSLHAZkRLVkrIWXOWgWbzFes0RIrrNWSrqRzOsTCR3DaLbvDwNkOiE+GrmwoQi aBNuYoz4hV5Zjn/wwH+Eqp7++UIOyifFfqLynknI3sShYJRcbpuW3TWIKTVk2MGog97X 4RI/PsgIdtqTMXWPHR4e5aDSnUQhFJ8Y6xN/F1zDB8FqdiChtKHDXp3dE/rpsgigb/L2 3iZBagqbGifdIEnu6q9oTN6P22rMVpOZkO70Hf6I7UJNYb+T7upoYpOt1d6FwUNuYa55 MT5g== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LZk9AONs; spf=pass (google.com: domain of james.hilliard1@gmail.com designates 2607:f8b0:4864:20::130 as permitted sender) smtp.mailfrom=james.hilliard1@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-il1-x130.google.com (mail-il1-x130.google.com. [2607:f8b0:4864:20::130]) by gmr-mx.google.com with ESMTPS id w6si370963ybt.0.2021.09.16.00.26.16 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Sep 2021 00:26:16 -0700 (PDT) Received-SPF: pass (google.com: domain of james.hilliard1@gmail.com designates 2607:f8b0:4864:20::130 as permitted sender) client-ip=2607:f8b0:4864:20::130; Received: by mail-il1-x130.google.com with SMTP id x2so5640477ila.11 for ; Thu, 16 Sep 2021 00:26:16 -0700 (PDT) X-Received: by 2002:a92:ce85:: with SMTP id r5mr2795419ilo.159.1631777175709; Thu, 16 Sep 2021 00:26:15 -0700 (PDT) Received: from MacBook-Pro-2.localdomain (97-118-233-80.hlrn.qwest.net. [97.118.233.80]) by smtp.gmail.com with ESMTPSA id y26sm1316340iob.37.2021.09.16.00.26.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Sep 2021 00:26:15 -0700 (PDT) From: James Hilliard To: swupdate@googlegroups.com Cc: James Hilliard Subject: [swupdate] [PATCH v3 1/1] IPC: add status streaming support Date: Thu, 16 Sep 2021 01:26:12 -0600 Message-Id: <20210916072612.2022-1-james.hilliard1@gmail.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-Original-Sender: james.hilliard1@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LZk9AONs; spf=pass (google.com: domain of james.hilliard1@gmail.com designates 2607:f8b0:4864:20::130 as permitted sender) smtp.mailfrom=james.hilliard1@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , This adds a NOTIFY_STREAM command to the ctrl interface, this is implemented with a history replay functionality so that clients can see notify messages from before they connect. This has the advantage of making it possible for multiple clients to monitor notify messages at the same time. Signed-off-by: James Hilliard --- Changes v2 -> v3: - unlock stream_mutex on OOM error Changes v1 -> v2: - move stream interface into network_ipc ctrl socket - add history replay --- core/network_thread.c | 128 +++++++++++++++++++++++++++++++++- include/network_ipc.h | 11 ++- ipc/network_ipc.c | 79 +++++++++++++++++++++ mongoose/mongoose_interface.c | 39 +++++++---- 4 files changed, 242 insertions(+), 15 deletions(-) diff --git a/core/network_thread.c b/core/network_thread.c index adaf21c..27e8fd8 100644 --- a/core/network_thread.c +++ b/core/network_thread.c @@ -69,6 +69,14 @@ static pthread_t subprocess_ipc_handler_thread_id; static pthread_mutex_t subprocess_msg_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t subprocess_wkup = PTHREAD_COND_INITIALIZER; +struct notify_conn { + SIMPLEQ_ENTRY(notify_conn) next; + int sockfd; +}; + +SIMPLEQ_HEAD(connections, notify_conn); +static struct connections notify_conns; + static bool is_selection_allowed(const char *software_set, char *running_mode, struct dict const *acceptedlist) { @@ -116,11 +124,61 @@ static void clean_msg(char *msg, char drop) } } +static int write_notify_msg(ipc_message *msg, int sockfd) +{ + void *buf; + size_t count; + ssize_t n; + int ret = 0; + + buf = msg; + count = sizeof(*msg); + while (count > 0) { + n = send(sockfd, buf, count, MSG_NOSIGNAL); + if (n <= 0) { + /* + * We can't use the notify methods for error logging here as it will cause a deadlock. + */ + if (n == 0) { + fprintf(stderr, "Error: A status client is not responding, removing it.\n"); + } else { + fprintf(stderr, "A status client disappeared, removing it: %s\n", strerror(errno)); + } + ret = -1; + break; + } + count -= (size_t)n; + buf = (char*)buf + n; + } + return ret; +} + +/* + * This must be called after acquiring the mutex + * for the msglock structure + */ +static void send_notify_msg(ipc_message *msg) +{ + struct notify_conn *conn, *tmp; + int ret; + + SIMPLEQ_FOREACH_SAFE(conn, ¬ify_conns, next, tmp) { + ret = write_notify_msg(msg, conn->sockfd); + if (ret < 0) { + close(conn->sockfd); + SIMPLEQ_REMOVE(¬ify_conns, conn, + notify_conn, next); + free(conn); + } + } +} + static void network_notifier(RECOVERY_STATUS status, int error, int level, const char *msg) { int len = msg ? strlen(msg) : 0; struct msg_elem *newmsg = (struct msg_elem *)calloc(1, sizeof(*newmsg) + len + 1); struct msg_elem *oldmsg; + ipc_message ipcmsg; if (!newmsg) return; @@ -148,6 +206,18 @@ static void network_notifier(RECOVERY_STATUS status, int error, int level, const SIMPLEQ_INSERT_TAIL(¬ifymsgs, newmsg, next); + + ipcmsg.magic = IPC_MAGIC; + ipcmsg.type = NOTIFY_STREAM; + memset(ipcmsg.data.msg, 0, sizeof(ipcmsg.data.msg)); + + strncpy(ipcmsg.data.notify.msg, newmsg->msg, + sizeof(ipcmsg.data.notify.msg) - 1); + ipcmsg.data.notify.status = newmsg->status; + ipcmsg.data.notify.error = newmsg->error; + ipcmsg.data.notify.level = newmsg->level; + send_notify_msg(&ipcmsg); + pthread_mutex_unlock(&msglock); } @@ -366,7 +436,8 @@ void *network_thread (void *data) struct sockaddr_un cliaddr; ipc_message msg; int nread; - struct msg_elem *notification; + struct msg_elem *notification, *tmp; + struct notify_conn *conn; int ret; update_state_t value; struct subprocess_msg_elem *subprocess_msg; @@ -378,6 +449,7 @@ void *network_thread (void *data) } SIMPLEQ_INIT(¬ifymsgs); + SIMPLEQ_INIT(¬ify_conns); SIMPLEQ_INIT(&subprocess_messages); register_notifier(network_notifier); @@ -507,6 +579,60 @@ void *network_thread (void *data) } pthread_mutex_unlock(&msglock); + break; + case NOTIFY_STREAM: + msg.type = ACK; + memset(msg.data.msg, 0, sizeof(msg.data.msg)); + msg.data.status.current = instp->status; + msg.data.status.last_result = instp->last_install; + msg.data.status.error = instp->last_error; + + ret = write(ctrlconnfd, &msg, sizeof(msg)); + msg.type = NOTIFY_STREAM; + if (ret < 0) { + ERROR("Error write notify ack on socket ctrl"); + close(ctrlconnfd); + break; + } + + /* Get first notification from the queue */ + pthread_mutex_lock(&msglock); + notification = SIMPLEQ_FIRST(¬ifymsgs); + + /* Send notify history */ + SIMPLEQ_FOREACH_SAFE(notification, ¬ifymsgs, next, tmp) { + memset(msg.data.msg, 0, sizeof(msg.data.msg)); + + strncpy(msg.data.notify.msg, notification->msg, + sizeof(msg.data.notify.msg) - 1); + msg.data.notify.status = notification->status; + msg.data.notify.error = notification->error; + msg.data.notify.level = notification->level; + + ret = write_notify_msg(&msg, ctrlconnfd); + if (ret < 0) { + pthread_mutex_unlock(&msglock); + ERROR("Error write notify history on socket ctrl"); + close(ctrlconnfd); + break; + } + } + + /* + * Save the new connection to send notifications to + */ + conn = (struct notify_conn *)calloc(1, sizeof(*conn)); + if (!conn) { + pthread_mutex_unlock(&msglock); + ERROR("Out of memory, skipping..."); + close(ctrlconnfd); + pthread_mutex_unlock(&stream_mutex); + continue; + } + conn->sockfd = ctrlconnfd; + SIMPLEQ_INSERT_TAIL(¬ify_conns, conn, next); + pthread_mutex_unlock(&msglock); + break; case SET_AES_KEY: #ifndef CONFIG_PKCS11 diff --git a/include/network_ipc.h b/include/network_ipc.h index 1a3d957..f370ccf 100644 --- a/include/network_ipc.h +++ b/include/network_ipc.h @@ -37,7 +37,8 @@ typedef enum { SET_UPDATE_STATE, /* set bootloader ustate */ GET_UPDATE_STATE, REQ_INSTALL_EXT, - SET_VERSIONS_RANGE + SET_VERSIONS_RANGE, + NOTIFY_STREAM } msgtype; /* @@ -80,6 +81,12 @@ typedef union { int error; char desc[2048]; } status; + struct { + int status; + int error; + int level; + char msg[2048]; + } notify; struct { struct swupdate_request req; unsigned int len; /* Len of data valid in buf */ @@ -122,6 +129,8 @@ int ipc_send_data(int connfd, char *buf, int size); void ipc_end(int connfd); int ipc_get_status(ipc_message *msg); int ipc_get_status_timeout(ipc_message *msg, unsigned int timeout_ms); +int ipc_notify_connect(void); +int ipc_notify_receive(int *connfd, ipc_message *msg); int ipc_postupdate(ipc_message *msg); int ipc_send_cmd(ipc_message *msg); diff --git a/ipc/network_ipc.c b/ipc/network_ipc.c index 767079d..5ccc18b 100644 --- a/ipc/network_ipc.c +++ b/ipc/network_ipc.c @@ -163,6 +163,85 @@ int ipc_get_status_timeout(ipc_message *msg, unsigned int timeout_ms) return ret == 0 ? sizeof(*msg) : -1; } +static int __ipc_start_notify(int connfd, ipc_message *msg, unsigned int timeout_ms) +{ + fd_set fds; + struct timeval tv; + + memset(msg, 0, sizeof(*msg)); + msg->magic = IPC_MAGIC; + msg->type = NOTIFY_STREAM; + + if (write(connfd, msg, sizeof(*msg)) != sizeof(*msg)) + return -1; + + if (timeout_ms) { + FD_ZERO(&fds); + FD_SET(connfd, &fds); + + /* + * Invalid the message + * Caller should check it + */ + msg->magic = 0; + + tv.tv_sec = 0; + tv.tv_usec = timeout_ms * 1000; + if ((select(connfd + 1, &fds, NULL, NULL, &tv) <= 0) || + !FD_ISSET(connfd, &fds)) + return -ETIMEDOUT; + } + + return -(read(connfd, msg, sizeof(*msg)) != sizeof(*msg)); +} + +int ipc_notify_connect(void) +{ + int ret; + int connfd; + ipc_message msg; + + connfd = prepare_ipc(); + if (connfd < 0) + return -1; + + /* + * Initialize the notify stream + */ + ret = __ipc_start_notify(connfd, &msg, 0); + if (ret || msg.type != ACK) { + fprintf(stdout, "Notify connection handshake failed..\n"); + close(connfd); + return ret; + } + + return connfd; +} + +int ipc_notify_receive(int *connfd, ipc_message *msg) +{ + int ret = read(*connfd, msg, sizeof(*msg)); + + if (ret == -1 && (errno == EAGAIN || errno == EINTR)) + return 0; + + if (ret != sizeof(*msg)) { + fprintf(stdout, "Connection closing..\n"); + close(*connfd); + *connfd = -1; + return -1; + } + + if (msg->magic != IPC_MAGIC) { + fprintf(stdout, "Connection closing, invalid magic...\n"); + close(*connfd); + *connfd = -1; + return -1; + } + + return ret; +} + int ipc_inst_start_ext(void *priv, ssize_t size) { int connfd; diff --git a/mongoose/mongoose_interface.c b/mongoose/mongoose_interface.c index 2e9416b..1878101 100644 --- a/mongoose/mongoose_interface.c +++ b/mongoose/mongoose_interface.c @@ -141,31 +141,44 @@ static void broadcast(struct mg_mgr *mgr, char *str) static void *broadcast_message_thread(void *data) { + int fd = -1; + for (;;) { ipc_message msg; - int ret = ipc_get_status(&msg); + int ret; - if (!ret && strlen(msg.data.status.desc) != 0) { + if (fd < 0) + fd = ipc_notify_connect(); + /* + * if still fails, try later + */ + if (fd < 0) { + sleep(1); + continue; + } + + ret = ipc_notify_receive(&fd, &msg); + if (ret != sizeof(msg)) + return NULL; + + if (strlen(msg.data.notify.msg) != 0) { struct mg_mgr *mgr = (struct mg_mgr *) data; char text[4096]; char str[4160]; - snescape(text, sizeof(text), msg.data.status.desc); + snescape(text, sizeof(text), msg.data.notify.msg); snprintf(str, sizeof(str), - "{\r\n" - "\t\"type\": \"message\",\r\n" - "\t\"level\": \"%d\",\r\n" - "\t\"text\": \"%s\"\r\n" - "}\r\n", - (msg.data.status.error) ? 3 : 6, /* RFC 5424 */ - text); + "{\r\n" + "\t\"type\": \"message\",\r\n" + "\t\"level\": \"%d\",\r\n" + "\t\"text\": \"%s\"\r\n" + "}\r\n", + msg.data.notify.level, /* RFC 5424 */ + text); broadcast(mgr, str); - continue; } - - usleep(50 * 1000); } return NULL;