From patchwork Tue Jul 11 19:04:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ron Brash X-Patchwork-Id: 786819 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3x6Wjh2kMmz9s7C for ; Wed, 12 Jul 2017 05:04:56 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="TlqQnYTC"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OX/JtUH6"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:To:Message-ID:Date:From: MIME-Version:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=Mlk0DGIT1SKzgN8/efsHDyfrda1wWfPx9DBQZxzMv4k=; b=Tlq QnYTC3C3im1gJ/vJOzDrAovIynygjQXkdfijXGsH45RkOQrC4vglrqBSAzvia/g/MJSM5Orr5jSvV RSx/T/PXw9kj6C09+DAxzB2O9eXNXtJPsUzhUdbpaQ4f9qNau++idbwRYbChVztvzioOGCdFSEtDu aDxiaH03xIGsoU6DFKBgXafk2o/ftK2uJxXu3trMrPoE9q+/umNfaqkDnGbWvJY6MPPCGYO4jPc1x UheeQTx0qDneDPtpqSSfTPya+rMAxqpXGNDQ/BYtux3odwqU9Se2WdBHdpVrbBmG9Z1PxpWGoFAW0 5i2zub+8h1++wksDgzDAMJAtV8hbA7w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dV0Sb-0006tJ-19; Tue, 11 Jul 2017 19:04:37 +0000 Received: from mail-qk0-x242.google.com ([2607:f8b0:400d:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dV0SX-0006sW-I5 for lede-dev@lists.infradead.org; Tue, 11 Jul 2017 19:04:35 +0000 Received: by mail-qk0-x242.google.com with SMTP id 16so184111qkg.2 for ; Tue, 11 Jul 2017 12:04:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=3bCiv1F+IV8EJfEA4A2wXTPTHoDp6ytBn1kK7ziK3+4=; b=OX/JtUH60f2WpkLHmlne1Cgso9zdHsbzWeWPKpw8gL7Rl7cvwkcjUkmjRXx0CSexbt Ookt518LOPABJCfkCHEqfCyY3ylsO5REd6kd2qxxxwotTi6RCFst2CIqiCq0XSfz7lgJ PQoeGT2fNPLC43SZQayYU6tut5FY3Z49e9Wf071N/N6IHtq4s/sKoLc3YSAh2TpZZIba lpqjODP+4OFOcC8FUpAlBSHnUNop8O39bnYYNSQAnNiNVjgoraEnui7Cnb+EVtHaGroS f5MpEdBfqnvCIOPhME9hmOc13YOd3B6pjrWjqGsh5byUFstObCV2xw0BGLU1GLnk3YbF wNEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=3bCiv1F+IV8EJfEA4A2wXTPTHoDp6ytBn1kK7ziK3+4=; b=RGs03IeuefB6u6vWElvKil1ZpRDfGRDX5/CPvrZQvsxfC+NiGjpGYeD+4pww23X0CU 4A8wln6xQHhMHsgCxk8cF0ka72Vg8oS+GwBtfhenv5p/Lt1M0XsrE7oZtitIpOzFEo81 lWJ7FtHs86k9VZCVgK6sIfv6DXcm81UAXcc8qUvXYmZu6BySnZtNu3EFzWFITtLDjHJo Lw2CTI/LoaOPcL+gVM7NGxwo/n3Lmgt2zlUbrSrauW/+bsJK18gSrVUBIAfcWhH3vNwq vkK2r6MrhvtDCHjHETiHZ/tE7006nH1xU81jn1hBb9v6rDwPXz0igDV88BdMc1sr6Wvv xIDg== X-Gm-Message-State: AIVw110viOo5vZtw1qRVS7UtpqiD82hgA9J5EuVCwiiaNBjPByoKvdNA Zrdc+IZ/3xZruAjo8hKsYFwRMVDnl/c5 X-Received: by 10.55.207.85 with SMTP id e82mr1711100qkj.235.1499799848937; Tue, 11 Jul 2017 12:04:08 -0700 (PDT) MIME-Version: 1.0 Received: by 10.237.56.130 with HTTP; Tue, 11 Jul 2017 12:04:08 -0700 (PDT) From: Ron Brash Date: Tue, 11 Jul 2017 15:04:08 -0400 Message-ID: To: lede-dev@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170711_120433_732069_75BE70E2 X-CRM114-Status: UNSURE ( 8.97 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2607:f8b0:400d:c09:0:0:0:242 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ron.brash[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain Subject: [LEDE-DEV] [PATCH][ubox] Fixes log read starvation issue after threshold reached X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This patch fixes a logread starvation error, which occurs after many logs are generated (around 16k if defaults are used). The log read process seems to halt silently and yet continues running. A restart of the log services fixes it. This is problematic because logs should be logged, instead of silently lost Signed-off-by: “Ron Brash <“ron.brash@gmail.com”> --- log/logread.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) ustream_consume(s, cur_len); @@ -240,14 +242,28 @@ static void logread_fd_data_cb(struct ustream *s, int bytes) uloop_end(); } +static void notify_fd_remove_cb(); + static void logread_fd_cb(struct ubus_request *req, int fd) { static struct ustream_fd test_fd; - + uloop_register_notify_fd_remove(fd, notify_fd_remove_cb); test_fd.stream.notify_read = logread_fd_data_cb; ustream_fd_init(&test_fd, fd); } +struct ubus_context *context; +uint32_t ctx_id; +struct blob_buf * bb; +struct ubus_request request; + +static void notify_fd_remove_cb() { + ubus_lookup_id(context, "log", &ctx_id); + ubus_invoke_async(context, ctx_id, "read", bb->head, &request); + request.fd_cb = logread_fd_cb; + ubus_complete_request_async(context, &request); +} + int main(int argc, char **argv) { static struct ubus_request req; @@ -362,6 +378,9 @@ int main(int argc, char **argv) sender.fd = STDOUT_FILENO; } + context = ctx; + bb = &b; + ubus_invoke_async(ctx, id, "read", b.head, &req); req.fd_cb = logread_fd_cb; ubus_complete_request_async(ctx, &req); @@ -374,3 +393,4 @@ int main(int argc, char **argv) return ret; } + -- 2.7.4 diff --git a/log/logread.c b/log/logread.c index edac1d9..7eb028e 100644 --- a/log/logread.c +++ b/log/logread.c @@ -230,8 +230,10 @@ static void logread_fd_data_cb(struct ustream *s, int bytes) break; cur_len = blob_len(a) + sizeof(*a); - if (len < cur_len) + if (len < cur_len) { + ustream_consume(s, len); break; + } log_notify(a);