From patchwork Fri Aug 18 08:27:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 803089 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4010:c07::238; helo=mail-lf0-x238.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbtwk3lgakgqeujqqnli@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="m7UNs7dG"; dkim-atps=neutral Received: from mail-lf0-x238.google.com (mail-lf0-x238.google.com [IPv6:2a00:1450:4010:c07::238]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xYbpV4dGzz9t2c for ; Fri, 18 Aug 2017 18:29:05 +1000 (AEST) Received: by mail-lf0-x238.google.com with SMTP id 87sf1528685lfy.0 for ; Fri, 18 Aug 2017 01:29:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1503044943; cv=pass; d=google.com; s=arc-20160816; b=DS9guRSJZjGOZWR0fnRxSwoG34qecQoP1jHN3B9AKogEB50q6kUvf82ZA8+74loY77 Ct8SLMySYyLHW2QBAW2SqoSsqUa/JI0OYfFD4ZhNia9OfLuM67V6gR9jCpoj5iDr/xqh XJyaywk7XOwInxYV86dTwbq8wS0ngvuhfm7fMJre+Taus+5mnbVjLRXkf5T99Z2HAugb /qr7noLeaPgfqvuTYfaRqwd35o5bK0tBxQE3YPVKh3zFuHYNwl0bZraPdnmW8jbynDry hG4RyD3R7pNxf4O+PhVr0U9J9XvboZIfWYMuAxMvQbdMMX17lEQVW1DcxyF7EtKlCF5K Qx6Q== 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:message-id:date:subject:cc:to:from :arc-authentication-results:arc-message-signature:mime-version :sender:dkim-signature:arc-authentication-results; bh=kpvG4FiYUc07Cc8KSdQci+tClrwCUlgyi6n2W+gQqUU=; b=VgYTbTKvM0SA8cauCGImrtgOx5KSHgNUEN7dw7/zd1RGSqFzMIrF6jkvTcDWGkj4CQ BEG8ejZRiqqgIfr1uOQw54cDweY/ufpRoziIWy3P/pI7ZM3RlBIZdV/3/CBhps7PM+pL 0caqY+5QRmV9T2Dr/P4R/vgU5WlAGsEDy02my3FCrdslgK+OBkkClpWdcOvLX9QDcHW0 0KrU/0as3fSSavoC1a4+loCt7QS+NZLK7YrFQGcGxGYU048JrCZjplTu68INtSYOqGn8 DfvFfWIIhorw+SFAvrZniIinRY5b2bwmw0powR8XyMjXjStnzyAHRXtr9+gbOlPGLMlv 9dgQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 192.35.17.14 is neither permitted nor denied by best guess record for domain of christian.storm@siemens.com) smtp.mailfrom=christian.storm@siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:cc:subject:date:message-id :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=kpvG4FiYUc07Cc8KSdQci+tClrwCUlgyi6n2W+gQqUU=; b=m7UNs7dGKzOppdnYL8qyBNRTSb5cJUyKY2VEJFQOeP/pJd1Dbr0IQudIxQKHf2Z26b lBqq4jMZNh12umvEcyMNeEDoP51kiBtt2LWPeBUZYs5S2C7ybP/zvz8+ttOdFEffrpiO yR5WFdC3pMrzz30J6apRMagv+vIvtUTpBmnqvAOmixEXCxBHQjlnxzhtQvMoHB1ZC04Y jAiZzXNMaf01qR++IJc1GSzoMbYNrs2Fr66FtJMA0sKqWotiayjVyuRSn3S3FCMVfH25 B1PV3lciHxy5xSD6UrlyHlIJ0qLSmFtGSy5cfoyqPhUIJ7jcZC+bhp6awdfBmmt8tx37 9kzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id: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=kpvG4FiYUc07Cc8KSdQci+tClrwCUlgyi6n2W+gQqUU=; b=R6XL2Qh6t6RRIWHK5VRWGzX/pvsj/NzhjI1O+dRnYO9pbiC3YhhOVGPXlLtouWxlVA kEHERXXVbU47h8qYI3Xq0RpNV7A6xT2/ps3jCCi9ULBcy6eN9qKWdUsj91540Kh4R1S3 5gXgZeeTqGypk2Vd9cIx26wkTpCM39s/hhswDGSKtGpCf3WUfJfTLQMoEimASHUt496r yx0RFZX0g0iEn9c1YKabJ3wWzg2cbFqiG7G31Z8oHmJ/krj4i60VJ45prkXds3jeHMy1 zDVjVpgYVqmIG9kNTxcqBJpatLzYUDoPD/hf2d54bm9MdCu5OOMbIFCOh1k1AVAbScqm dmOQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AHYfb5ivitVl/b2qBiQIOjKB5DwwE0qn0HeHJEzUwnO60GZkK9zZHo8Q /T9GaBIYqhTOPw== X-Received: by 10.25.67.69 with SMTP id m5mr5059lfj.23.1503044943095; Fri, 18 Aug 2017 01:29:03 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.46.19.17 with SMTP id 17ls164899ljt.2.gmail; Fri, 18 Aug 2017 01:29:02 -0700 (PDT) X-Received: by 10.46.87.78 with SMTP id r14mr1236835ljd.29.1503044942458; Fri, 18 Aug 2017 01:29:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503044942; cv=none; d=google.com; s=arc-20160816; b=MQNzt2928qqOzvsDt/nURS4tzcRQU7q1JPzkcidlaJdLguFTkqG596/0B7Z6EDkG89 QKhDq5QpJyE0OPyb1FiXAgMzXZxTnBwTV64562cdEvT3GQHAqJZucl6sMtwGMdPDaYNa fsLYYU5wenoSobbPL9sRauAqtZNlfXgNp0dkHwghf38CruBTd1e31D4059pM6N4Kw7/B tByPHkLWkTdCC4PbgvHxk3+ljkD0dwHmY16OC7p5wHSHar8MOBJEi7oJbISYQkaotRha ZZmt1zQGZDGoXdQo7RJAH9H/GzjxZ4OBaUjeqiohjQZSzcIsEueauLb8afL9z3Vo03i5 svBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=9USukjxCdTRZaDO4TDuCq2pneaOPsm+40W/lK31Hf58=; b=cphR5n7uutw0UdYMDLw3hqUQ3WQL13jk9MUd/7oBF7KNQ51tcKP7osJB6xK8XlnlvT /HVFxIhJhUi0cSWbFZltDzbHsenTnl5vQzjQyanrbMGrML46WNnu1SKll4Zov38nLBcR krJ6Tw2tIwxJuEqjNyGt7wmvFBGiwbeih7ff5OGVej4/Dqe+JotPv6Vs7sQa1Y5m/UZY iiWoLNY4RPVUBulVNnMdfwzwwt0IEQNZ8b5NdP4T6CTdt1xCcQUqZgd4Cv4DHkQtSZ/o z4O5t3PlYSxzcq9/amP+dFWLYFffbXbp8vo5jTdb6rJ2kgJCDkWZjQJH2TQ5e8cjyb8m nqTQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 192.35.17.14 is neither permitted nor denied by best guess record for domain of christian.storm@siemens.com) smtp.mailfrom=christian.storm@siemens.com Received: from david.siemens.de (david.siemens.de. [192.35.17.14]) by gmr-mx.google.com with ESMTPS id x63si341519wmf.8.2017.08.18.01.29.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Aug 2017 01:29:02 -0700 (PDT) Received-SPF: neutral (google.com: 192.35.17.14 is neither permitted nor denied by best guess record for domain of christian.storm@siemens.com) client-ip=192.35.17.14; Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by david.siemens.de (8.15.2/8.15.2) with ESMTPS id v7I8T2Dt010813 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 18 Aug 2017 10:29:02 +0200 Received: from MD1KR9XC.ww002.siemens.net ([139.25.68.253]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id v7I8T1IB031894; Fri, 18 Aug 2017 10:29:01 +0200 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH resent] suricatta: enable IPC to signal wait abort Date: Fri, 18 Aug 2017 10:27:04 +0200 Message-Id: <20170818082704.11873-1-christian.storm@siemens.com> X-Mailer: git-send-email 2.14.1 X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 192.35.17.14 is neither permitted nor denied by best guess record for domain of christian.storm@siemens.com) smtp.mailfrom=christian.storm@siemens.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: , Allow aborting suricatta_wait() via IPC by server_ipc() returning SERVER_OK_WAKEUP. Signed-off-by: Christian Storm --- include/network_ipc.h | 3 ++- include/suricatta/suricatta.h | 1 + suricatta/server_hawkbit.c | 23 ++++++++++------------- suricatta/suricatta.c | 6 +++++- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/include/network_ipc.h b/include/network_ipc.h index e0d6672..9cd947b 100644 --- a/include/network_ipc.h +++ b/include/network_ipc.h @@ -37,7 +37,8 @@ typedef enum { enum { CMD_ACTIVATION, - CMD_CONFIG + CMD_CONFIG, + CMD_WAKEUP }; typedef union { diff --git a/include/suricatta/suricatta.h b/include/suricatta/suricatta.h index c04aff4..2419d8c 100644 --- a/include/suricatta/suricatta.h +++ b/include/suricatta/suricatta.h @@ -44,6 +44,7 @@ typedef enum { typedef enum { SERVER_OK, + SERVER_OK_WAKEUP, SERVER_EERR, SERVER_EBADMSG, SERVER_EINIT, diff --git a/suricatta/server_hawkbit.c b/suricatta/server_hawkbit.c index 605733f..6550835 100644 --- a/suricatta/server_hawkbit.c +++ b/suricatta/server_hawkbit.c @@ -871,6 +871,7 @@ static server_op_res_t handle_feedback(int action_id, server_op_res_t result, switch (result) { case SERVER_OK: + case SERVER_OK_WAKEUP: case SERVER_ID_REQUESTED: case SERVER_UPDATE_CANCELED: case SERVER_NO_UPDATE_AVAILABLE: @@ -1193,6 +1194,7 @@ server_op_res_t server_install_update(void) case SERVER_UPDATE_AVAILABLE: case SERVER_ID_REQUESTED: case SERVER_OK: + case SERVER_OK_WAKEUP: break; case SERVER_EERR: case SERVER_EBADMSG: @@ -1916,12 +1918,11 @@ static server_op_res_t server_configuration_ipc(ipc_message *msg) server_op_res_t server_ipc(int fd) { ipc_message msg; - server_op_res_t result = SERVER_OK; - int ret; + server_op_res_t result; - ret = read(fd, &msg, sizeof(msg)); - if (ret != sizeof(msg)) + if (read(fd, &msg, sizeof(msg)) != sizeof(msg)) { return SERVER_EERR; + } switch (msg.data.instmsg.cmd) { case CMD_ACTIVATION: @@ -1930,23 +1931,19 @@ server_op_res_t server_ipc(int fd) case CMD_CONFIG: result = server_configuration_ipc(&msg); break; + case CMD_WAKEUP: + result = SERVER_OK_WAKEUP; + break; default: result = SERVER_EERR; break; } - if (result == SERVER_EERR) { - msg.type = NACK; - } else - msg.type = ACK; - + msg.type = (result == SERVER_EERR) ? NACK : ACK; msg.data.instmsg.len = 0; - if (write(fd, &msg, sizeof(msg)) != sizeof(msg)) { TRACE("IPC ERROR: sending back msg"); } - /* Send ipc back */ - - return SERVER_OK; + return result; } diff --git a/suricatta/suricatta.c b/suricatta/suricatta.c index b520978..e1b161b 100644 --- a/suricatta/suricatta.c +++ b/suricatta/suricatta.c @@ -47,7 +47,11 @@ int suricatta_wait(int seconds) } if (retval && FD_ISSET(sw_sockfd, &readfds)) { TRACE("Suricatta woke up for IPC at %ld seconds", tv.tv_sec); - if (server.ipc(sw_sockfd) != SERVER_OK){ + server_op_res_t result = server.ipc(sw_sockfd); + if (result == SERVER_OK_WAKEUP) { + return 0; + } + if (result != SERVER_OK){ DEBUG("Handling IPC failed!"); } return (int)tv.tv_sec;