From patchwork Mon Sep 14 14:56:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 1363672 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::338; helo=mail-wm1-x338.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbrmj735akgqexsamugy@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=siemens.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=p20RecWM; dkim-atps=neutral Received: from mail-wm1-x338.google.com (mail-wm1-x338.google.com [IPv6:2a00:1450:4864:20::338]) (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 4BqqG51412z9sVt for ; Tue, 15 Sep 2020 00:57:15 +1000 (AEST) Received: by mail-wm1-x338.google.com with SMTP id m125sf83515wmm.7 for ; Mon, 14 Sep 2020 07:57:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1600095430; cv=pass; d=google.com; s=arc-20160816; b=FnCnvuddJPMcgY09YQw5UUO61uqPwxpqsTRCiiMGUb46nBgHVMjd98XZONL8HluFJ9 X0ZfF7vHDc/BWoxu4n7jcodTydE42Oy1vcP5ZxHTgZTiOfNaYAqzKOssc84M+5+tlBjd /uYWa/KGoaMqZPdgoJHWZUJyinXPaIU2jbNcDdgRDW2/XVdFzAoQQ3t6odJ8hQtAqFj1 1xkQRMkvPebL8xlexzUi0ZApqsQqBmiBrDe2prxTizsTV3lVD4cPjDJ/tncxjQqBnpuk pSt+MAJj3jomUXYwONDQmW+r5XR2h6b7micY3RSFZReGPyPaucTHbcyjxyKpB7mpEb7B gaTA== 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; bh=7CsuwleomdBPnuuKXGRvbepzHIIvg4l/aXEgJtyN2O0=; b=OUhaKpZuK27EXjbCV0eoq+AV+sh3kz9QukenZiD6smTRZIMxxmKzFF6XS0jXt0VCsl +DQAcogzG+SAwK+yRYjYPHdmE7LwCQcadje+2wB9kBtaE014DSj9cgZ/ATQkW4etyuLD QcBOi9Sv55EBpTA6gDAShOQnRbSTxfPPQfT2XEMhFIhOAi7LaUXKvzQ5E6lEf5tB2u13 1/4coSMIz2wq+3XzQFDwvVleTT7tORzdHz3gYIOherWH2gL4k4QXlU4WiNAI250uQm5x OxLb+3ESoMS3DgLoyVzjtIIW8GSQCowBaQazgTJkOCkR/horKR9BWLIdxGsp6Xt/DOsx JzhA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; 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=7CsuwleomdBPnuuKXGRvbepzHIIvg4l/aXEgJtyN2O0=; b=p20RecWMk20xuU/vK3GiZEWouSBeIwdE2m4YE4Ykh4ItYX1GMhFw/e5i5vHfp8LgiB RQGM7b/sDUGBdpG6twddtPGs1wSkOnPqvuUIcJd57knaL2gZC7E7rXWGoFWTOAvzht2W VYkVho7kOkWm5lyzj8QqvqXu4sQdzaWTK2IyfMuKVybWk7K1nCWXxCdoCQapM9OtnOwz fNxokaCUyoHotG9OZAmBVQJ8r+XNWe4cw3oxweEGJBD5cuVDx5ZTXQGU31Cc6GOqfESI 2FZv6euTpf229dowMtYiFvCynQ6pD5953daXl+pRVfgQe8CuOfxK4IfWJARAWrY2ErLQ dW7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; 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=7CsuwleomdBPnuuKXGRvbepzHIIvg4l/aXEgJtyN2O0=; b=Cf6jJ2Gtt2nNabjSiCGK2iUqpntAL1p3PWfbsxwQb+fuxyF4i2THcJa7V8NwqmEXGI DLeGxnO7UhujdBiAmljflSO1z48IoQb8xI4e0ftB9Xz0nRlClWyW1vPa4Zq7elr4+yL1 YdhAfsICSH4ZLV8i196iFoxwMdYV7GnTBrctLB4RZ1MT40Ry2A63u8Z64zsawOmIB6yX ZnjreCA36p3FEUPK0y5s1FmJDrd8ZqeX/p/ZvoG/WK0C4k9gZ2WEnLk0mvPA4PcHamf4 gX+RP8JjnmoANbGZysLkEND5qAy09wac9HvkqKO1RDDjshxZ1PyYOLhndsnenwW2mzL+ bkbw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM530RqMcIDRWaa6ufhNw2FrF/LoskycEzHEXA4jfBJB1X9DE6vtXl t+vCpy337ctYj90srEbUHmA= X-Google-Smtp-Source: ABdhPJzBvnFI/XmtxdgDrilkJfMKQjV+THKUkkgY6dDXLKtqSsfmW6Qrw7DaH4PC3Fn+gKe44TAm3g== X-Received: by 2002:adf:f24f:: with SMTP id b15mr17582081wrp.301.1600095429933; Mon, 14 Sep 2020 07:57:09 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a7b:c768:: with SMTP id x8ls2375120wmk.2.gmail; Mon, 14 Sep 2020 07:57:08 -0700 (PDT) X-Received: by 2002:a7b:c151:: with SMTP id z17mr16158531wmi.53.1600095428835; Mon, 14 Sep 2020 07:57:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600095428; cv=none; d=google.com; s=arc-20160816; b=wZrxCREi0G0hqqFS1VuIxVxeI7kgYAwZc5B8ndj0omSCmFsT746VI+KdTo13BPbTdl zGu5SPcg6tSurPnOG2p7gpJIGHFq6ielh9aKqvoC7VeWK0Jylvi9cIMhOzWLg89zc4bc OTRlmLH54C+fPqvSKWff9sDUNi0cn5kqfDgkyioZ1IuiNRKswSkIS5e6DCd315SJGn4K SMh4ZpeDZWHSujHzgDzSUgLVkweW4sX4BbX4nwlezcI+MqIxnPdaPMaK07cQYKTB63ro 5xDbLemg2iCs32Q2LtPt9g4yPPzmXL72ylzk3n+aRJJZgNukVaaKSYy/cFDdMLOwl2qN KYjA== 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; bh=gPJ+oaTTrTOL5K2gCrl9gb1LrKHmQtT/MEHgjC2olYc=; b=sTOUWLMsxouQX/cnXEe5ZYIlo8LAvxLfduIHRXVtNhuqJqyy8r+Sry+TddkR6gLwur jBnNrBIU6GpnqaD7xs/FJ4/Chn5/nHrM1SxkHzY6cKUtL5nT2SmFmDvT+rf4jJaSznUy lmweapLX01gdOLi9ggXD1FzvZUIh5+nZ8wJmVwdY+Gb1gzZdng/CWfz3/0Oo6RdVWh9/ nFfZ3GnqMQhvjS9VwUt9t02a1hBoVBwHL6ZlETEmqUmWZVogFIGkqpgc2AVnBOsiphG6 p+cfwK58SLQASJXQRvWXBH8ThDEj67v8O1ZBNmcaVy9ADPN/xCcgX6e5zhvVSPgbLvte Zzww== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from david.siemens.de (david.siemens.de. [192.35.17.14]) by gmr-mx.google.com with ESMTPS id b1si326093wmj.1.2020.09.14.07.57.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Sep 2020 07:57:08 -0700 (PDT) Received-SPF: pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) 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 08EEv8Vk004418 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 14 Sep 2020 16:57:08 +0200 Received: from MD1ZFJVC.ad001.siemens.net ([139.22.42.140]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id 08EEv7pI008872; Mon, 14 Sep 2020 16:57:07 +0200 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH 01/14] channel_curl: Make setting request_body symmetric Date: Mon, 14 Sep 2020 16:56:59 +0200 Message-Id: <20200914145712.4989-1-christian.storm@siemens.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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: , Setting channel_data->request_body is done inside the channel_put_method() function while for channel_post_method(), it's done in channel_set_options(). Harmonize this by setting channel_data->request_body inside the respective functions. Signed-off-by: Christian Storm Reviewed-by: Stefano Babic --- corelib/channel_curl.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 48e6853..02d8dff 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -634,16 +634,6 @@ channel_op_res_t channel_set_options(channel_t *this, } break; case CHANNEL_POST: - if ((curl_easy_setopt(channel_curl->handle, CURLOPT_POST, 1L) != - CURLE_OK) || - (curl_easy_setopt(channel_curl->handle, CURLOPT_POSTFIELDS, - channel_data->request_body) != CURLE_OK)) { - result = CHANNEL_EINIT; - goto cleanup; - } - if (channel_data->debug) { - TRACE("Posted: %s", channel_data->request_body); - } break; } @@ -743,6 +733,17 @@ static channel_op_res_t channel_post_method(channel_t *this, void *data) goto cleanup_header; } + if ((curl_easy_setopt(channel_curl->handle, CURLOPT_POST, 1L) != CURLE_OK) || + (curl_easy_setopt(channel_curl->handle, CURLOPT_POSTFIELDS, + channel_data->request_body) != CURLE_OK)) { + result = CHANNEL_EINIT; + ERROR("Set channel option failed."); + goto cleanup_header; + } + if (channel_data->debug) { + TRACE("Posted to %s: %s", channel_data->url, channel_data->request_body); + } + CURLcode curlrc = curl_easy_perform(channel_curl->handle); if (curlrc != CURLE_OK) { ERROR("Channel put operation failed (%d): '%s'", curlrc, From patchwork Mon Sep 14 14:57:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 1363670 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::43d; helo=mail-wr1-x43d.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbruj735akgqek45jvci@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=siemens.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=j/B81Hxn; dkim-atps=neutral Received: from mail-wr1-x43d.google.com (mail-wr1-x43d.google.com [IPv6:2a00:1450:4864:20::43d]) (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 4BqqG50sWvz9sVq for ; Tue, 15 Sep 2020 00:57:15 +1000 (AEST) Received: by mail-wr1-x43d.google.com with SMTP id y3sf7001603wrl.21 for ; Mon, 14 Sep 2020 07:57:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1600095431; cv=pass; d=google.com; s=arc-20160816; b=yrnostuSMDQYg7WW8pRMQTmN1NRLkt7Bmb5z//XUjbV+ZizFDn7rIYJZlgwzN4g1Tw hU4vPBJy1BvroMZKNzQa2+HNXy43u1ozedO3dOshdPCIaUhxHBDC5fU7ch77FwF+wISO U4Kubey26mwYNGY7rnzecjXBS0cWywQ17DoyY5IACoWrPdlE60Hgabq+m3xC8+rmAYnI KtMnzDzBEuIrgjtnE9sDHhH4RkvsRwlf+wtSoUkW4A1i9v+VYlJMreuovbDDr9ZWPRZd YZm4oThZs0n6Ze2ZKwQYpdq/+uLzqMZ/6IIpaLeqKGqOwz0YhCoAWsEtfCG/z8R4l2Uh vY1Q== 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:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=fjycqWwOAB/H67TvNjk2ckz1+bs8tikJXY52JQTTB3U=; b=v0uHAmmT3xSrHVlwcBKtfeVcJ7oSomDvFm9HFxlF4dRREYyT1lpT/h8aMWeH4dPWhq dmkybYIazGg9xLJ0w3A25i3j6uSsZ3ny4OQUmIn/VwMPrRI0Zr5bwiyaZVnszeqKGRiu yUyUzqoW2cCf7WT8gzW0G7skGNff3eWr0lq1v3TGgZfmHjiymAZL/EVaOZ6/v/I4G3R3 WPjYh6CMuUWuPuZrIjYjT5SZi9JDmFHRhBxshcDPTLwns48NSoJCw1uro6X5VrqtAi55 8vckYgcCctS5Mrscl8Q+QC/LhbzdydTlETQ+OjIeZtvHlNQx8ZSQA73oVZ/ec36Rkh3q Gdlw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :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=fjycqWwOAB/H67TvNjk2ckz1+bs8tikJXY52JQTTB3U=; b=j/B81Hxnw3mFO30eH4DpOustmfwVcKQDIGs0oFzK0b5oJpD5G/TtsbBfq1zwzmH83j bRUa+uOsZZbYSjO5RQ7N0KW09DU4CpE97stCbvWpgi+zaJvb1CsjoH7KKVnjspOAhRfN MuZglBhITDD8XYJTZyaGzYOaSliTYLsuhuaWqGtvE6WuC/XmEcOxTA0Ya/wgcXvc0me6 R0ST0Q1TLG/lwYVxXZ2m73G0DyaDfXw5NgIVGY/91sUP2Q1UOwYgGjeT/Qu0SDPc1APK 6vj2M+m/Xnsy60rIE5X81FxQclprmcHv9gwX+IWw6ajAzVBt+xsyyZZjx1D5jLiqmuXs xB7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references: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=fjycqWwOAB/H67TvNjk2ckz1+bs8tikJXY52JQTTB3U=; b=KSzQ/ZQxJraD2CqTsn0dtCWNQAj5L9v02Yny9oalIQRy/1wEnaOJIIouAkNCOAx7RB h0j5CBdBwtdZFxurphqSg0XQSEYIzQFmTHUJzwE15vxZGlzrHi83VDiq2tkY8n27N3o3 lSImVEMcB5DWYV6WQs4aeIdjOhA3k2Cg+w6t3EZT7QNOO7A0twZhzf8AZNLH7/DN6mtY flstp2rhcbS7tdrO7BXmKPmk70WJMvr1YnrjiGleFRm3n2yuB6adHpl/t3M5H9Xw93aK oKPsjMV0z4kz9r/ZeQJmjTMqIbh0X/NcV6h1RE0nXgyKQJ6o1J6YXyKNZLoqIh/gEoNZ ZuZg== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM530TthNv3R4rZ7OzCC+aIq+WgBcIvklUytcqZd++BB3GHi8Pvhhc wqryoxdqep2iaVhXZpzD8N4= X-Google-Smtp-Source: ABdhPJwWwhr9isr4KDlFL2Ip3O3AUe/iOV3dLFV8ACFsFCg9RRuXKler3zUOSJjLgawTHyS/tPV8gA== X-Received: by 2002:a1c:1f41:: with SMTP id f62mr16067412wmf.51.1600095431347; Mon, 14 Sep 2020 07:57:11 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:adf:e3c3:: with SMTP id k3ls8362202wrm.1.gmail; Mon, 14 Sep 2020 07:57:10 -0700 (PDT) X-Received: by 2002:a5d:680b:: with SMTP id w11mr17438458wru.73.1600095430352; Mon, 14 Sep 2020 07:57:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600095430; cv=none; d=google.com; s=arc-20160816; b=B2RT+VFXrsMm6fgkVmbfKWEvbMIjMPX70Lr3CkdecL++JXgOxW6Y6IhFo87uVT8WRb saaRwYT7VJkJPfTOwg4m9tynnELSPsKsQP9CZPk/uQoLZsgWkBodXJT4RsALGEJCvFi8 V01lnubAd3tyWr47r3aJnHUiFFErEhWMgR1MIGlNUI3/AklAXB2hBY4f9gCQbpqEkTD0 ElWRZGINh8tKBJrPf/1m9rcMCOCXShEvXsDT6e00jTLGs+IBUFricamBlydrcBFlEgPi MntPYf2vGG/YCNJ9cq8lfuJhPUqMS8OGBrhBkqhq8anE2wYhC+gE/mubpWh/QDFOSIVm aTFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=TXDms0xtkyiyIX08UEYpYvc5rDtibeKutuaCYl3UDfg=; b=an/IlxIyuU48kS1zVIqvrkUi31VfmAC6QVMy+MHgqjr8nIlHxM64xRg7oWlS0AU8DF ZJ3QceMpIFwjjqQQvXILs66jnMBjI/YhTgpBXe1EJssIlG7JqjMa/OMEPzkuZAc0hIHD nRJFaCNVPQNOV8BBgpGuB4CuPawRyZGFvnTvcE0VZhCaVbNDWMb7Gfesda2tvZnVFcUa qvMIziWwz+UW1YxHp8GpftunT9k27c33Snv1rwFabanJ4DZLurkRTdZUhSFjJl8sMsnB 6pI2iwAcC1OIpevuGvBeCaWH1fPYLpC+OrZY04QZvmPXiWNRwrMmti5ycbHpO3MARz4H s1bg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from goliath.siemens.de (goliath.siemens.de. [192.35.17.28]) by gmr-mx.google.com with ESMTPS id k14si290952wrx.1.2020.09.14.07.57.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Sep 2020 07:57:10 -0700 (PDT) Received-SPF: pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) client-ip=192.35.17.28; Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id 08EEv94F022716 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 14 Sep 2020 16:57:09 +0200 Received: from MD1ZFJVC.ad001.siemens.net ([139.22.42.140]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id 08EEv7pJ008872; Mon, 14 Sep 2020 16:57:09 +0200 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH 02/14] channel_curl: Consolidate curl verbose setting Date: Mon, 14 Sep 2020 16:57:00 +0200 Message-Id: <20200914145712.4989-2-christian.storm@siemens.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914145712.4989-1-christian.storm@siemens.com> References: <20200914145712.4989-1-christian.storm@siemens.com> MIME-Version: 1.0 X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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: , Centralize the curl call to enable VERBOSE curl mode to channel_set_options() instead of the channel_ methods. Signed-off-by: Christian Storm Reviewed-by: Stefano Babic --- corelib/channel_curl.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 02d8dff..ec65581 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -514,6 +514,10 @@ channel_op_res_t channel_set_options(channel_t *this, goto cleanup; } + if (channel_data->debug) { + curl_easy_setopt(channel_curl->handle, CURLOPT_VERBOSE, 1L); + } + if ((!channel_data->nofollow) && (curl_easy_setopt(channel_curl->handle, CURLOPT_FOLLOWLOCATION, 1) != CURLE_OK)) { @@ -717,10 +721,6 @@ static channel_op_res_t channel_post_method(channel_t *this, void *data) channel_op_res_t result = CHANNEL_OK; channel_data_t *channel_data = (channel_data_t *)data; - if (channel_data->debug) { - curl_easy_setopt(channel_curl->handle, CURLOPT_VERBOSE, 1L); - } - if ((result = channel_set_content_type(this, channel_data)) != CHANNEL_OK) { ERROR("Set content-type option failed."); @@ -783,10 +783,6 @@ static channel_op_res_t channel_put_method(channel_t *this, void *data) channel_data_t *channel_data = (channel_data_t *)data; channel_data->offs = 0; - if (channel_data->debug) { - curl_easy_setopt(channel_curl->handle, CURLOPT_VERBOSE, 1L); - } - if ((result = channel_set_content_type(this, channel_data)) != CHANNEL_OK) { ERROR("Set content-type option failed."); @@ -875,10 +871,6 @@ channel_op_res_t channel_get_file(channel_t *this, void *data) } } - if (channel_data->debug) { - curl_easy_setopt(channel_curl->handle, CURLOPT_VERBOSE, 1L); - } - if (((channel_curl->header = curl_slist_append( channel_curl->header, "Content-Type: application/octet-stream")) == NULL) || @@ -1064,9 +1056,6 @@ channel_op_res_t channel_get(channel_t *this, void *data) channel_data_t *channel_data = (channel_data_t *)data; channel_data->http_response_code = 0; - if (channel_data->debug) { - curl_easy_setopt(channel_curl->handle, CURLOPT_VERBOSE, 1L); - } if ((result = channel_set_content_type(this, channel_data)) != CHANNEL_OK) { From patchwork Mon Sep 14 14:57:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 1363674 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::23b; helo=mail-lj1-x23b.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbsej735akgqexnf2q7q@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=siemens.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=YKtK1oBX; dkim-atps=neutral Received: from mail-lj1-x23b.google.com (mail-lj1-x23b.google.com [IPv6:2a00:1450:4864:20::23b]) (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 4BqqG61r9Hz9sVy for ; Tue, 15 Sep 2020 00:57:17 +1000 (AEST) Received: by mail-lj1-x23b.google.com with SMTP id o13sf5720166ljp.18 for ; Mon, 14 Sep 2020 07:57:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1600095433; cv=pass; d=google.com; s=arc-20160816; b=TgV2mA9+qV6hOqle7SE4/u7dVoMH2i3RTV34k2SIIdvmyLqFEqBb6jB2oIqOhNopJ3 WZsnhIa+N5GzwiDTFIj7MuKhh9CFjGtibdjTwE9ZoO+UCMBLRFtgJgmbw+WkH9PZJ4Vw Zoa0U23kM0+mtTqmcvpwSjW3Xo5IiFGKBb9NZB3ylwEMdv4hs5srOiu+IbKcF7YF3GyH T1fnJTgznipE4DAusd870D1DJrCPtZDXdBVqvjbubUukJJH8J8pq5CMNskOfDe+RmamR c/G+OYP+4vzgIrqzdePRRK98sspeIi68D/rypGo3wdf8L12V6LVOsC9IVMTFUD0hzbbq Lr1A== 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:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=aifaCgiPm/NhDz/NnjOLhR1SESMc6bInDHZKbHyh79M=; b=LYBeyB9jq8PMT8L64//ItYzbJOTdXGI+cS2zlRMLh4i8zFTDpSYJ2r/fZKI0DEL6qj zFj3mAeMZHz+QUjL5dvlVdcBdCay4o5WQxyNBQOdCh16pTTrPeOOvGeqvWUgPDNdDqPJ UIVWic8hngWGlYUAiLYEYlIMCDHJ8EJhE9UdAom7m/mIsq5tbDZz3NpjD8bofzhqu1K2 BMQjc59kCq8Uc7LSxGMsZEKtDB2N00Zd2fbr7q1x95sSiDPkBVM3vg80JoU2nP0uBLQp e8e7TTypixo1mQBKiKwuaZiHXpXV95MOdD+aqRWEenx0zgRiBKmYQ6GWDfxPehegKsLl fNHA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :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=aifaCgiPm/NhDz/NnjOLhR1SESMc6bInDHZKbHyh79M=; b=YKtK1oBXMpjEb1QoTHSYwNO+BFw+40vOJjOWwQQRM1M6p0AhPHC+U7OIMDg/G8ub+N MbYpudt3QIPAxZOG8GYTBYY0nxpBVhn9w+dA66VqgbHoCkCK3Y+yGSXB5ghMnLzqQmtD OajvDK1BJNkR4mjjr+xvi2kOA8QYnuOIw7HhfQpPGaRQf86aosBkOoWTCjXe21qtBX1w VtBihJ33pqUs1PWn7Ncs8yjPLUd/QUwf8Kjb0LTbpVF5wdHV0QCD3i76ebCBEuSO7LTx QPeMtEOIJs6Lm/ZvTw9YISI+8i3txIm9RjfhllTWzldKEYU77NP7MFXcrqGZ5hyh0ZEv Unww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references: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=aifaCgiPm/NhDz/NnjOLhR1SESMc6bInDHZKbHyh79M=; b=NwBuMQjnYIsRxeqatPXnAUBBwCnj50/k6QZWKJ5+RLU+heqMspU8lCznYEpfdmtujo SGgzZVs9sUWxJI7JNXAC74Y720JX5chyfQPrh4V9lWCBkhtWeaIrItmbtX1ChPmAJR44 7eWm0xcZG6obuiw4ogy8BbGmP4MBneUeAtAasGIJNqJktFFt7PYnRTTbJ21wRJhbZXIU LZniKlhINf3vkQHgHdgaYSgo7UjEqVL3Wx9cy9RrpKbepHiRCaATGFu6T/NuP7aq29iS zZ+mPxWZagW3QcwWFcIBdcuCKcPioo5ib0vVBuwEomFxb7cjRc0nZo/DCsu0YZVyD1+o cIOg== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM530zDePW+AWJ1dKu8s0wdsRM8Li0dKSr2zA+NBERQncQcVyFL0vP 5z09aUB6//tO8l4aCDyHGas= X-Google-Smtp-Source: ABdhPJxnTLm2SVXGcBo2puiTZ5ukvV3uZQDjvLYjEbb3Sm1HUEYBTcLttNeOh1c4BGH797Rqe2trPQ== X-Received: by 2002:a19:404:: with SMTP id 4mr4227042lfe.343.1600095433128; Mon, 14 Sep 2020 07:57:13 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a2e:9151:: with SMTP id q17ls1460265ljg.8.gmail; Mon, 14 Sep 2020 07:57:11 -0700 (PDT) X-Received: by 2002:a2e:9743:: with SMTP id f3mr5735925ljj.310.1600095431586; Mon, 14 Sep 2020 07:57:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600095431; cv=none; d=google.com; s=arc-20160816; b=hNZTf2u1op9pJuFIxZHeoYVIk0N+fXVvwzUqeqt4tk4mcd3CniJ9L1djdRmJqakyka rPNx4JOueZdyjYCoaheQSeiA0cdJbCwWFiT+Oih5pTdPmF5/HXTw90rMMEuc1acnFs1M O+dj3YaDHFUDF2czdzxkDMsqO1t90RBPmUwfaLeqRT5bSsqUXX5o9F6jZnyCg/a9zfJS tvfWJGv4c4IqCm91wjKwONBDSJtG8XBtyZaAtOtD5sAq7ValJNX3hxqC4FOjNtZCAE1w 2I+zzhba851eM1aBi/YVlxlnDYH1xYOlaldJYcZ+6nfrpnJnUhSk82OlKfG0Xl6Z54H+ Ec9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=1xhZ8YMhcPbOUq8F6MpxZDEuxYAswIkDa6yS7K6hrUE=; b=rdf8+osHk3sTJe2rk7knX2z5qyedh4Q6b7jy6UjQ7jhAKiL5zSRoSGy3hNOrPcFIDZ SO9bduOcf0MLd69nkjfhNhdacNGOA/EhViXR1foMoNetp7tN9vUPTSEai7NJNEMKwFFf /BrQ6QETVZt7TkD4OJq+MmCG30ZiYQuKqm4FOOvMMjz7hr3zZo3HkJO5z5hHpsK9Qn/t mOGxmQACzU3UbQPx9G9vN/Pr3RjtjOvySCF6x0czooAstTSBhJLLg7l07ffmwebLegxO dZzAfC5U+3/z2g2FGdDSxztDbKuyVs2821CNGbxYRqZu2ytpcT1Sk/CzJTMU1RRN07Ds 2tSA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from david.siemens.de (david.siemens.de. [192.35.17.14]) by gmr-mx.google.com with ESMTPS id q20si271988lji.2.2020.09.14.07.57.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Sep 2020 07:57:11 -0700 (PDT) Received-SPF: pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) 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 08EEvAZB004483 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 14 Sep 2020 16:57:10 +0200 Received: from MD1ZFJVC.ad001.siemens.net ([139.22.42.140]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id 08EEv7pK008872; Mon, 14 Sep 2020 16:57:10 +0200 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH 03/14] channel_curl: Factor out channel reply buffer handling Date: Mon, 14 Sep 2020 16:57:01 +0200 Message-Id: <20200914145712.4989-3-christian.storm@siemens.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914145712.4989-1-christian.storm@siemens.com> References: <20200914145712.4989-1-christian.storm@siemens.com> MIME-Version: 1.0 X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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: , Factor out channel reply buffer handling so that other channel methods like, e.g. channel_post_method() can use it. Signed-off-by: Christian Storm Reviewed-by: Stefano Babic --- corelib/channel_curl.c | 101 +++++++++++++++++++++++------------------ 1 file changed, 56 insertions(+), 45 deletions(-) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index ec65581..4747107 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -712,6 +712,53 @@ static size_t put_read_callback(void *ptr, size_t size, size_t nmemb, void *data return n; } +static channel_op_res_t setup_reply_buffer(CURL *handle, write_callback_t *wrdata) +{ + wrdata->outdata->memory = NULL; + wrdata->outdata->size = 0; + + if ((wrdata->outdata->memory = malloc(1)) == NULL) { + ERROR("Channel buffer reservation failed with OOM."); + return CHANNEL_ENOMEM; + } + + if ((curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, + channel_callback_membuffer) != CURLE_OK) || + (curl_easy_setopt(handle, CURLOPT_WRITEDATA, (void *)wrdata) != CURLE_OK)) { + ERROR("Cannot setup memory buffer writer callback function."); + return CHANNEL_EINIT; + } + + return CHANNEL_OK; +} + +static channel_op_res_t parse_reply(channel_data_t *channel_data, output_data_t *chunk) +{ +#ifdef CONFIG_JSON + if (channel_data->format == CHANNEL_PARSE_JSON) { + assert(channel_data->json_reply == NULL); + enum json_tokener_error json_res; + struct json_tokener *json_tokenizer = json_tokener_new(); + do { + channel_data->json_reply = json_tokener_parse_ex( + json_tokenizer, chunk->memory, (int)chunk->size); + } while ((json_res = json_tokener_get_error(json_tokenizer)) == + json_tokener_continue); + if (json_res != json_tokener_success) { + ERROR("Error while parsing channel's returned JSON data: %s", + json_tokener_error_desc(json_res)); + json_tokener_free(json_tokenizer); + return CHANNEL_EBADMSG; + } + if (channel_data->debug) { + TRACE("Got JSON: %s", chunk->memory); + } + json_tokener_free(json_tokenizer); + } +#endif + return CHANNEL_OK; +} + static channel_op_res_t channel_post_method(channel_t *this, void *data) { channel_curl_t *channel_curl = this->priv; @@ -1055,7 +1102,8 @@ channel_op_res_t channel_get(channel_t *this, void *data) channel_op_res_t result = CHANNEL_OK; channel_data_t *channel_data = (channel_data_t *)data; channel_data->http_response_code = 0; - + output_data_t outdata = {}; + write_callback_t wrdata = { .channel_data = channel_data, .outdata = &outdata }; if ((result = channel_set_content_type(this, channel_data)) != CHANNEL_OK) { @@ -1069,26 +1117,10 @@ channel_op_res_t channel_get(channel_t *this, void *data) goto cleanup_header; } - output_data_t chunk = {.memory = NULL, .size = 0}; - if ((chunk.memory = malloc(1)) == NULL) { - ERROR("Channel buffer reservation failed with OOM."); - result = CHANNEL_ENOMEM; + if ((result = setup_reply_buffer(channel_curl->handle, &wrdata)) != CHANNEL_OK) { goto cleanup_header; } - write_callback_t wrdata; - wrdata.channel_data = channel_data; - wrdata.outdata = &chunk; - - if ((curl_easy_setopt(channel_curl->handle, CURLOPT_WRITEFUNCTION, - channel_callback_membuffer) != CURLE_OK) || - (curl_easy_setopt(channel_curl->handle, CURLOPT_WRITEDATA, - (void *)&wrdata) != CURLE_OK)) { - ERROR("Cannot setup memory buffer writer callback function."); - result = CHANNEL_EINIT; - goto cleanup_chunk; - } - if (channel_data->debug) { DEBUG("Trying to GET %s", channel_data->url); } @@ -1097,7 +1129,7 @@ channel_op_res_t channel_get(channel_t *this, void *data) ERROR("Channel get operation failed (%d): '%s'", curlrc, curl_easy_strerror(curlrc)); result = channel_map_curl_error(curlrc); - goto cleanup_chunk; + goto cleanup_header; } if (channel_data->debug) { @@ -1107,7 +1139,7 @@ channel_op_res_t channel_get(channel_t *this, void *data) result = channel_map_http_code(this, &channel_data->http_response_code); if (channel_data->nocheckanswer) - goto cleanup_chunk; + goto cleanup_header; if (result != CHANNEL_OK) { ERROR("Channel operation returned HTTP error code %ld.", @@ -1116,43 +1148,22 @@ channel_op_res_t channel_get(channel_t *this, void *data) case 403: case 404: case 500: - DEBUG("The error's message is: '%s'\n", chunk.memory); + DEBUG("The error's message is: '%s'\n", outdata.memory); break; default: break; } - goto cleanup_chunk; + goto cleanup_header; } if (channel_data->debug) { TRACE("Channel operation returned HTTP status code %ld.", channel_data->http_response_code); } -#ifdef CONFIG_JSON - assert(channel_data->json_reply == NULL); - enum json_tokener_error json_res; - struct json_tokener *json_tokenizer = json_tokener_new(); - do { - channel_data->json_reply = json_tokener_parse_ex( - json_tokenizer, chunk.memory, (int)chunk.size); - } while ((json_res = json_tokener_get_error(json_tokenizer)) == - json_tokener_continue); - if (json_res != json_tokener_success) { - ERROR("Error while parsing channel's returned JSON data: %s", - json_tokener_error_desc(json_res)); - result = CHANNEL_EBADMSG; - goto cleanup_json_tokenizer; - } - if (channel_data->debug) { - TRACE("Get JSON: %s", chunk.memory); - } + result = parse_reply(channel_data, &outdata); -cleanup_json_tokenizer: - json_tokener_free(json_tokenizer); -#endif -cleanup_chunk: - chunk.memory != NULL ? free(chunk.memory) : (void)0; cleanup_header: + outdata.memory != NULL ? free(outdata.memory) : (void)0; curl_easy_reset(channel_curl->handle); curl_slist_free_all(channel_curl->header); channel_curl->header = NULL; From patchwork Mon Sep 14 14:57:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 1363671 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::437; helo=mail-wr1-x437.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbsej735akgqexnf2q7q@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=siemens.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=XlE2nptJ; dkim-atps=neutral Received: from mail-wr1-x437.google.com (mail-wr1-x437.google.com [IPv6:2a00:1450:4864:20::437]) (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 4BqqG52X64z9sVw for ; Tue, 15 Sep 2020 00:57:16 +1000 (AEST) Received: by mail-wr1-x437.google.com with SMTP id o6sf6993896wrp.1 for ; Mon, 14 Sep 2020 07:57:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1600095433; cv=pass; d=google.com; s=arc-20160816; b=QOlVaJTUzgcHB6/nlwV0IxTiY+tD6MJDGyU2iF6ygAE0uM9/TWj+U9WZcFC+H15eM2 EBNOAqd/Ema8957FG+6Qufe8v4hjv8DJ5ZRzjkIjrjkEdulu8yJzrCy5PDwB3dIROr6X vEbqYpP+4A3zAkwmex7AA+1c/uFLHaAU+CXI1wBMI5vJG3bV/BDGr2HowOcrIoS4GQi7 ilL4DkoJb5y/TG4pKY+OkTGPKeIuAROT+BSbvI6HPdu8DtCqKS4X788TJKnqG+RnzZBy Wc00dJ9BE22zne/OYpaa1UEHOHj0Qczw8j6tsc6CGvFpZEyOmf1nb5q4rYdgqn/BmblT C6qA== 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:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=WDjAYla/F16KwVA4W4rCpDZpvtU9peFaAFnVEX8ckq4=; b=t4M07zS0swOZaAkdBrca68b6361HfGm9KwzgaiRjkAmmT9/mN92umCGxrfGiF0nel7 BkN5bwpbgp7qdyZmx1/4nD0UcCZwm4cT8Cn/w+By0qnQI/sLXLY9wYkCFA3BeIp0foAw 5nOaJ52xe2GX66nvaczEK6kbMQ8QdFNdztZeUu6DXjNK7F5DUtL/00MmXn6lJkysGDrQ Qda93JOM60PhmF5HouE7DPprPmS9tsvIZhOcdfEAL7v2pFeFDpXVL2Vum+txiXVdPzKS P9u0Qe7LA6Rp6ZUnRdOB0HMB2oNc2+PzJ461YC0WML0CyZOgce+neoyvx3TDsXu8U3fj NKmQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :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=WDjAYla/F16KwVA4W4rCpDZpvtU9peFaAFnVEX8ckq4=; b=XlE2nptJC9MXRASY90CREYwrNzl5nzcqtFRH2BxBe626grfw2bok2PWOnUcDswYjnS EPRurirDb8zPngL3BFqekIkdj2WYGCVgyW1relqkJAFp5xqmeM/dVKGUFJGBDHplLRim D9mvg4uiPVRjdSvdeQajX3fbDWZIgUkFDgwQq45wvDBUy8AnjcFOFDlARy0ft8Wge/7x HQIPvZ1UdOvuLKKA57fcWLGfFq9pB6jJ4oPVMlkxcxv5IccSMum8so/ydorE+JD/5o9y mWYlNQF7yN847rDJXCC75XUe/j8oLAFnr9lV3KCri+yajDsXSl7A3be2Lp0tCXmlCj/l 8jfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references: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=WDjAYla/F16KwVA4W4rCpDZpvtU9peFaAFnVEX8ckq4=; b=c2kSopmSNQS8DUDdTBzINqwAF/3kOcTrs9aImfRZv1f1YhN4PnTvhuRkgbXS2hYbCr XfWHEy37NxLP8Vr+LXJ6YJibkzWB2nK4na6LTrDImOfFODAxsbI3FMIL5jpuwu0vhrfK QCOdUXLIfxiQC8v9QRYOeXucJt1a9nleA0e0gVobUDTpfWBLheAFGWo8U0iB7gDNX5xr GO1fubpHb0dWPBwdotVZT/888Gg2Xf/7mQn8IxYqFHaYHplmGGZ3cFIS7sy7NCEjhDFM a8zZQCOKsqpGiQ9G1BkfjT0cRXfcw34ZGe1ZkrYK8rBW0wX63C6/1+mWME3dkkx/RRFG kS3w== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM532+Y1YlHDGaqoQVb7ronx5B1ZYw0w57mIpdtCF5hkkciBvuORng 2/2+RjOxLaedAOflfDhemp8= X-Google-Smtp-Source: ABdhPJz3xnhj+isqYMvkpOfuh9A5rH9mrgfAHSUrqQnO4in5oOxjJqaW1Z3GmRApYPPNYklXijmQXg== X-Received: by 2002:a1c:1d52:: with SMTP id d79mr16389643wmd.82.1600095433181; Mon, 14 Sep 2020 07:57:13 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:adf:e3c3:: with SMTP id k3ls8362342wrm.1.gmail; Mon, 14 Sep 2020 07:57:12 -0700 (PDT) X-Received: by 2002:a05:6000:124d:: with SMTP id j13mr17442788wrx.182.1600095432217; Mon, 14 Sep 2020 07:57:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600095432; cv=none; d=google.com; s=arc-20160816; b=qypNEFzo7qnm0HBC6MUhiwzwVbDjOtJdHSy4z/HzwzD+FHbwR6ui4Uw+huUpMeZmGT IAmtkg8io1AeduQbZtvW+gjbyF4KhbmhP6eJnSipEEMkUC0Gt4nUjmWyjcJd3mBGS5Y1 O7vftT9NPFKQNdv6MGKAIuxFRAnx2Wy7bfRpC2ub1ob/WoL7F8c/6SSXU26dgko+QaVj pitOjnO7tybcZKVcfA9zjjQZj9k0sTzkpqtpVcAXZWPnaRsln0QigZmFEy3hNrFR2hC5 weZGxojLNxbnfa42QNwudGkwps3fIFLLWeI9zCQqzLGbYXF5hgaENMdsda4/PeUKerwQ MIiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=ATYmbPNVGvazgh/4maFoypTAt11VnE+yoYXh4es1sDc=; b=gR1FTHcnCjbebPfMgE9WC3zquPY4CDHTpFBQ+MhSmqPq2J460LMCaXP0zo4fRkFgQS N7jyzE9an7nhT8ATTNWXHi9zYafFVHiSQBZ+49vFK09jjlROQWqTbXGSyGite39hLEM1 A6ULf+D4/HgzrMUp5n+jdXIGZqkEgrnLhQRQMbseK/VGzYyjgIoHlHQN+gSXHRs26JSR Hcmcpu5HH5MOzP06wb/53o34TTL4TFV1Cy+xS2tdK11fl9/VeWrlF30b7V2COvg/uflw f/1KaP6JPxiUKSCLs6cKS14M74jIGVPtzLFsy3UUN7hOOnOi7peWiEURhvsiKW3F2DYS L4jg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from goliath.siemens.de (goliath.siemens.de. [192.35.17.28]) by gmr-mx.google.com with ESMTPS id z62si336368wmb.0.2020.09.14.07.57.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Sep 2020 07:57:12 -0700 (PDT) Received-SPF: pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) client-ip=192.35.17.28; Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id 08EEvBFe022769 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 14 Sep 2020 16:57:11 +0200 Received: from MD1ZFJVC.ad001.siemens.net ([139.22.42.140]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id 08EEv7pL008872; Mon, 14 Sep 2020 16:57:10 +0200 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH 04/14] channel_curl: Factor out channel reply log handling Date: Mon, 14 Sep 2020 16:57:02 +0200 Message-Id: <20200914145712.4989-4-christian.storm@siemens.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914145712.4989-1-christian.storm@siemens.com> References: <20200914145712.4989-1-christian.storm@siemens.com> MIME-Version: 1.0 X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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: , Factor out channel reply log handling so that other channel methods like, e.g. channel_post_method() can use it. Signed-off-by: Christian Storm Reviewed-by: Stefano Babic --- corelib/channel_curl.c | 46 +++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 4747107..4737037 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -712,6 +712,29 @@ static size_t put_read_callback(void *ptr, size_t size, size_t nmemb, void *data return n; } +static void channel_log_reply(channel_op_res_t result, channel_data_t *channel_data, + output_data_t *chunk) +{ + if (result != CHANNEL_OK) { + ERROR("Channel operation returned HTTP error code %ld.", + channel_data->http_response_code); + switch (channel_data->http_response_code) { + case 403: + case 404: + case 500: + DEBUG("The error message is: '%s'", chunk->memory); + break; + default: + break; + } + return; + } + if (channel_data->debug) { + TRACE("Channel operation returned HTTP status code %ld.", + channel_data->http_response_code); + } +} + static channel_op_res_t setup_reply_buffer(CURL *handle, write_callback_t *wrdata) { wrdata->outdata->memory = NULL; @@ -1141,26 +1164,11 @@ channel_op_res_t channel_get(channel_t *this, void *data) if (channel_data->nocheckanswer) goto cleanup_header; - if (result != CHANNEL_OK) { - ERROR("Channel operation returned HTTP error code %ld.", - channel_data->http_response_code); - switch (channel_data->http_response_code) { - case 403: - case 404: - case 500: - DEBUG("The error's message is: '%s'\n", outdata.memory); - break; - default: - break; - } - goto cleanup_header; - } - if (channel_data->debug) { - TRACE("Channel operation returned HTTP status code %ld.", - channel_data->http_response_code); - } + channel_log_reply(result, channel_data, &outdata); - result = parse_reply(channel_data, &outdata); + if (result == CHANNEL_OK) { + result = parse_reply(channel_data, &outdata); + } cleanup_header: outdata.memory != NULL ? free(outdata.memory) : (void)0; From patchwork Mon Sep 14 14:57:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 1363673 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::53d; helo=mail-ed1-x53d.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbsmj735akgqesjpmziy@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=siemens.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=Wq+7MvBx; dkim-atps=neutral Received: from mail-ed1-x53d.google.com (mail-ed1-x53d.google.com [IPv6:2a00:1450:4864:20::53d]) (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 4BqqG55djfz9sVx for ; Tue, 15 Sep 2020 00:57:17 +1000 (AEST) Received: by mail-ed1-x53d.google.com with SMTP id c3sf82007edm.7 for ; Mon, 14 Sep 2020 07:57:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1600095434; cv=pass; d=google.com; s=arc-20160816; b=njMCG2fN39Ii64OBKBOGMEcW/dLtI+o41yU/9PbSfp/mSmeM5Ff6dM3vfQh0QlCGbM FppFNtgoCKzvhJ/UrtU6NtVaDZ2ZDnuVSFCbXs2dns9Zkp+QJ+MWciQeJNH3/rLXwV3m pnuEIyrdlBs6avrGJfJfZf4EysBFRj3AEjfCFo1NOepKPwwkfKfPZFm/DIWw0SwZXih7 rp77Gp+Ykye7JJnkEPn0LczN3iGNB9Ti9Pbdn0BtDlZSm/hrn8eCCk2N8Mknxi/nfm+k mKFVaNs0Cp2Cc0jZZ6BVQfe9OxyEZBJO1nnI5GlI6clOkxZ4YaikaU8h5qoopotYCDkO Ie6Q== 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:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=TXTOr5f4XIAqY1FxxB64oVML9JjFfmqzKylhPWyewKs=; b=DOXMdnR0WPprYzVmhtPg55UGkqdePpwLR3W4iJorzgsnyfES8OsfQl9WmjyFOHwFfn FA7cugQXeezVopz8Dub2AfXJsvQzuxU0oG0TWP+xorYPbmy1mm8sehM8gGRZwXsVzfqj 7SZjVF3d43JOoKhp/RveV/EfZkq72r+fEQ+YwoLQGa7K3+RsxTlg7YeDo6cQ27vEDIel /08z1Nj1jxbqk+hnqiC10Pp4/+W8DZB/+b+2DphDRt2QNUKcgJP9+aV37XX2m+1o07TS Lko9vr9aH5yYbP1Ry5tRSbqKwlEdysnglEj8ebaqhBjMNYmaDZKMBuhxYVeGUce/VwpH 93DA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :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=TXTOr5f4XIAqY1FxxB64oVML9JjFfmqzKylhPWyewKs=; b=Wq+7MvBxwy61IbANHTroh8WQbMaE1eEf45piYDRClCtnB/NvvLUddmwe8ekOR/ahg8 +7ApSLfS0V91HUkOoD1AHacD7u7FguGUsr8wCpaHaUZP0FYpKveznoTjEE94y+FBabvf DD9i5VnNdzNHfZ/UHT4Bmq/6aTq3/7NZaODIFDtFmU2xf3AtSkAD1EtJBMWGO/3NJRja s81P8/IeiD5/uz4aPdBnmRVnWtND57T4Rh7YP8TvhpONHOMwvccTKHtKDSsnn5owbaOT bpxJ3/Eb0CAWyaO/06cL10KmVJaTxoiWipn/yxkyLAMGKi2BjraWzeEJG0uxH5vEnErT dxUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references: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=TXTOr5f4XIAqY1FxxB64oVML9JjFfmqzKylhPWyewKs=; b=YGD1yfV5bhqeMeraZWE3THWebdq/PBxJ5TGmIg7qP81ePRhrtnsnuo2qqD5w5e94YR lprqTsMU5QkXqV/CSNka83MZuBw2BeRAqN6p52upGIzSL4vhmm85oQ8HxD1284Kb8Wys 5I7pfHcJYdIyOAs842x4zB9mRce52ZNXRRvrii8HHEc6hzZtP4XiYGaBjBm9ZVsQc/Hl 2N8/viYkRj8C1rl9fCi8RzqIOkhqT1JqvWdIkrzAf5ufqZSeEGIs7wXFfKq1hvJTOEuJ S8nPFT0iwJWaYcHZ/6FEROjSSgmucADrt9G4dpfg7nyYFYh5AWBbCKXfruflDgA2whuf uhVg== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533O5AwUKDrM0Ti3GGPq3BXl0cdponFPWjPl34dPeDjeua9zGU+a 2YNmcq0d7t+4dhvQMMRH7u4= X-Google-Smtp-Source: ABdhPJxL5GGr882Fh+LZ9CMH26Cg6OsboT4HIDWwg6iJ0o/SsEu+7WvBChRQlECQ28eElB9EsKlgAA== X-Received: by 2002:a17:906:28c4:: with SMTP id p4mr15022081ejd.345.1600095434107; Mon, 14 Sep 2020 07:57:14 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a17:906:4904:: with SMTP id b4ls4694603ejq.9.gmail; Mon, 14 Sep 2020 07:57:12 -0700 (PDT) X-Received: by 2002:a17:906:95d1:: with SMTP id n17mr15701795ejy.324.1600095432934; Mon, 14 Sep 2020 07:57:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600095432; cv=none; d=google.com; s=arc-20160816; b=z7proOtS5syJbWzd0gypSWS3ebLwnrBHb47lVEyNNmUKKS6CsMHyFzlrGsYXAJgWUW dM5R4MjkkKTAqBiGabsFUuQwbBqpLoRYUCzoEr9n8zL9rmW9YNq1NFGoy5ukTlCImUph T8dU1+2joyxu3Siqm0wBWaOlB5UBFsj3l4GcCp4B6AVwaJTTIANA/GIqjYlAY7Mcyw88 Rf4me7sHGNkUXIzZPN7ZejR3af80oFTV2MaGNO8z8JKitWiHPy+fsZV3FEfDabB0JmY/ lvJ1vIQf76fWL57kAbcUp5s/6TjcSb9SAaej5ZxvoFbJUKY9emHuWBND6l4wumg5RUZY dqEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=pCh36rjflDYeIxwR9+GTlotUdmwvlbmlzgPdIcnjbzI=; b=aWfI6aDDg3NnRDExO20E9rRq45fYJHYZkZhYOE5Z0E5voQajsrSDgxi9raUyQYoOkK aypqibnY4onsPIrL4rrO4vF2VAZXrNDXZx850KwNm5FsEcEDGkDoU8Zddvjy7i1Pi5L9 vsdni2VxFuxh4sopLdSdtkdIUnBwh6/qYZtfqtT6YYJZPLc3JDtv1zOwX45Ny3/yF9hs kOll6wUt5Ek+62ZnJDnbj6zGxLZAwQX/rD4hVDCU8ysFuboaSurVAV4MBzhlCNMvJ5bB 6m+uH1ptHHsLKFFtchadWiWhSPIDXaTDXLn/gByBAX2Zn1GFdXnQHx+KvPAHQcpPU5bl 64Xg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from goliath.siemens.de (goliath.siemens.de. [192.35.17.28]) by gmr-mx.google.com with ESMTPS id dk15si307551edb.2.2020.09.14.07.57.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Sep 2020 07:57:12 -0700 (PDT) Received-SPF: pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) client-ip=192.35.17.28; Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id 08EEvCNX022814 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 14 Sep 2020 16:57:12 +0200 Received: from MD1ZFJVC.ad001.siemens.net ([139.22.42.140]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id 08EEv7pM008872; Mon, 14 Sep 2020 16:57:11 +0200 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH 05/14] channel_curl: post: use log & buffer functions, respect nocheckanswer Date: Mon, 14 Sep 2020 16:57:03 +0200 Message-Id: <20200914145712.4989-5-christian.storm@siemens.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914145712.4989-1-christian.storm@siemens.com> References: <20200914145712.4989-1-christian.storm@siemens.com> MIME-Version: 1.0 X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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: , Make channel_post_method() use the factored out log and buffer functions like channel_get() does. With the latter, channel_post_method() may return the server's reply body to the caller instead of curl logging it to console. Also respect nocheckanswer. Signed-off-by: Christian Storm Reviewed-by: Stefano Babic --- corelib/channel_curl.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 4737037..40c8c60 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -790,6 +790,8 @@ static channel_op_res_t channel_post_method(channel_t *this, void *data) channel_op_res_t result = CHANNEL_OK; channel_data_t *channel_data = (channel_data_t *)data; + output_data_t outdata = {}; + write_callback_t wrdata = { .channel_data = channel_data, .outdata = &outdata }; if ((result = channel_set_content_type(this, channel_data)) != CHANNEL_OK) { @@ -803,6 +805,10 @@ static channel_op_res_t channel_post_method(channel_t *this, void *data) goto cleanup_header; } + if ((result = setup_reply_buffer(channel_curl->handle, &wrdata)) != CHANNEL_OK) { + goto cleanup_header; + } + if ((curl_easy_setopt(channel_curl->handle, CURLOPT_POST, 1L) != CURLE_OK) || (curl_easy_setopt(channel_curl->handle, CURLOPT_POSTFIELDS, channel_data->request_body) != CURLE_OK)) { @@ -825,17 +831,18 @@ static channel_op_res_t channel_post_method(channel_t *this, void *data) channel_log_effective_url(this); result = channel_map_http_code(this, &channel_data->http_response_code); - if (result != CHANNEL_OK) { - ERROR("Channel operation returned HTTP error code %ld.", - channel_data->http_response_code); + + if (channel_data->nocheckanswer) goto cleanup_header; - } - if (channel_data->debug) { - TRACE("Channel put operation returned HTTP status code %ld.", - channel_data->http_response_code); + + channel_log_reply(result, channel_data, &outdata); + + if (result == CHANNEL_OK) { + result = parse_reply(channel_data, &outdata); } cleanup_header: + outdata.memory != NULL ? free(outdata.memory) : (void)0; curl_easy_reset(channel_curl->handle); curl_slist_free_all(channel_curl->header); channel_curl->header = NULL; From patchwork Mon Sep 14 14:57:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 1363675 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::53a; helo=mail-ed1-x53a.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbsuj735akgqe4llmi3a@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=siemens.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=msCBdDGQ; dkim-atps=neutral Received: from mail-ed1-x53a.google.com (mail-ed1-x53a.google.com [IPv6:2a00:1450:4864:20::53a]) (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 4BqqG64Bdwz9sW1 for ; Tue, 15 Sep 2020 00:57:18 +1000 (AEST) Received: by mail-ed1-x53a.google.com with SMTP id x14sf80663edv.8 for ; Mon, 14 Sep 2020 07:57:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1600095434; cv=pass; d=google.com; s=arc-20160816; b=Dq6d2RL6lp3JklqNZ9jArSxea5c34wJgChSHWG2tWTB8cqZFStO0mO/5gqn/G0P/P0 DVKym5dx71xhQmpWkenFH6Us9xqGmGpIy772mT0jTtR8c4M0cGHlRNT42OvV750lSOZD K6A2Oe4CTDsKvmGLw+7N41VsibV4o7UTKWnnGnrez4HfzKM48WGjNloNehGWPaJMyuj3 PUop2tto5uk8slO8dyZxeY83+UVrDHmMyVJQEu2vWWZwV6OtbF/USUMmMTP9R1uXacHz o3hpLUqn3OdDlAGuqLx9yE0CyAZhw8KNy5IWoMk95jQC6ko0sjuPxR/Cispk7f2NU47I F+FQ== 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:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=TnZO6xWoP91USnjt8qquHTVA4iI933LKI4RlwRAbuRI=; b=pNOBW6nHEcoZ2UpFLJ4WDXfUGtoiHPOZ/KivBuHxB3tnq5ua5SqtUVtEi99ckl85Tz KAhTSxob0cDwFmKFk1FbJZNvAPtuCxFpIXLeKJpc6XlS92foUFBdRCSr5RhRlTMgBxTR i4jSYb+aO/VVQbHjabRyk4Pn6VvuaUND9tRkhdu5uYOktDSTmJ4r5p3Ixxpelvp3Kf9b 1DEEptzpM2PejgoCBDddZleAc9ITNJFz+WP3GAYbgwbxUnZzcuFXz0kJG9EQjhKHarae NPNxua+8853oTimNtXcJQ1gZxyqCJuGnRg3UnnFOzAnm2uzVXvFtvz46UKxGvuqdLybx YA9Q== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :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=TnZO6xWoP91USnjt8qquHTVA4iI933LKI4RlwRAbuRI=; b=msCBdDGQeln+NLDcs5dHy2DMO6huXQI9bm2KxwvPSU+3Z6ahsLi4psrs8PBlvsi4Y5 eKCASI28+oRfiY0yM+AdahMfbOTeMiflWKAc695ZzUp6nAEFTT7pnsrCU0wXmDmfhN8B psAG0rqdIZZGxYjf/xAVM0yTg5NHAKo0QYHmbilDfmzKLRVm7Q1ozkXC2G3pmftWMOyq 4dzrP6gjQjgEDH9MALpfXzY1ET7Wi9e99hYSDkOECOD9ljO+M2LRckoHLePgdUpoekpD lytNUAxWAAJcAcgaFYqtnAplka5aAosDNuqadRDSrS9UP4gNyd1m3MpPpae8Tpdql70U SVuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references: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=TnZO6xWoP91USnjt8qquHTVA4iI933LKI4RlwRAbuRI=; b=OcX+4qY6UqUp0/FVVEx72xXGyHmbf27FfOjEFo0CW2hczkUn+/GBalFGySoqKLiDG0 Jx8E+6pqfzGO4b7p2zxV4DLbyWQbK8XJY4YSVFcGyrF+2jaWlkmrEtUx5lW9vlR9iBFN 7fdkKxH/3A75sTSNSay6mCXv9AxOn51XOIPBdioCKysdZPE4gqJqLkEQJ2gp/EO39/p3 hN9hVbuw4SPwOHUQHO1aYfQHqTkXtmBvpp5pTF8qp4EdS9sOrB2Z707+EBh5pvSG7sdT Zx5jk9qaVksuhKKA6szCa1T7ctTirdDj2vDSCkZRqBQ9kru7x6Mbv4E7c0U3gDUlRPY5 Tvpg== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM531Sp9VUHzA6rqFxHtbmH0t0lDP7egJv7tybT1J23O5eWHHlqH1s 8mTHvpgBM57k9Mwev5lCn0s= X-Google-Smtp-Source: ABdhPJxEdK+O+7y6jgBxKlYqj++CEfjKaXsDkDWugk+sV5KObQ5ST6JM6Mlb1+UwELsRig88PJfisA== X-Received: by 2002:a17:906:4993:: with SMTP id p19mr15681053eju.277.1600095434737; Mon, 14 Sep 2020 07:57:14 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a17:907:387:: with SMTP id ss7ls4702678ejb.5.gmail; Mon, 14 Sep 2020 07:57:13 -0700 (PDT) X-Received: by 2002:a17:906:6a54:: with SMTP id n20mr15682790ejs.401.1600095433635; Mon, 14 Sep 2020 07:57:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600095433; cv=none; d=google.com; s=arc-20160816; b=oZKTyqCqIUzKwwI+YayILd2sGM7pm4L2OaR/KptEJbLfq7TzmgAUgn/VByNSOC1DEv PcC43ehkLEIkyFM53hSeZvLHOSWb+i6n1jyDsodn5cAWCCBDcqt4qqRTnp+o5zVTTZvg fN2u7j34qEjCpeCG02UOPrBwczWITIYMbJOr1a3esaZv+/kH6KY6YrpPpxhkLCI5bFUV /uV1xJwfcxwN+iUycbWd9v+G3WjfcBDCap1Ig6xJsHY3ti0hFDDjW8eAn9zXpqj2owFA TP01AWy+OUoxjISgFhd2j2lcWv67cmm3cXlR2H4Xgw7Ptahf+8K/zr6N71zsXmnP6y+6 OJ1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=DVKh1ExSIqe0WyZb0Mowiddg21zFj5NefQY8tY956yo=; b=MslNVjGu3i6tTCbyTM2x8YVCQX8+kjIf1aNHFTYq+JcVWed7L3H46as4UgwxztT3y4 o9dOoMzd7GadKSF/Wydpr9bKdOSlXaBRyOTh7TTqYE8VrddrFeRJ50jCMySpI0qiMiGu mBGyXLN7U2CfPQCPh7kOl4F04VKWY6Q/kbOHi/Hc0FNV9r75tK+eLDb4ZtqTW4kRZ2Wh ZygryP9ftzjur0lwf6dfddjzsbhc4KoeMOu88qWWaLDjiwN0MB/QYzR6WGXkuaFCi+fw IDc5AmixFKpfgf+dNNp50k0oyrRgS7091aVq7KFEtsltoBbY1I7RQuXmH8qQ+0raFNdC Uqxw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from thoth.sbs.de (thoth.sbs.de. [192.35.17.2]) by gmr-mx.google.com with ESMTPS id f17si345505edx.5.2020.09.14.07.57.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Sep 2020 07:57:13 -0700 (PDT) Received-SPF: pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.2 as permitted sender) client-ip=192.35.17.2; Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id 08EEvDJn032160 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 14 Sep 2020 16:57:13 +0200 Received: from MD1ZFJVC.ad001.siemens.net ([139.22.42.140]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id 08EEv7pN008872; Mon, 14 Sep 2020 16:57:12 +0200 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH 06/14] channel_curl: put: use log function, respect nocheckanswer Date: Mon, 14 Sep 2020 16:57:04 +0200 Message-Id: <20200914145712.4989-6-christian.storm@siemens.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914145712.4989-1-christian.storm@siemens.com> References: <20200914145712.4989-1-christian.storm@siemens.com> MIME-Version: 1.0 X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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: , Make channel_put_method() use the factored out log function like channel_post_method() and channel_get() do. Also respect nocheckanswer. Signed-off-by: Christian Storm Reviewed-by: Stefano Babic --- corelib/channel_curl.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 40c8c60..27d4b62 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -722,7 +722,7 @@ static void channel_log_reply(channel_op_res_t result, channel_data_t *channel_d case 403: case 404: case 500: - DEBUG("The error message is: '%s'", chunk->memory); + DEBUG("The error message is: '%s'", chunk ? chunk->memory : "N/A"); break; default: break; @@ -893,13 +893,11 @@ static channel_op_res_t channel_put_method(channel_t *this, void *data) channel_log_effective_url(this); result = channel_map_http_code(this, &channel_data->http_response_code); - if (result != CHANNEL_OK) { - ERROR("Channel operation returned HTTP error code %ld.", - channel_data->http_response_code); + + if (channel_data->nocheckanswer) goto cleanup_header; - } - TRACE("Channel put operation returned HTTP error code %ld.", - channel_data->http_response_code); + + channel_log_reply(result, channel_data, NULL); cleanup_header: curl_easy_reset(channel_curl->handle); From patchwork Mon Sep 14 14:57:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 1363677 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::63f; helo=mail-ej1-x63f.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbs4j735akgqetxs2pqy@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=siemens.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=WDmpKLEv; dkim-atps=neutral Received: from mail-ej1-x63f.google.com (mail-ej1-x63f.google.com [IPv6:2a00:1450:4864:20::63f]) (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 4BqqG75dghz9sVf for ; Tue, 15 Sep 2020 00:57:19 +1000 (AEST) Received: by mail-ej1-x63f.google.com with SMTP id d8sf8193420ejt.14 for ; Mon, 14 Sep 2020 07:57:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1600095435; cv=pass; d=google.com; s=arc-20160816; b=yBJ2V6mQQNADE9RyIHmF9OjJg/LX90w6A15XJMlfncTj1DONV83Yb4sTgfLeSRFLwC aVkOMgqwzjeTzAx/LPCN9h8vWbmoEDDvaK4LlWP6OBcbQFn1HfbB2lB4mzRgVmLFpUzm iBe98QeiQuR5XJ+E7nZyutsRGH4EFNo6NLXVmjPi4cSBMuAIGrp5GVeFtk4fCAEZ4KMb ujtSrcteZybqfTjWWFP8NAM0/aRxKE9e4nQC4rLaUrTDYLVb3e5G998OoxhYJ4y5IJD6 +Vns+QHSDXqkXlsXtjtb2aQ8fBPHFIeRYxv18dTXvszA2Yxl0buEp2aO/Akd9ArxN5o9 imRQ== 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:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=TsphEsTbeEtYpREX/YL7mS0Fe40VadWCqPZjG/+TyAg=; b=i3BMfr5jgZ3J8JNLeR2FOTPMpebZiHgZ1cn9zlrXDmDsJ2QfCxuMzFxY9ktT1+Q77i gv/zTFXxoy4+5yQcz3UpZLMVe0HBvoIrGVSEHmNej+swdrzRQeOT6G0qgqaTr17pubL9 XI7YBghLa6wMN0ObCUM0ESwMVkrOz21LKlw4odluMHHe6ZI6ucEqEASkndUTtoHz6Yws B+BPG83QDJ5SU/GJaJ+foiaxmnPCOxXiqtiVtgL5pu/Ra39cNwWRJuEaqJbXivapeQXf W/md8fbecPVMU+sNSNmdmnUjIyoCs19loEp51LT29i9tYM+pwvllA+NTLogf1i08UWRY cZgg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :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=TsphEsTbeEtYpREX/YL7mS0Fe40VadWCqPZjG/+TyAg=; b=WDmpKLEv2TG/2kzXWk3OSeBH5FHObzoNLksZCUSp9RwtXpcXvnheeE6I1h0unOToHK xjBmrLLeFTlOJs2isNAt75pJheZgHWqsPRxMggkiqM75JAusu8YRts+xALv8nRuulfUU 3BEQTQYp/ymGjSnn72CjRoUcmQurytEYHJZEbeKV661JbvCiGnFSMW3FpNWmoWTzSYZs jh67GP0zodp02e5A3oL4H2PexoD1qP9gYTsNggvq28hPxUBhTr/nA7PDHQKuWBMxhwxh xrGEK+XQuF7eoHLSq3XR7a8HhL+oEIDZHCson2gQ0jw9e34i7GMjLRM3Z5rXYWW+/zzR lORA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references: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=TsphEsTbeEtYpREX/YL7mS0Fe40VadWCqPZjG/+TyAg=; b=AKhWY9YmC/PaOhCrWWuRT0ffl6nrjaI1oWEUyFdR7W4VuE6e+3f562ZLI98GApmv0w S8ZRa7hPIpGPCdq/fqA+LuXzE6wZE6qO8V62peeJSyL/9WbiODBenZnlwVqEK4In+cjO 4B3+joU1dDbc/5JOuXsRLCYPZx0F3MWMdWSl3t5L2yBYlQfSVqyCfH/z9l6Xgqdrd9/J z65TMJlQ4XYzP4nYlEm4wddKmZaR0Ya8Yfhw/4i7PBtGx+tbcyvkntyRP71BrzskOapj qVicLBrQP0Cv+6t3IsZpomt+l50oaNDN3smHxgykHfSDpbwLxWg8Z+9fIw1EBv3cDtZh 0xdA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM5313vhL8GM4zbA8pGlQNYD5pkKitCbuzZywVZECZepK/gt5QGS89 DExhjl8+dKFUa4VL2ym1d7k= X-Google-Smtp-Source: ABdhPJz+xRtLvix9Fn80XB+ZKTR6mI0EYvceei1b2uhr6rXBDkjKpSWsMElq0o6JK6R/8AaSa+NIcg== X-Received: by 2002:a17:906:4a53:: with SMTP id a19mr15904877ejv.56.1600095435541; Mon, 14 Sep 2020 07:57:15 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a17:906:d0c8:: with SMTP id bq8ls4707114ejb.3.gmail; Mon, 14 Sep 2020 07:57:14 -0700 (PDT) X-Received: by 2002:a17:906:14c9:: with SMTP id y9mr15821468ejc.523.1600095434569; Mon, 14 Sep 2020 07:57:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600095434; cv=none; d=google.com; s=arc-20160816; b=SyfPvq3SQxYblgCrYzRn8JRa5+kaRoI66uFFUVLXq3DwiaSeFhKKVFLmqkZXDxLD4w L4cSKPZpEZVcO776idfmrtkfQA/IOVrrzQgdy0nKNHFrOrwoBvGFIlr5xMaPTmc5weVC zPa/ON7DtDidJbO7nXqSyP9H4cF7Tnu/hVIJsrEMSB21RCKX0V5cKtcfwP0Xr33GsUQ8 zuGOcfDQoQETfhB+iEWpGn4Gc8woKGxv323xy9rGQNolZ7ygYLsh+CJGucbQ8fQrEEUy hBGL0RpajiSKEIE/OdOybK7ggkL6N9obDToUJUXR++3LdvvIgo00DggJUqOwhjAPoUGA 9r0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=QqLtv7ZuBcrJmKHRr6X+8jjdNNifnMLPUTgbyv6xiFk=; b=rVQkXlTz47szSjFxgF6GxrVO44mXwx0zil6NnkTcDMYdgwqW5/HCpIm4SBrRRK1nR+ 20DpkCtzVFthoDi+frNI4hnZriKL+FaYftjtZR5BUK3LuH9FHLKg5hTkdRWFetxrHHPa I56PQ/xRRyK/bsak13Co5WjF7YdwI/u/Q9S3/aIIebbMow3AL+r0QhepzL+6tmoe++QZ WsC0QM4W9ZGStC4tLKcmdt837xIhiVaAkIzRjjYdmCpMQsFFLbqkGZ4JVYmWkKlTsMCB hBzipmoa+ySOEpB/0kYJUWM8j4ppy4W9YNEQnNytTzuJL/DzhGwiSY26+TyedQMU2fsY U8yQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from david.siemens.de (david.siemens.de. [192.35.17.14]) by gmr-mx.google.com with ESMTPS id k6si272277eds.3.2020.09.14.07.57.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Sep 2020 07:57:14 -0700 (PDT) Received-SPF: pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) 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 08EEvEjp004578 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 14 Sep 2020 16:57:14 +0200 Received: from MD1ZFJVC.ad001.siemens.net ([139.22.42.140]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id 08EEv7pO008872; Mon, 14 Sep 2020 16:57:13 +0200 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH 07/14] channel_curl: get_file: use log function Date: Mon, 14 Sep 2020 16:57:05 +0200 Message-Id: <20200914145712.4989-7-christian.storm@siemens.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914145712.4989-1-christian.storm@siemens.com> References: <20200914145712.4989-1-christian.storm@siemens.com> MIME-Version: 1.0 X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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: , Make channel_get_file() use the factored out log function like the other channel functions do. Signed-off-by: Christian Storm --- corelib/channel_curl.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 27d4b62..e40bbff 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -1069,15 +1069,8 @@ channel_op_res_t channel_get_file(channel_t *this, void *data) total_bytes_downloaded, total_bytes_downloaded / 1024 / 1024); result = channel_map_http_code(this, &channel_data->http_response_code); - if (result != CHANNEL_OK) { - ERROR("Channel operation returned HTTP error code %ld.", - channel_data->http_response_code); - goto cleanup_file; - } - if (channel_data->debug) { - TRACE("Channel operation returned HTTP status code %ld.", - channel_data->http_response_code); - } + + channel_log_reply(result, channel_data, NULL); if (result_channel_callback_write_file != CHANNEL_OK) { result = CHANNEL_EIO; From patchwork Mon Sep 14 14:57:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 1363676 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::23d; helo=mail-lj1-x23d.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbtej735akgqevngynda@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=siemens.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=Bhmf/zdR; dkim-atps=neutral Received: from mail-lj1-x23d.google.com (mail-lj1-x23d.google.com [IPv6:2a00:1450:4864:20::23d]) (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 4BqqG86dZGz9sW8 for ; Tue, 15 Sep 2020 00:57:20 +1000 (AEST) Received: by mail-lj1-x23d.google.com with SMTP id f16sf5737486ljm.17 for ; Mon, 14 Sep 2020 07:57:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1600095437; cv=pass; d=google.com; s=arc-20160816; b=j3mv88nPpmFyADVEqJFmQmrj2utkFTa+ON2oyFgM1InHYrC8GgE26zhwd5gDz2cgki HEu4ld6zHJiFf2gUIrSULK4NlwDc4GwpPfdMtRDX3KM5N3nVGPMz+KchxSt7iDuWee/A FIFg62GjbYbtiddqon8FEK3IBQLP9Qv2UD3MMgKSsUmeD1En9DCU8bRCUmN5gz1n8t42 RwLwKNh5J1iIGxtyRKINoUaTtY6OJAtracIqk9ClAWPpFvkPu+6P1yuHokR1DHjJWnVO 0oqErw/36QJgDZ6P6VibfeeUHeb2qSZapTkJ/ttKhTljeiSkK9+dcQIs0xEqaiFisnlf drlg== 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:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=ms2RGMplMEd2ijdgPQNOrcKG5DZclYutIvbv0rl1oDU=; b=hKD87XTBVEaZAUfQYdKMWxmrts8nPdW52xQyWiHsD6EjjJFE/jieuxj+fTZr9qfNSC Je2PzIcOBU9gK9egnpsXokB1CpoyF+jRVnAN4NX4phQc/J455JsX7eO4VsNLzzRimNk1 6AzsYpFPlVkZDT5DgdIAhU0APa2DTyTf3QUW/UL2zGAG2Qz58St6dt17dH8VGUfxD78C m/XInZwjeITM7KsHO/o3eCXzbf69rwlNbDLv0hais+sOindDDGhtUI/H56WyMJ2MUSUb aU+SbDwjNR8JmwkKTCMXCaF4iwSN6GDxLVWQfLgwd6eTOC0PEIW0mdncY3/cmnHTTVAp jsng== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :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=ms2RGMplMEd2ijdgPQNOrcKG5DZclYutIvbv0rl1oDU=; b=Bhmf/zdRXIe/T+mXznMfDP5hc82S/UOLP+q2efaSITk1EGiDTPETW5grbYbUC/QcvG dNoC3HrjWHzkwBf5Y45zyENAB5bG4oBjIuOdneSkSimzWm+ckEvfNngEFNjfBFi/axkM AZlFxSpnmMN5nfk1gqpHv2gAMLvWF7xIakE05AUfQrtXoEui+h8cJ8V1TNpQFfXE8r63 SsFT+IiJhDA/bmR9uVW9+Paa0wFEkOZKv/BOlKD902Jv7bAUa8gF56mJ5dLqM3KjZjhh u5UyGpbTvdT2hlbyrTIDcCLkimycLsJfy665f6Zv0m5egbuw/ZBaiL/XaIYgzBiAuPH7 +mZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references: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=ms2RGMplMEd2ijdgPQNOrcKG5DZclYutIvbv0rl1oDU=; b=B8dHLudE4tE1tMCp52cuOwN4Um96MZC1BLOqAG9qJw+wIAoBc5s7vqgtYDQjeeHYBC uq7zAY5IteSXlSLzmo/kKMMmrhhxadjPbH+tft68pHEdLOBuwF+YnY0lzdsgYRscLbIM HVtsOAFC1iL1H8IVTiUSalomExuGWtmmFb5g9vbcR/eHkSIRP0Mi3RpGrWPVvVrOE/dr ctMlxDivrwSrnKZJgY4gNKLSAS6WCBEcvfBoFNyzia8JbVFZOa3DlGW43K765hgU9eAu G98DUaZeinFzKnmBWBtLQtODstYdUhREo3xQj04ZilC31oLzudC/L6uQq52DQMjXJqZ/ +How== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM5306LiDP7k2gbwFbR78TKTMXSgGaxki+JaNu2lqT+Ftj5YIDndZs lgGdj85UNwGApL9K7K1I4X4= X-Google-Smtp-Source: ABdhPJyhIZQMlBoUvQgCzvJNY+NmENqkskngPZcO6QwilwR4ufeA7edglZ5xIt9XsoLNl0D7bE3LLg== X-Received: by 2002:a2e:a58c:: with SMTP id m12mr5391879ljp.378.1600095437125; Mon, 14 Sep 2020 07:57:17 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:ac2:5c44:: with SMTP id s4ls36458lfp.3.gmail; Mon, 14 Sep 2020 07:57:15 -0700 (PDT) X-Received: by 2002:a05:6512:10d1:: with SMTP id k17mr5289534lfg.179.1600095435828; Mon, 14 Sep 2020 07:57:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600095435; cv=none; d=google.com; s=arc-20160816; b=My1JPBISm4woX+yFIvw2HCGaoQ+/f7sidTu/Vr4+H8h9ZSBzzffd1nk7w2X6dL/PMk R1ro1bRPpBueTjdKSJ8rYu53HiF+CxtNqSI9MzOpk+wgmClTmlxTAezYiY1CQFcYq8JC cTYOx0DyX/wwrg5yhORfW8y8UfX+ujvyMlpDONQHR58gBDlPOU9kwBe73KcjY8bemVhB l5PJNCSuNqA2lX43OoYeA3XPKNZ1XC3P6RiozoRgEA+nAECL5q/2BpaTCHvFdBSfbvty TFD1gCHYsdw1mYvKd7wH5fkYF+V9bJ+FSSl+zDbl3CAivor1Q4z4y3X3hujZ+zzOaj1G 0w1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=WwluWhXL3X7u3Ebeg/V0QcZKU7FtRb1N1O9zfsG3VFI=; b=UMuYxKp/NOKXtJtd3MsXghSZpeeEEVD4IcOTYdYGuPjow0YYEMINIlkg66sCNNZe8+ xZLWAiXKIEEd0e9yr21wD6SN4pp+5mpHWmAiD95gwGNgxP5aB/EwY4oasskwQ0ZSIv7z QRlVmDPA41+/jljpR7PaMR0srsuv334ShamfKuOl3TXSC7xNvKMA4vkNbJEloUsXQXdL ZquBz6VzP8/jY48UVo2c1f+FY4JfXXNYzXk+h01DAGDZfKkWTCCUsviCQtKfWj4CAlm5 U7yQ1C0KMrdjsysppEhmMPkWLmwU2EJcIYRmNyBzC/vAULaj/dILjV2v4q0PpHFYQCHY FFAg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from thoth.sbs.de (thoth.sbs.de. [192.35.17.2]) by gmr-mx.google.com with ESMTPS id k10si365884ljj.0.2020.09.14.07.57.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Sep 2020 07:57:15 -0700 (PDT) Received-SPF: pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.2 as permitted sender) client-ip=192.35.17.2; Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id 08EEvFp6032214 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 14 Sep 2020 16:57:15 +0200 Received: from MD1ZFJVC.ad001.siemens.net ([139.22.42.140]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id 08EEv7pP008872; Mon, 14 Sep 2020 16:57:14 +0200 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH 08/14] channel_curl: Consolidate effective URL logging Date: Mon, 14 Sep 2020 16:57:06 +0200 Message-Id: <20200914145712.4989-8-christian.storm@siemens.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914145712.4989-1-christian.storm@siemens.com> References: <20200914145712.4989-1-christian.storm@siemens.com> MIME-Version: 1.0 X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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: , Make channel_get() call channel_log_effective_url() without the channel_data->debug condition as it's done in all other channel methods. Signed-off-by: Christian Storm --- corelib/channel_curl.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index e40bbff..53ebc2d 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -1153,9 +1153,7 @@ channel_op_res_t channel_get(channel_t *this, void *data) goto cleanup_header; } - if (channel_data->debug) { - channel_log_effective_url(this); - } + channel_log_effective_url(this); result = channel_map_http_code(this, &channel_data->http_response_code); From patchwork Mon Sep 14 14:57:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 1363680 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::13e; helo=mail-lf1-x13e.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbtmj735akgqecyzvgeq@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=siemens.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=MHtfJdFL; dkim-atps=neutral Received: from mail-lf1-x13e.google.com (mail-lf1-x13e.google.com [IPv6:2a00:1450:4864:20::13e]) (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 4BqqGC59Fgz9sWG for ; Tue, 15 Sep 2020 00:57:23 +1000 (AEST) Received: by mail-lf1-x13e.google.com with SMTP id a81sf2517285lfd.1 for ; Mon, 14 Sep 2020 07:57:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1600095439; cv=pass; d=google.com; s=arc-20160816; b=ApJsRg867NF8Uz5HBdAr97ANEqJAI+q4X0WdhPLC3nPC9jqFZqlATIHsPNSRsUDdM9 e964jZxLvZ8T8nlaATQ9VMo32BAxyPTxqIM5cZXIrbN5YhxAGVefZ/ebymEF22+excGi U39VQCvnmcjRBbmgMKqiTUMXV8k5yUtVtxwPnbBJsmW/nX5xk5kQcRv7aHUcrO/iSLJk WzBgj5RF5UXOgR0h8l4CebdzEFnd3cICb0C8mSAsK6O7KtkgA27sqJSrlAmwQ4z9aIxH l8bpVAPx6GAdHNNLcg9y2j0eI3e+64rPA1cCkpQk8r50RzZ/tWruTnPhyl4u/sN5XE3t CVwg== 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:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=AyPnPdYiWT5KQAVFy4WwW4GlPv/UEsHnKUKyoqBpwb4=; b=Zi61wRInAwJ6JnvYDVLcCCixADJ5vrlSPeoOuS/wMsmtAxMTYpD5K0h964KXmubhuw 18Tzf2ndEfL6OUls+RQaRQlJ//zd+hNM5ZfP4r1OZugWYQp2b10fOYePMZCsP/cabJky ZU+Trfk1xpQGRr+SMNfdlADqg27nNGA1GL1F51QOrxffZdOz0QVN1/GMwKLlrYHykFxq QL5DOUX2oDi/fv0b1uC8wdvYwdDzGVeS2IMF5NxW2lojYZ5E7B+DRlwxNFlLxEoH7i3G G3eohLyaltBq+E3Fh/AvJaI03M8DE3HIq+bBMdMWsU5q+U5VqtWluBblmbr8BGRowvQz o8XQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :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=AyPnPdYiWT5KQAVFy4WwW4GlPv/UEsHnKUKyoqBpwb4=; b=MHtfJdFLjBkIth6spJC3Tuvb8lRkDsvI6sch6NS4Qc5I46pN78TMvsVQ3MzYSeM9gO v3uAizLI0n5lM+zcro/x01DZ+TStfrumL/ReOilA2ryswn0uVf2tXTmDdIvOYzRp8zJK Rq1O1gSxEGSJqYEzgWKnL2dmYA0d+6MICVOH2fti1jrdI15TpsxmYq/o5xyIi3QEB3ix CjGJi/Sq+tEiv2Du6tABHhaWKugJyFDWDdHjNJ2yAFVr+LlWK2sHdhvUeCkn028xq2Q3 J0Bru3IPT1d8nKZDwNJKvANRRmaBReS67umnicVjQDRx5ha4hOAx54XxE+LYBHGN8+Sv q7fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references: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=AyPnPdYiWT5KQAVFy4WwW4GlPv/UEsHnKUKyoqBpwb4=; b=D/9l9a78FRwFY2uCRuSgdamHqB9G/NPutjZs/gMLijGqWf0oCcVa36ozDb/0+Ex6ZA YrWCV4eno7/tINeUem04dsKImRE6tZu3ipvOuWrGm3cvESgVTeeLUDpfSeWGTEOaqAfM 71K1Y4ARHeIDBDv/7TkQ3W4FjUaUNdvthbwBRNQ2/61tQ60//39xtbrbYsPf8nOoRZ/2 LdmejG4GibCAQGEcxOmMNIWlFydcvOVPbQv36x2GQD+SC5OrbcbAeMM4d9qbtxnxNy3d PMEFgNfny7sBlBMcjMwFj7pkHMEAEJAUUQUCzJCa5DcmPN3VUQm5H0HP9b2cXZprvUtP CMOg== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533kJcbj1EoncPP+82KVgPBSpbyhkAX1T+oo51IahoK4n6VG+nhd Rho+uZCQ52iW+gcctTx+CnY= X-Google-Smtp-Source: ABdhPJxG7De/KCGm1qrK7jH5nThDNWvJqqzOqw8gpTLnDJrQ+kBl6xFyiIkQjGN2/nqtsrRl+Sp2Yw== X-Received: by 2002:a05:651c:110:: with SMTP id a16mr5209546ljb.110.1600095437841; Mon, 14 Sep 2020 07:57:17 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:ac2:5c44:: with SMTP id s4ls36477lfp.3.gmail; Mon, 14 Sep 2020 07:57:16 -0700 (PDT) X-Received: by 2002:ac2:4c19:: with SMTP id t25mr4854724lfq.503.1600095436732; Mon, 14 Sep 2020 07:57:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600095436; cv=none; d=google.com; s=arc-20160816; b=b6HplKdz/SvJ205HZW7TRuyCwH+W6+K0F5pcdnJbzRUuQcAF5Q9VFDJD7FyEuUg3hB 32VI7i2pYQnw6ZkZgIbw+O7JR327TFqXZE84mIohIW4911h8uqJ3bb9c8VfNlVIZ9Nt3 9cGlFHuPgzQTIumBwMx32PNqTp1R4zb2AxntSdh65ugvEeWfRDqlcmeoWRuRSi16XN0G 6nRTLwZJwnbCldkoCwFfBPuamOPJ/PHe+7cMQrRX2QZEeKIZ4xf5PmJEhJPXcqn7oPti ME9ddU2B3uug6bjXR0Gq6n83wIj+Ni5z2jK8W/fj6+gMmer8BdCJZx9T8dw+S5Tw2P/h c4tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=05nuTWjlcvc8D6G6CcXIVgiw+6QIKhX8Jv3zrJrSXZg=; b=e/Ibcm4qEp/4B6vPwe3HHSkGauoVtkPldBQ9XjAJnUe+SufHcV6FqrX1+aT6r0fyvg mXVZ7TjG63+yeUclPZDPKweYXJvqZ8hGm9zKab7xFPgEOJxJMV745SigctxteqhBz+jT kd0riCWKDLFH3tgIKirzK70yAv/mfd2WBNVSd2laRukFShLSlU6N7gOBc/9UWaNJWtGf GVZlR/2+nIiFy/kvl/MzMgSDqEoK/3hMQnoDqir6RvZYVd6wt2OQl5yY+6nsgr/lb38A 5TOFgetVzk2EptPK5P4yYid97s+SHG65LhkKMUmmByoGWxatATrXZfSdX7dpguEJemBD kffA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from goliath.siemens.de (goliath.siemens.de. [192.35.17.28]) by gmr-mx.google.com with ESMTPS id 21si340575ljq.5.2020.09.14.07.57.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Sep 2020 07:57:16 -0700 (PDT) Received-SPF: pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) client-ip=192.35.17.28; Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id 08EEvFZ4022889 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 14 Sep 2020 16:57:16 +0200 Received: from MD1ZFJVC.ad001.siemens.net ([139.22.42.140]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id 08EEv7pQ008872; Mon, 14 Sep 2020 16:57:15 +0200 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH 09/14] channel_curl: Make CHANNEL_PARSE_RAW actually "parse" Date: Mon, 14 Sep 2020 16:57:07 +0200 Message-Id: <20200914145712.4989-9-christian.storm@siemens.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914145712.4989-1-christian.storm@siemens.com> References: <20200914145712.4989-1-christian.storm@siemens.com> MIME-Version: 1.0 X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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: , A CHANNEL_PARSE_RAW-flagged channel operation returns the response body raw and unparsed to the caller via channel_data's new 'raw_reply' field. It has to be free()'d by the caller just like the json_reply field. For not returning the response body to the caller, the newly introduced CHANNEL_PARSE_NONE flag should be used instead. Signed-off-by: Christian Storm --- corelib/channel_curl.c | 19 ++++++++++++++----- include/channel_curl.h | 2 ++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 53ebc2d..8c4efa9 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -767,18 +767,27 @@ static channel_op_res_t parse_reply(channel_data_t *channel_data, output_data_t json_tokenizer, chunk->memory, (int)chunk->size); } while ((json_res = json_tokener_get_error(json_tokenizer)) == json_tokener_continue); + /* json_tokenizer is not used for json_tokener_error_desc, hence can be freed here. */ + json_tokener_free(json_tokenizer); if (json_res != json_tokener_success) { ERROR("Error while parsing channel's returned JSON data: %s", json_tokener_error_desc(json_res)); - json_tokener_free(json_tokenizer); return CHANNEL_EBADMSG; } - if (channel_data->debug) { - TRACE("Got JSON: %s", chunk->memory); - } - json_tokener_free(json_tokenizer); } #endif + if (channel_data->format == CHANNEL_PARSE_RAW) { + /* strndup is strnlen + malloc + memcpy, seems more appropriate than just malloc + memcpy. */ + if ((channel_data->raw_reply = strndup(chunk->memory, chunk->size)) == NULL) { + ERROR("Channel reply buffer memory allocation failed with OOM."); + return CHANNEL_ENOMEM; + } + } + + if (channel_data->debug) { + /* If reply is not \0 terminated, impose an upper bound. */ + TRACE("Got channel reply: %s", strndupa(chunk->memory, chunk->size)); + } return CHANNEL_OK; } diff --git a/include/channel_curl.h b/include/channel_curl.h index 321526b..5f312ea 100644 --- a/include/channel_curl.h +++ b/include/channel_curl.h @@ -28,6 +28,7 @@ typedef enum { } channel_method_t; typedef enum { + CHANNEL_PARSE_NONE, CHANNEL_PARSE_JSON, CHANNEL_PARSE_RAW } channel_body_t; @@ -42,6 +43,7 @@ typedef struct { #ifdef CONFIG_JSON json_object *json_reply; #endif + char *raw_reply; char *cafile; char *sslkey; char *sslcert; From patchwork Mon Sep 14 14:57:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 1363683 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::237; helo=mail-lj1-x237.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbt4j735akgqev66ngfi@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=siemens.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=p6xj8d7o; dkim-atps=neutral Received: from mail-lj1-x237.google.com (mail-lj1-x237.google.com [IPv6:2a00:1450:4864:20::237]) (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 4BqqGG1gnDz9sVx for ; Tue, 15 Sep 2020 00:57:25 +1000 (AEST) Received: by mail-lj1-x237.google.com with SMTP id 184sf5763449ljf.14 for ; Mon, 14 Sep 2020 07:57:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1600095440; cv=pass; d=google.com; s=arc-20160816; b=mrJ2UpyF07L6bC3xYzCSCDjvVWUcCZyFwFn+8jEXbjw3sJ9ffklxTwXYuipZYlZai1 LyngIy/w7kiUBzV42qA3FP7s+wQIhCRp6ldTKTvcP2NF3sgpLp0xIC8Rw5x9+gSr45cG qX97dKeZIN7GiyPju8ttppdXjXqUID/3gFCUNmqjbior2lJ8rnMAGRAzt9yrlo+pKnj3 9x/HBmDHc6Xoe+rvrNMExIdCxTuc1aS8YznBvq/DCfXVtOHdv4gE+xfEw+7zdeBkB0/P C3Pmnb3JtNWH8NUEV3UXg2nzluxIKRS7JbZBVgwxsiXgc05WwA3rwxh460zufUsPyKrI +4xw== 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:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=A4EORirjlm0psxjAIdmMoLaRq1haNsMT8qYHQU1zWuI=; b=N10Q1eypUcwtYo8eCek4vAd5QeuzppjzIhVRtIXmLTCJRdQ1L7bzM8+7HKxrpiFSxg 5Yc3jqy0ZY1mm0lzOTJsDtQKJVN9+2/zXmQth1TOX+oBuqIC2bDQpVZBVIrLi0h8l/i3 hRFGH7VNtJkJfhyVp5bchyPbyhV3Lzw40IF80Cxsf11ivv3YtxCb7yIUhdjW2q+spQOn I8K+3+nKeLkdb7HmYFeolqJcPAOmm/gbagYNHpdGWD0WmTj78SLVjaalFzBdAjGIRaRv 3G+hvB5sMqqeiBncoazfM2MXQOqB0ZMwbqNjrfu3iA/NICJODDtWuM7XwKy2scRscOI1 4g3w== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :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=A4EORirjlm0psxjAIdmMoLaRq1haNsMT8qYHQU1zWuI=; b=p6xj8d7o/2PDukfbLHLX5QdZHW0qySkeU5WM5uK5cfDTI2uXkKqpV+6w+da6p9MNxu pjEfyYKNLeOR/uj+Wi8jbjDIRGZxNGHKmJutT84SESbDXSRLIbxk14okiT48821CHYfY WSVuo01bIDfFcB5ERKghncpBg/WE4inFQjT4FaiEUjurO/KRoLdhEnCb78M0FY+Td8R8 uhIpyfeef8HGGv41cGXnAF+ZCnXwVhlIeM9k5yR/Vz1gqhSdU2DNnmnGjajLl3gUZzGE N6ShzR5JrVkgU2kF3mgQu03JpLh8+V/nMo8DY5gjTApsGIQrmWs6NQlQvWa0UZBjv+xX hqBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references: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=A4EORirjlm0psxjAIdmMoLaRq1haNsMT8qYHQU1zWuI=; b=g+sGtsT4rPlB4lrMrZdm38rre1AjLgkuk4P6f8/N5a9JNa+XkxEBWE8iL87tWhkym1 zFbpzTIJO3mAyXdL16M/ifKqV1902aeEwAS6KYja6iUTLGdMUPkU7+4gSuSZEZkXn8gJ LXBe4FUy/OvV8AwXtB/KPz10A7R6/YiQa2mIWCc/b5fKni2dJoWBXswjl8i5LFgCozhq zAbiBm2JG6lxSBMmLfbpBTdAypxgGvVLNV5V1Wvn8Ea3Uumo4P9Xc/EPWYkSVp3rkyg0 Dw4u3LvvktN+4iCIyxyBchk/Ll7XpIkBrc8Ltif3OGZUn3enzVM3TzfOxy9Xx7Vq85Zu nKPw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM532EXIpci9M9VCcy3JMuyT04xTXJhM01CZhHRldcqx7J1sJub1NM SlPqfmYTd+xHY1qlvN57ovY= X-Google-Smtp-Source: ABdhPJzvk/2fbTz7wCaUj7llJz7kNFS+VPiDf+bOolSZSY7y9uePJoG3KcMsMfFEKyOofSaV0UWxzA== X-Received: by 2002:a19:7604:: with SMTP id c4mr5358484lff.132.1600095440190; Mon, 14 Sep 2020 07:57:20 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:651c:555:: with SMTP id q21ls1439809ljp.3.gmail; Mon, 14 Sep 2020 07:57:17 -0700 (PDT) X-Received: by 2002:a2e:a550:: with SMTP id e16mr5693625ljn.125.1600095437716; Mon, 14 Sep 2020 07:57:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600095437; cv=none; d=google.com; s=arc-20160816; b=xqjwmZl7eGT0eqUc22gybax3t4L8B2NQcc1LwxgMjU7ugNleTha0Df0tsSO4E9uniB 0duWYWlrJ5T0LyDbvffVa4kUNA2qcVLyz7fvx7OJmudk4r7V9Cn/kz1Nx7Vn6XX0p9tV F0+qpeHbyWiyhchivavRuasHqz1iqMWvuF8AtsrnhD8QARiDAUvlvphQS5oUElcqYk+T KW7sSmX/Ucjbi2VSohNGIZhF21usjOi5XmFm+XyZ49AgKQAzEcDH6EpfyvV8J84MxDQJ sAFpY798GtmZdl6wPgfmBXt84vRYPFocbdD8h9qNfK0xsKnH4kMECAcseP2/fX9LV+DG rTtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=Ouiv3odJOeVkWSIMWudZt77y/mRD0OdVwbhcBaXg/Jk=; b=l+bexx/6t/Z9zSyOD50qipnpuq9vSAOziU9nLs8qw+a/3Ni0M3C9HZ+LrChflAbmCL Tf5k39DjQi45TfiY8TbgH+ymANnCrCV9RgfcZWHlIvgrxWvuOrT20CuJQ5Ip9Qz3r6kr 6VGOQjqPtQhZ3epRKKhvffFjnf8x1gAAMlxcwkZRNcL63eu4WFSrmN9O2OuLjKwsthhC /ifTMjQtWkeILZRIO1P3IwycSPZQIje7koRaEmEwx55QtNL+YgcotXDTFjqze68oBODc b6vNVuFr2+EfuWYIO0kGXZ0N6NpZmeO7i3Vj7q0WP+3qaT/USjbXyv0T3q7vb1nvRyVg 5ZMQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from david.siemens.de (david.siemens.de. [192.35.17.14]) by gmr-mx.google.com with ESMTPS id 11si260132lfl.4.2020.09.14.07.57.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Sep 2020 07:57:17 -0700 (PDT) Received-SPF: pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) 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 08EEvGfK004646 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 14 Sep 2020 16:57:16 +0200 Received: from MD1ZFJVC.ad001.siemens.net ([139.22.42.140]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id 08EEv7pR008872; Mon, 14 Sep 2020 16:57:16 +0200 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH 10/14] suricatta: Adapt to CHANNEL_PARSE_NONE Date: Mon, 14 Sep 2020 16:57:08 +0200 Message-Id: <20200914145712.4989-10-christian.storm@siemens.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914145712.4989-1-christian.storm@siemens.com> References: <20200914145712.4989-1-christian.storm@siemens.com> MIME-Version: 1.0 X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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: , Adapt suricatta modules to CHANNEL_PARSE_NONE instead of CHANNEL_PARSE_RAW where CHANNEL_PARSE_RAW was used but the response body actually not. Signed-off-by: Christian Storm --- suricatta/server_general.c | 2 +- suricatta/server_hawkbit.c | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/suricatta/server_general.c b/suricatta/server_general.c index e346295..57c09a8 100644 --- a/suricatta/server_general.c +++ b/suricatta/server_general.c @@ -106,7 +106,7 @@ static channel_data_t channel_data_defaults = {.debug = false, #ifdef CONFIG_SURICATTA_SSL .usessl = true, #endif - .format = CHANNEL_PARSE_RAW, + .format = CHANNEL_PARSE_NONE, .nocheckanswer = true, .nofollow = true, .strictssl = true}; diff --git a/suricatta/server_hawkbit.c b/suricatta/server_hawkbit.c index 05337f4..95a0a8b 100644 --- a/suricatta/server_hawkbit.c +++ b/suricatta/server_hawkbit.c @@ -316,6 +316,7 @@ server_op_res_t server_send_cancel_reply(channel_t *channel, const int action_id channel_data_reply.url = url; channel_data_reply.request_body = json_reply_string; channel_data_reply.method = CHANNEL_POST; + channel_data_reply.format = CHANNEL_PARSE_NONE; result = map_channel_retcode(channel->put(channel, (void *)&channel_data_reply)); cleanup: @@ -325,11 +326,6 @@ cleanup: if (json_reply_string != NULL) { free(json_reply_string); } - if (channel_data_reply.json_reply != NULL && - json_object_put(channel_data_reply.json_reply) != - JSON_OBJECT_FREED) { - ERROR("JSON object should be freed but was not."); - } /* * Send always a notification @@ -433,6 +429,7 @@ server_send_deployment_reply(channel_t *channel, } channel_data.url = url; channel_data.request_body = json_reply_string; + channel_data.format = CHANNEL_PARSE_NONE; channel_data.method = CHANNEL_POST; result = map_channel_retcode(channel->put(channel, (void *)&channel_data)); @@ -445,10 +442,6 @@ cleanup: if (json_reply_string != NULL) { free(json_reply_string); } - if (channel_data.json_reply != NULL && - json_object_put(channel_data.json_reply) != JSON_OBJECT_FREED) { - ERROR("JSON object should be freed but was not."); - } return result; } From patchwork Mon Sep 14 14:57:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 1363682 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::33a; helo=mail-wm1-x33a.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbtuj735akgqegxsqcdy@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=siemens.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=NA5xVJ6b; dkim-atps=neutral Received: from mail-wm1-x33a.google.com (mail-wm1-x33a.google.com [IPv6:2a00:1450:4864:20::33a]) (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 4BqqGB4d9gz9sVq for ; Tue, 15 Sep 2020 00:57:22 +1000 (AEST) Received: by mail-wm1-x33a.google.com with SMTP id q205sf1642951wme.0 for ; Mon, 14 Sep 2020 07:57:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1600095439; cv=pass; d=google.com; s=arc-20160816; b=I9H1cXawyv3DlFBlbHshw3CPqiMEmQSqUlDjdFe1eisqy0glIgdqPEwju4OcMN2RZy cCx9F3jGSrt0ihfRAKWgnC/NDd8DwOArpFN3eYVk+0dMfPOKa7AVVDXLjB10X16E++rq 8GzObVHp+fZV1i2XWNP8oWwn5mQjPm2Q9vRkNYVAk0/qBpsfG1wbHWgyOyAvjd+F+3n7 PqcTvO516c9I2XGtYdlThM7FIjiHROBgbR54xTke2OcdjxYxooO2hAV04Fuc3F1PUntq pdKVjqNFDDlGU9AbzL0PNsG40ydg+XFcna5R8xfLEce3heBTp+E4Q6oWEyLtk6jsCDwS iRtw== 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:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=rPD8oZyc0K/AQUs9nxSzUo9yZG+zG4Vlaxw84vcLjxk=; b=gcQ8olSzf81QCC46r8uQbDQM5mz0QV8FXeBUvAKiHbb40wsyMeF9vCCxYOUqWDASH9 if5jw4vsQUmWqNDwA8CI3SyLr3OdxvLDFpaLjVMluWOl9bgrCzA96hZi/GuI4i2wl2Bj xnVETg6OaIruNtttTj3IT6fxtbanIfPF41+zf3XJAzD1+GwdXFppi0AtR1VhP48BbR3I 3M0xj3PN85+RKN8cSc9p7laM6S0Ks2fQxkMDlIzYnrjotvqjpCODjQZgni170xZv4ih1 /wVFCkwRQw/nzxvZRYHvgNHYZ/fajHo3vcMh6p0PL2me/0zM8Kna2wHlEwlL6l9ABYPF SQOQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :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=rPD8oZyc0K/AQUs9nxSzUo9yZG+zG4Vlaxw84vcLjxk=; b=NA5xVJ6bOusjPF6QtnpSTDSycpNSLokS8JDWia/mTNPDbYJOiZhErZPwZbAO4E8wVV oR6uyKbyHTDVF3wWy0ZQ7j8QwEt9480BHMMCd85PFTYDQBmPvGbl2yj9ZW3ioopoSlJN w6OnKJsQz8xz+FzJJ5Voa/QJvms4zhM1emM16tHpzR54VFx3ak1+w9vmpAkvfwCTDIkm PuUWo4FWHC6hsyGr6bu+EqK5pdF/V6Pgd/aTTvw3p/g/8dgPiMCsVRfDBFi6b0OjfDGU +MiODKw4di5uScFTkSKZmxNnHvcRzxlQ1VnMovpiPuorZ0DxPD5pdMeRWRys/fH0z9zP w49g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references: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=rPD8oZyc0K/AQUs9nxSzUo9yZG+zG4Vlaxw84vcLjxk=; b=WgXbCpA5Yr4b3SMTmZqdl4osc7cJ2eIZ8+CB3g/+P7ePoMzbS1IIcO2nZKW3Dyg42h 0se9fLHI1b7ohCBCW4qPuSnNtWLma7g6oRSN1JmbjWKyzWYwE5hpG61qFKCD+lJEzVTj mKsJ0VXmkTRMoToBYveGSTy3i9j4y73dvIwEXOIu+uBteKE5BDmVnAMFZBh+yLVpYnrP gEGgMDXFEGzYm69okbiPhj9LE/XmLuH76mWPvqXt2IzOCNrY5jr/I7nAXeWkuce6s/sn MFdb9AwMpe1EHhqtes1PVQBnxbF/2rtvT3ol3i4NFvSTNZniMhb8GsEJ6OF07v+wOsGV C3mw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM53238jSe8tZjB5BTwI2lnZv+/UVPQF1H5wF8h5XFMeuaI5zV1LL/ ujq61MQrgU0C46WeqseaP5k= X-Google-Smtp-Source: ABdhPJy36H+7Y4C3V4FAV3tLM7t45pJiKKTz+lDCUTOajX8YM3UNSV6OKkPqmWgCx+CjsUmLU4y0qA== X-Received: by 2002:a7b:c959:: with SMTP id i25mr10394628wml.39.1600095438947; Mon, 14 Sep 2020 07:57:18 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6000:8:: with SMTP id h8ls8358313wrx.3.gmail; Mon, 14 Sep 2020 07:57:18 -0700 (PDT) X-Received: by 2002:adf:dcd1:: with SMTP id x17mr17533349wrm.150.1600095437918; Mon, 14 Sep 2020 07:57:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600095437; cv=none; d=google.com; s=arc-20160816; b=0aA0wRJuQK42N5SOPbgB0GOKfhXrAWQn25j5a8L//MoyPnpRhJMimuQwRyFwUI992G YppWDaYmLpSAN7MWI5VhHLJJ6gqVUuH9JkI3JRw3U80N+pv1lAbnYgI/f14FeDOSJ7KU vc0bWNUL2dJ0XrgKzU0Gf/oM0KMg4eabg1jIBVHl7L2fshsbMkGLIBhMgeRFyw/hI+1l coKfMcLNTFZqbD5yRmDmWeu48qcZ9Dpoqaxzzw0bUdaCIiWjHifH69i61zA68OaUY4nF XmA9UxUqXDI58Ucu1OE84sfDjKTDOP6lenQhDzn/EAdzPgHCdYmaCSs2sfb/SbAeuYlZ 0YoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=qyCTt5jiYX+HgnBuP+dJfgDsOGq0bJR2Uq0JJps6xtA=; b=aKJdnfnFl2nJUTLbsRJaJGCWN3/oWq4EDrk1HTruuOrIZnRFsv7DyU7ZW6dif/piQO RsiuLpiazFYJ9Uqoe2PpH3lobR7mWBF7QlTRN1Q1PMSUn+/2XwP8GonWHwRzzRXhSJer Q1aG/6+8PdobM/cUh9OVsWiVgspiJKqLJEQtdWfg/0ooeXiS2KfsihDe0vA+0KCXe+pI OCCrMoup0hxMVwTKL1p1NGxX5MC4WzY9COgjGfXL24T+q9lqnP6ZDBfuepvy4ec5VmZg fnGap+j5A/zt138v88z737k1NJF44VjQfSJw6NZc2angNPnZ3QPzdE7QZPU9pEBXJVeq xhMA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from david.siemens.de (david.siemens.de. [192.35.17.14]) by gmr-mx.google.com with ESMTPS id s69si264752wme.2.2020.09.14.07.57.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Sep 2020 07:57:17 -0700 (PDT) Received-SPF: pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) 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 08EEvH2N004666 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 14 Sep 2020 16:57:17 +0200 Received: from MD1ZFJVC.ad001.siemens.net ([139.22.42.140]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id 08EEv7pS008872; Mon, 14 Sep 2020 16:57:16 +0200 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH 11/14] channel_curl: Pass through dry_run flag Date: Mon, 14 Sep 2020 16:57:09 +0200 Message-Id: <20200914145712.4989-11-christian.storm@siemens.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914145712.4989-1-christian.storm@siemens.com> References: <20200914145712.4989-1-christian.storm@siemens.com> MIME-Version: 1.0 X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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: , In order to enable channel_curl users, e.g., suricatta modules to perform dry runs, pass through the dry_run flag via channel_get_file(). Signed-off-by: Christian Storm --- corelib/channel_curl.c | 2 +- include/channel_curl.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 8c4efa9..c6b45bc 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -976,7 +976,7 @@ channel_op_res_t channel_get_file(channel_t *this, void *data) file_handle = ipc_inst_start_ext(channel_data->source, channel_data->info == NULL ? 0 : strlen(channel_data->info), channel_data->info, - false /*no dry run */); + channel_data->dry_run); if (file_handle > 0) break; sleep(1); diff --git a/include/channel_curl.h b/include/channel_curl.h index 5f312ea..6b4f4da 100644 --- a/include/channel_curl.h +++ b/include/channel_curl.h @@ -44,6 +44,7 @@ typedef struct { json_object *json_reply; #endif char *raw_reply; + bool dry_run; char *cafile; char *sslkey; char *sslcert; From patchwork Mon Sep 14 14:57:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 1363678 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::63a; helo=mail-ej1-x63a.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbuej735akgqehghniiq@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=siemens.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=B9YWb26V; dkim-atps=neutral Received: from mail-ej1-x63a.google.com (mail-ej1-x63a.google.com [IPv6:2a00:1450:4864:20::63a]) (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 4BqqGH07yMz9sVt for ; Tue, 15 Sep 2020 00:57:26 +1000 (AEST) Received: by mail-ej1-x63a.google.com with SMTP id hh10sf8136946ejb.13 for ; Mon, 14 Sep 2020 07:57:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1600095441; cv=pass; d=google.com; s=arc-20160816; b=N79hJR5rvbvLVhaWny+lKZLAt4NPynCv8GviB5POoU7yp0J9v2yH1hxDLT8ij7Rfaj hFEIEnzJOJmFxnYy+qw9YsOcEQmXVfMQXs2ungKdAEMbvk/7gLLTJsJVbFZNHA61vU/D xctgqkxOMjguBYhdtCZzy0uVPvHJ2LyOXWT+ooD7+iaOZcW126BGaWK/pPS5EB/rGCjW a85uMmg4k/YNoMLPu9NTJUAFnhgXiqIhj+gtRZLqFVxBRpxMGBd8GslDICAG1ZoXhzlq +8GlScLaxlrudaJRCAbe1/q1vVEKhASzcaUFHykZFnf3mx16s6/fdmL126PHb4+fVK0g OEJA== 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:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=EaHpeTKyU1WclpuzEbe895whD82Wy1jSTh28SJbEOCk=; b=Mj346ca6sYUe8cinv1pMmeXRi8IITnRnrjSIJQy1LCxwkKqXOhLKLXHcqHKtxnM8/x c3wulTE6vw9Z4vVqIKm9VswDnvSCT+vYFltaRR6/hI66wn874ZaE5J/MhV1/LTBhwbkk gfNo2SekrMvA5Ev2s5z6ZhJMhb4sG9dfnIhW6svfOqK7U4Upg8SMSxu4Jui7PwMndk/v 7UIxhd8HWlFM/rvdCqZJRQCSLHkazOQ7vSTNrYQDvRcS5AvJt9KYRFilLzUFOjmyYYH2 s0HBD/hhnAuocigksig801thqDHhkrHkIpBJROBKp0tStJcc3msUny6uiJa77j2POyxN zZ9A== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :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=EaHpeTKyU1WclpuzEbe895whD82Wy1jSTh28SJbEOCk=; b=B9YWb26VUmVw/uc3BvcvLfppCocL5SXO61zYMKsRYnRVKiLq4+q09rNj+lF/RKK0y4 VfEdshX0LXdMz29LBSJKAp6+NMfCVa8hvTYtZ5hYUMkp5/ybbguYuqttjiQIAS+yTqhx b54s3sQzlqKqXBJ09aYhHl32sky3QHdGWrtxAu9jiVqahsjhNm0TezOLAqhTqHpfp/Co B9N31H+ViuNevTm14nbKYU1eJoWw+2x+cgajoSE2KAZ+0EPG5ja7djmmMBsG72Kr2CRn ESw0ixE68guzg5k+CGw5qwn5C2cNNfyWj5pjTcfwvA+FoOviBjh956cXhO12M/RCajGn fGww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references: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=EaHpeTKyU1WclpuzEbe895whD82Wy1jSTh28SJbEOCk=; b=PztkmXVBt7Tvi6R3PZxoZ8yBuvBPiJVO+rnkQrQrybN/dAzyZp7wpQ+zPyQtrB8/mm Z+YSwluKQOmFbHCJ4OTvIojT9ewRohLDEgRRVCOKd1LcEtKYzYMpnWZ4kvmOOz2D56J+ uXckgYYzP3tRuiPfI2YBhMCPT1xgf4veYB5MG0ATfAafLL+dtc8bGa/gNoLIvqmJusYF HbKkiiQHQi99yRMdHsk2FwpOOP6LMGV4irAA1Dm9pl+b1yAYAata6Q3TorOI86g4TDYd cAYfEHE8kzuTT4B4zRXNwk56YIgZOO9HGTrbSfo+oAtmbVcAwgVtp5e90AftLEy8o3ZG b28Q== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM530M4UI+A2iOER+YmkbyDRm3ZzAc/d19jd5k2gn0BM3N++UO7Kif fgvC6cYR1OcgbuXre5b3oHQ= X-Google-Smtp-Source: ABdhPJxJv2nuJUgNI3X6r3q/iz3u901w/mBBek3affb+gIBLny8A/KaGdQcNnnxIv6LW0Tp5XGdZpQ== X-Received: by 2002:aa7:c6cf:: with SMTP id b15mr4357273eds.134.1600095441278; Mon, 14 Sep 2020 07:57:21 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:aa7:c9c2:: with SMTP id i2ls11393989edt.2.gmail; Mon, 14 Sep 2020 07:57:20 -0700 (PDT) X-Received: by 2002:a50:f102:: with SMTP id w2mr18080541edl.63.1600095438654; Mon, 14 Sep 2020 07:57:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600095438; cv=none; d=google.com; s=arc-20160816; b=dxXe0KaSW2JucEx+kwPtfIUiTzVfbOYGIr+lbiCMzMymIJoq6eWeoPVqq1bOefr0+p bHLkzwt4GhD8llG3nyfPDhQtCmgZokIqbZtAQL9+wbxc6zXIQ4WR1TMm+7mdmgb6/HN2 zQi/y6LN98Z5w6tsSQWvpsTv9dPCVgFNa4JHbwWXc9r6EWQ9F75RTaQi/XsApWYky71c sU/pvLF2Y40hm0Lgn5ScOpJZRk9ftHkeK5RWdepHXMhOJaPF3AC/C9ZxrZfBk+15dPuZ 2x7/25VD3P6S6pfu/UKDd0LKHLWk/xii4866rEEmfYjqUaEN1or5LfJyQaaaKhvEuhGi 84Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=sqRcRTp6YSCClzGB8YzvzUhRSHt8hqacA3Ka9GlbQu8=; b=m5LS46rCLCIZ7S5CiT0PekU+flY8be/lQpVoHDiJrNO3SPG3dK33B8Z8sPDIcyIjMe C3EHQT9//MAMw9x68fqTzU8EYcmtaY3S1z2hamlIXW3HFt+AXsYMAa451FHqLOJ15SYw Mwko5uBiuPZKBhdIcqQgPOTVcr3DjYulQFAEvnfZIdS20+leS7c5365BrLsQWN1e3cDF ShbW1dEoXqjXcMaC0O99paDZj9QFyBi/txen58n7S2RlS+uZUQtHV5T/HrLbrbHl3IW1 g5asJYpWCZBw4tlQG4F3OMog8XXXbV/e6CsFPnsy4NXzNQ11kkO4POyqj25iXV9dp0Wg cSyA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from thoth.sbs.de (thoth.sbs.de. [192.35.17.2]) by gmr-mx.google.com with ESMTPS id f17si345518edx.5.2020.09.14.07.57.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Sep 2020 07:57:18 -0700 (PDT) Received-SPF: pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.2 as permitted sender) client-ip=192.35.17.2; Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id 08EEvIJN032318 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 14 Sep 2020 16:57:18 +0200 Received: from MD1ZFJVC.ad001.siemens.net ([139.22.42.140]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id 08EEv7pT008872; Mon, 14 Sep 2020 16:57:17 +0200 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH 12/14] channel_curl: Rename to channel_callback_ipc() Date: Mon, 14 Sep 2020 16:57:10 +0200 Message-Id: <20200914145712.4989-12-christian.storm@siemens.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914145712.4989-1-christian.storm@siemens.com> References: <20200914145712.4989-1-christian.storm@siemens.com> MIME-Version: 1.0 X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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: , Rename the method channel_callback_write_file() to channel_callback_ipc() in order to be more suggestive. Technically, it writes to a file but that "file" is SWUpdate's IPC channel, so (re)name it accordingly. Signed-off-by: Christian Storm --- corelib/channel_curl.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index c6b45bc..b69eb3b 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -54,7 +54,7 @@ typedef struct { /* Prototypes for "internal" functions */ /* Note that they're not `static` so that they're callable from unit tests. */ -size_t channel_callback_write_file(void *streamdata, size_t size, size_t nmemb, +size_t channel_callback_ipc(void *streamdata, size_t size, size_t nmemb, write_callback_t *data); size_t channel_callback_membuffer(void *streamdata, size_t size, size_t nmemb, write_callback_t *data); @@ -155,8 +155,8 @@ channel_op_res_t channel_open(channel_t *this, void *cfg) return CHANNEL_OK; } -static channel_op_res_t result_channel_callback_write_file; -size_t channel_callback_write_file(void *streamdata, size_t size, size_t nmemb, +static channel_op_res_t result_channel_callback_ipc; +size_t channel_callback_ipc(void *streamdata, size_t size, size_t nmemb, write_callback_t *data) { if (!nmemb) { @@ -164,14 +164,14 @@ size_t channel_callback_write_file(void *streamdata, size_t size, size_t nmemb, } if (!data) return 0; - result_channel_callback_write_file = CHANNEL_OK; + result_channel_callback_ipc = CHANNEL_OK; if (data->channel_data->usessl) { if (swupdate_HASH_update(data->channel_data->dgst, streamdata, size * nmemb) < 0) { ERROR("Updating checksum of chunk failed."); - result_channel_callback_write_file = CHANNEL_EIO; + result_channel_callback_ipc = CHANNEL_EIO; return 0; } } @@ -179,7 +179,7 @@ size_t channel_callback_write_file(void *streamdata, size_t size, size_t nmemb, if (ipc_send_data(data->output, streamdata, (int)(size * nmemb)) < 0) { ERROR("Writing into SWUpdate IPC stream failed."); - result_channel_callback_write_file = CHANNEL_EIO; + result_channel_callback_ipc = CHANNEL_EIO; return 0; } @@ -990,9 +990,9 @@ channel_op_res_t channel_get_file(channel_t *this, void *data) write_callback_t wrdata; wrdata.channel_data = channel_data; wrdata.output = file_handle; - result_channel_callback_write_file = CHANNEL_OK; + result_channel_callback_ipc = CHANNEL_OK; if ((curl_easy_setopt(channel_curl->handle, CURLOPT_WRITEFUNCTION, - channel_callback_write_file) != CURLE_OK) || + channel_callback_ipc) != CURLE_OK) || (curl_easy_setopt(channel_curl->handle, CURLOPT_WRITEDATA, &wrdata) != CURLE_OK)) { ERROR("Cannot setup file writer callback function."); @@ -1081,7 +1081,7 @@ channel_op_res_t channel_get_file(channel_t *this, void *data) channel_log_reply(result, channel_data, NULL); - if (result_channel_callback_write_file != CHANNEL_OK) { + if (result_channel_callback_ipc != CHANNEL_OK) { result = CHANNEL_EIO; goto cleanup_file; } From patchwork Mon Sep 14 14:57:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 1363679 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::33d; helo=mail-wm1-x33d.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbuej735akgqehghniiq@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=siemens.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=lJTLvEHH; dkim-atps=neutral Received: from mail-wm1-x33d.google.com (mail-wm1-x33d.google.com [IPv6:2a00:1450:4864:20::33d]) (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 4BqqGG23Ccz9sWJ for ; Tue, 15 Sep 2020 00:57:26 +1000 (AEST) Received: by mail-wm1-x33d.google.com with SMTP id 23sf91029wmk.8 for ; Mon, 14 Sep 2020 07:57:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1600095440; cv=pass; d=google.com; s=arc-20160816; b=RwN8qGQJrB7kl7dKwShV2MuwS/SnEbOLPba3lucwhlNA4E0Fwjj27ls/2afi53pl5u kNv49CSAPBHgAXCdBnFi9QNs34uu+9JZWHj1VAhNoBncsk5EBPx3hAFCiW7Jf6+rh3KR nDhSsOXzPjhqBtosB9xmF7GJgMIbGJVF7aupi3fktd7p1zXgNmacQXMZVId+6VouiEQp Nkrfcw4wXFrqdfGmJ7Ar/tTTRc3oO0khZ2ZHKWfcLFGq7VwwSQhK0aG4J9xhVA4Pk6kx dBaTw65Twb+zU1Oo6ENB8XfmJWZQ8884Ectil/Yi6WaFuJNQrnAQ5JDI00CbrTUlaLJv 7M9A== 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:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=wiTxza5hZqBJ/PgrLD/B/3Yuew0LIDD48pkGDSC//H4=; b=zqTlMHAW2vITEV3t2RkTinRWDk49s8YMyHOLGgxoNmMbAH//PYjD2wwRqB/cIBHO8Z hDCA0BgxiYJqAGX09B1SeX+v4cWnTm+fjOrWwzIgj4991EKFStaO6WL4JfQT8156wPiM 0L4rMNV34dTXU1WzThT7YTY6Yw7iZfnKf4dM3ZS2raX1eXBmX2Mhqv+opSWWT7IdfwTU yEwdpbnxJqvHoP2fJbdJUw3Lw3z1EIvFy2El2hT0/PZrZFg4QDLRQnHjTMVaiGwvxZrQ rvTdOKn3jW8un1aIGRogwGNQHPUPRbQGEOUXOO615fa97zUZufP5+HQWRmJvbQhN0+Qf zKwA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :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=wiTxza5hZqBJ/PgrLD/B/3Yuew0LIDD48pkGDSC//H4=; b=lJTLvEHH2RDbbpS0090XXc7choEC0cV5ZjtI4FV49Bl175d1slgQHqyXQ0ci8hJn6+ 295wSLmHgPmdBuPprKEqvo7WYOJliKQ5FAAX4cF09JcVv2qbuPPeKoPUHQO3hIt9CjED dYso+OnlW/L35LV3jYU7wfab+JW5ok/2puQTSklI/goKYl4ZxWt20QC5YStLcRjZBFth w3gvgm7gk6UX4oXvR2uNmA6QdrolM4elzSBaP16HJMB4Zyv8cahYW8vQ4XQpPB1/o8ug cQ5jJCknsYpTVF1sWSkvvxwIk5jdf8Mm7bRRSsm2A57TYrQAk9wlzqUPeTuJ1fuf371I dzIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references: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=wiTxza5hZqBJ/PgrLD/B/3Yuew0LIDD48pkGDSC//H4=; b=Xbv2f2mMbNbBol9sUjDe2jghOmaf6oAYjRP+FrsDk0yt4kT8GY2xQRzBzX2oJJ1VNo uysOkmuDWNgQLYe/zCrUeb5/ei4NE/HQAirM4DyrpScqJxdFOMQnlS8dAXU+AOUMYuo1 DZSlyOk4tLHry8hArK3FEc5PwfUZkaBH6wFxmig5CNYVXaJtQXM308cAHU1h8PEx+RBk eEeWz1kNy5xrewqtDJ73x4/Tp/xU5HkwCIMBWfV8k3XDN2A7Qu+T6Ky99sJGfWkmH9hf r9j80tpxy3hM+qCbh7VmVKmMIphV/GApA2BJiNXiyNmREdkHDHCw/uJzqtCL4KbMXGTh AhzQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533D2Ym6GQg8Jj/tEPpOzpyGMJkFGBrUsgBXSOKIDBwgO7z+2ser 10uW7YSP0LGQt5m2Nm7Hfp4= X-Google-Smtp-Source: ABdhPJyMnpnUyaiFziyBlYSp327m2QifZABIYxPwFJCY3pcpZVJ5L/oaldE7wh9DUV2KgxS1jRFpkg== X-Received: by 2002:a1c:f719:: with SMTP id v25mr11967229wmh.159.1600095440521; Mon, 14 Sep 2020 07:57:20 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a1c:80d7:: with SMTP id b206ls4849012wmd.1.canary-gmail; Mon, 14 Sep 2020 07:57:19 -0700 (PDT) X-Received: by 2002:a1c:7918:: with SMTP id l24mr15869967wme.46.1600095439500; Mon, 14 Sep 2020 07:57:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600095439; cv=none; d=google.com; s=arc-20160816; b=0obz05gA/PeVCmONVsVueNdXYLx/04U8tKpmIraHOVxMsEbeYTZdYVF8j8Tl+lnCPq /SnakMkALK4k3uGC8NYNyTFHGHogJV990l4AkwFM6hm0Dpl8IXUoiNla2KFzVjf694QI 7rP5oUdzUfI0GpT8x6aNToPB9IHKT2NF7YhHCuhpOobqkeN1330cBSL+CKhZ/iy//+qV aQUcxy2O5w9sG59LYVrUdPOIbm2W7FSWnK/qCKVpzYLbCTP447pJCQMdtxFJDK8nMqF8 P5hj29yK2emWlUJHcYrOUlkcHCN0ycUFG+nfj1u8WBLZYMMifr9aq8xQpOLkY7XihohH XzWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=G16roBHTNGzaplsk96SYMY7xKnH6tlHrGXxq017/xgs=; b=Ernoi1vMgzzy7arNx6BCF1bML/0LBb4TgeOSp46C9Dnjh5CCX/7ylubsANBZoe8m2T zYNt1EUKx5bVg1+MH67FwxTlKuk6LWSThaX/obZU1PFkThROzd49ZpJBca2usoUPd8+C RICadlibF8OxT8JFHfa/L1EgLaMEOc9IXkcJWwUjoPaIVJxxnx7NAzyoDEclggpF/xLr Um9wcS0ntwlBDx9zhz7ZyEhQC84IRkqL15OQYVhZvY5Bsnrl20UT1f6ziB0RIl/kyIfp tppmm55cY5c4l6RK+dQ/6FT0XzN47HYfyJjHdT2bzeFgxrOEMfrPdkTxQ9u/Y7nognd3 42gg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from david.siemens.de (david.siemens.de. [192.35.17.14]) by gmr-mx.google.com with ESMTPS id 21si345520wmj.2.2020.09.14.07.57.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Sep 2020 07:57:19 -0700 (PDT) Received-SPF: pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) 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 08EEvJkC004721 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 14 Sep 2020 16:57:19 +0200 Received: from MD1ZFJVC.ad001.siemens.net ([139.22.42.140]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id 08EEv7pU008872; Mon, 14 Sep 2020 16:57:18 +0200 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH 13/14] channel_curl: Make setting channel operation method symmetric Date: Mon, 14 Sep 2020 16:57:11 +0200 Message-Id: <20200914145712.4989-13-christian.storm@siemens.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914145712.4989-1-christian.storm@siemens.com> References: <20200914145712.4989-1-christian.storm@siemens.com> MIME-Version: 1.0 X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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: , Move setting the channel operation method to the method implementations so that channel_set_options() only sets options common to all methods. Signed-off-by: Christian Storm --- corelib/channel_curl.c | 63 +++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 35 deletions(-) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index b69eb3b..5142c71 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -60,8 +60,7 @@ size_t channel_callback_membuffer(void *streamdata, size_t size, size_t nmemb, write_callback_t *data); channel_op_res_t channel_map_http_code(channel_t *this, long *http_response_code); channel_op_res_t channel_map_curl_error(CURLcode res); -channel_op_res_t channel_set_options(channel_t *this, channel_data_t *channel_data, - channel_method_t method); +channel_op_res_t channel_set_options(channel_t *this, channel_data_t *channel_data); char *channel_get_redirect_url(channel_t *this); static void channel_log_effective_url(channel_t *this); @@ -475,9 +474,7 @@ static channel_op_res_t channel_set_content_type(channel_t *this, return result; } -channel_op_res_t channel_set_options(channel_t *this, - channel_data_t *channel_data, - channel_method_t method) +channel_op_res_t channel_set_options(channel_t *this, channel_data_t *channel_data) { if (channel_data->low_speed_timeout == 0) { channel_data->low_speed_timeout = SPEED_LOW_TIME_SEC; @@ -620,27 +617,6 @@ channel_op_res_t channel_set_options(channel_t *this, } } - switch (method) { - case CHANNEL_GET: - if (curl_easy_setopt(channel_curl->handle, CURLOPT_CUSTOMREQUEST, - "GET") != CURLE_OK) { - result = CHANNEL_EINIT; - goto cleanup; - } - break; - case CHANNEL_PUT: - if ((curl_easy_setopt(channel_curl->handle, CURLOPT_PUT, 1L) != - CURLE_OK) || - (curl_easy_setopt(channel_curl->handle, CURLOPT_UPLOAD, 1L) != - CURLE_OK)) { - result = CHANNEL_EINIT; - goto cleanup; - } - break; - case CHANNEL_POST: - break; - } - if (channel_curl->proxy != NULL) { if (channel_curl->proxy != USE_PROXY_ENV) { if (curl_easy_setopt( @@ -808,8 +784,7 @@ static channel_op_res_t channel_post_method(channel_t *this, void *data) goto cleanup_header; } - if ((result = channel_set_options(this, channel_data, CHANNEL_POST)) != - CHANNEL_OK) { + if ((result = channel_set_options(this, channel_data)) != CHANNEL_OK) { ERROR("Set channel option failed."); goto cleanup_header; } @@ -822,7 +797,7 @@ static channel_op_res_t channel_post_method(channel_t *this, void *data) (curl_easy_setopt(channel_curl->handle, CURLOPT_POSTFIELDS, channel_data->request_body) != CURLE_OK)) { result = CHANNEL_EINIT; - ERROR("Set channel option failed."); + ERROR("Set POST channel method option failed."); goto cleanup_header; } if (channel_data->debug) { @@ -875,12 +850,18 @@ static channel_op_res_t channel_put_method(channel_t *this, void *data) goto cleanup_header; } - if ((result = channel_set_options(this, channel_data, CHANNEL_PUT)) != - CHANNEL_OK) { + if ((result = channel_set_options(this, channel_data)) != CHANNEL_OK) { ERROR("Set channel option failed."); goto cleanup_header; } + if ((curl_easy_setopt(channel_curl->handle, CURLOPT_PUT, 1L) != CURLE_OK) || + (curl_easy_setopt(channel_curl->handle, CURLOPT_UPLOAD, 1L) != CURLE_OK)) { + ERROR("Set PUT channel method option failed."); + result = CHANNEL_EINIT; + goto cleanup_header; + } + if ((curl_easy_setopt(channel_curl->handle, CURLOPT_READFUNCTION, put_read_callback) != CURLE_OK) || (curl_easy_setopt(channel_curl->handle, CURLOPT_INFILESIZE_LARGE, @@ -966,12 +947,18 @@ channel_op_res_t channel_get_file(channel_t *this, void *data) goto cleanup_header; } - if ((result = channel_set_options(this, channel_data, CHANNEL_GET)) != - CHANNEL_OK) { + if ((result = channel_set_options(this, channel_data)) != CHANNEL_OK) { ERROR("Set channel option failed."); goto cleanup_header; } + if (curl_easy_setopt(channel_curl->handle, CURLOPT_CUSTOMREQUEST, "GET") != + CURLE_OK) { + ERROR("Set GET channel method option failed."); + result = CHANNEL_EINIT; + goto cleanup_header; + } + for (int retries = 3; retries >= 0; retries--) { file_handle = ipc_inst_start_ext(channel_data->source, channel_data->info == NULL ? 0 : strlen(channel_data->info), @@ -1141,12 +1128,18 @@ channel_op_res_t channel_get(channel_t *this, void *data) goto cleanup_header; } - if ((result = channel_set_options(this, channel_data, CHANNEL_GET)) != - CHANNEL_OK) { + if ((result = channel_set_options(this, channel_data)) != CHANNEL_OK) { ERROR("Set channel option failed."); goto cleanup_header; } + if (curl_easy_setopt(channel_curl->handle, CURLOPT_CUSTOMREQUEST, "GET") != + CURLE_OK) { + ERROR("Set GET channel method option failed."); + result = CHANNEL_EINIT; + goto cleanup_header; + } + if ((result = setup_reply_buffer(channel_curl->handle, &wrdata)) != CHANNEL_OK) { goto cleanup_header; } From patchwork Mon Sep 14 14:57:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 1363681 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::13c; helo=mail-lf1-x13c.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbumj735akgqenvlzedy@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=siemens.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=nykGqWEE; dkim-atps=neutral Received: from mail-lf1-x13c.google.com (mail-lf1-x13c.google.com [IPv6:2a00:1450:4864:20::13c]) (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 4BqqGH2zk4z9sWK for ; Tue, 15 Sep 2020 00:57:27 +1000 (AEST) Received: by mail-lf1-x13c.google.com with SMTP id h17sf2515979lfc.3 for ; Mon, 14 Sep 2020 07:57:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1600095442; cv=pass; d=google.com; s=arc-20160816; b=P5MmHBMe9OHSemHi4+aVTFThmvy3OfH4lpBOmphQn2yksv05A1SZ22GefGDFsmLqVl SXHMhAzKk2UoKGZjACDgbkNHKvzIq0rg+6qQncM6wB5pGCLgSf89e5gjGfjqKNzTsyxc qzny1fQ4QrvykLkHDaYI3FQOcTBnSJuyF4ry27VPweFxvNH4QdA0PYMz0E6iTum8UQhq slBZ3QeQ5G64fqYBNnPhZw9N6WpQ1L5wOSuUuo0e6GDFFoPLKpIjVClz1WtrgPKy/tn7 KwE5qPbyly+IT5sxroReoIbb5VbFH7CaJhO9BOCCE52qgrnoAwo+l2bnCMdgYYK9Pq0I jYbw== 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:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=o7qBA4r2Hxv94oxhr03mB8cPWmBAMbYUgakWz7HW1CM=; b=FnR3fdxe6lrgaxmpoimglGr0bCZkDfXxZjmNImvnkYcoCTsVFmFahmXsoSTHNFNMZj kuERAUxvn7LXZ22DdZ3KJbCcD1AEI/KFXIvl2EMjcVRs4aCPvRiSysemr+w11v5BOsO7 Hl//JU7znTZMwWfchxKHzKzjw/VYQzJggarm8J0J1SdG9JiR2z/XIA01FrG+A6FxTp8f J8y8XMX+im+Bs/fpMZ/Hast2bwa+Kzp75QMeNEFsrZufuB7kdKRcdFvoBIOmUkl0Z9SI zms+6soKLN6QX/rmhQnLJiCWsUL6TOQNQLbkF3oxs7B2APQkdBWsDYpVTLfO/ahObyG3 K/ig== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :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=o7qBA4r2Hxv94oxhr03mB8cPWmBAMbYUgakWz7HW1CM=; b=nykGqWEE/TBHgjkBqUwXV5/ScjqAhxAv3hRCN43UG5WeHxQ3kVKp44I5iBRYtzdz2E 4q3yB75CMiWdYrUT4gkj0oB9OnFvoXmMsvlMb/L+YpRzPSV4T5gRbj8Ciawxqnj/X57v 4GDCPUBHuIzNMbwVJdGWo/TeULU5Shj+xIaOHl+b5j2vVwemztMMce8RU0zRfCsW81xi UhF0OHjgaM9scRGnZiuvyoDAyOFxHsXtXxuUdRKhrV/mB+wLL/yrmOx+Nz4vaXRG/KkZ +wkQTNZMg+DuRmEAbxtUc3uygbRic7nkV6CDNEi9K5Ztbw0cgsG7YqxHepW0AXF3qd0v nYjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references: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=o7qBA4r2Hxv94oxhr03mB8cPWmBAMbYUgakWz7HW1CM=; b=XNBfsxa3UvtrsBpeOT1oRann6m8TrnjgVEgEIXdqkQMcd+7uLYe+Z7l2Z0C4fN6FyY 9caAAcFHPytbwSOIHVyK6zZ5KXWVMxeiXPuHjCzwgo3fFmzMSmMbnPy3zMGvGxUVCFQJ 7WK8BfY0bNqDfmLh/2u7nqhTzNu0SAHbwSg4sY8MxuSprzsJ4InwaYfWwVDvFxebuMrC gyEFjNpa5YAVhSmnLB8PF1srSZ2bhYL2ze/pWc5RwcQuJna7ZvX6enfsWN90cxSjaMR4 mUPC3cCnPufge10025b+SwhHqH1IuF18ZiboyNCCIEIon0Ay5xnczVf9Jew4u4etiuLV Pe7Q== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM5301OF6N/WiA7uT3chXergibBjGn0bWVkYR3zPFGqdiOznsgWAQd /lOk7RCzweac/Uza3YzZLDc= X-Google-Smtp-Source: ABdhPJzXXv6g/FPpBiXbUYafqbYfBsASG9TxziApEz4jEQPvkVpopQlG/ODdv0DN6svq5ji6ZkxBtg== X-Received: by 2002:a2e:92d6:: with SMTP id k22mr5663925ljh.332.1600095441860; Mon, 14 Sep 2020 07:57:21 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:ac2:544e:: with SMTP id d14ls36389lfn.2.gmail; Mon, 14 Sep 2020 07:57:20 -0700 (PDT) X-Received: by 2002:a19:4211:: with SMTP id p17mr4960995lfa.480.1600095440575; Mon, 14 Sep 2020 07:57:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600095440; cv=none; d=google.com; s=arc-20160816; b=SX2PHXFfofC2VA/NwFXktfY1YqVLZj+RBgB4Ri14m/PGdG5t5PPLYCpMb2amymWFPP ubr3kS7Kh6TUhwD+Y86qqAyJlfqZs2ARv98OZ6nDUGa/ugpLhWW24d9XCy+SgUVP8Znm 3XcI5Q18scMP+oU7YHYRnDF0jqjE2PySUxnls+grvb2VOPgGqBWOLfNOjGAb5S5xYLcd hmkW50jDpCIDR8HP44G5miineVZcaBS4kxOIN0dwtoSp8zw9ySKojtSdEWEekAvw/lEe em73QbTmxvH8TMbcS/Dhrn0NWRp4RqYceo88PfZw/oU7Bg5iRjH9zm2qrBRzxjbEcHFY 1bxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=TaTfigECXovy3AvJYpooRxvZj2dDAPDcUX+NZIxgSsU=; b=ZvJopSHQUTmsVg7b5ItZYCVJgkFzP+Owvu/N+HBYLaX/rm5p+O1+OBN6hdQ8HLLkjI nUKfUjUW6EdaTJZJBh07oVrlgsojHcoHvgTevbkMZsMAJP7sLAz38ZjputBuw9RHlsnr L3XSj4tIvWkM/g8RTd58fc4b57WFd/zlMrU/Z0B28EfngZk3tu+5OsLsBayPn8h5snxU jn+rdlHcd+/LXnFTnihFBbyvXCHEUqy/fkwCTNjFnCVluOqXkupdC0RAsdRAxWtRhFjc Rb+ZxlNiS87PcXYOhonBAzizGQXVDRrZ2lt/5iq1iApm50c1qyeaidlN5iVIpvxwkvzE v2qg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from david.siemens.de (david.siemens.de. [192.35.17.14]) by gmr-mx.google.com with ESMTPS id f12si407876lfs.1.2020.09.14.07.57.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Sep 2020 07:57:20 -0700 (PDT) Received-SPF: pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) 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 08EEvJNO004812 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 14 Sep 2020 16:57:19 +0200 Received: from MD1ZFJVC.ad001.siemens.net ([139.22.42.140]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id 08EEv7pV008872; Mon, 14 Sep 2020 16:57:19 +0200 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH 14/14] channel_curl: Introduce support for PATCH method Date: Mon, 14 Sep 2020 16:57:12 +0200 Message-Id: <20200914145712.4989-14-christian.storm@siemens.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914145712.4989-1-christian.storm@siemens.com> References: <20200914145712.4989-1-christian.storm@siemens.com> MIME-Version: 1.0 X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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: , Signed-off-by: Christian Storm --- corelib/channel_curl.c | 28 +++++++++++++++++++--------- include/channel_curl.h | 1 + 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 5142c71..6521850 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -767,7 +767,7 @@ static channel_op_res_t parse_reply(channel_data_t *channel_data, output_data_t return CHANNEL_OK; } -static channel_op_res_t channel_post_method(channel_t *this, void *data) +static channel_op_res_t channel_post_method(channel_t *this, void *data, int method) { channel_curl_t *channel_curl = this->priv; assert(data != NULL); @@ -793,20 +793,29 @@ static channel_op_res_t channel_post_method(channel_t *this, void *data) goto cleanup_header; } - if ((curl_easy_setopt(channel_curl->handle, CURLOPT_POST, 1L) != CURLE_OK) || - (curl_easy_setopt(channel_curl->handle, CURLOPT_POSTFIELDS, - channel_data->request_body) != CURLE_OK)) { + CURLcode curl_result; + if (method == CHANNEL_PATCH) { + curl_result = curl_easy_setopt(channel_curl->handle, CURLOPT_CUSTOMREQUEST, "PATCH"); + } else { + curl_result = curl_easy_setopt(channel_curl->handle, CURLOPT_POST, 1L); + } + if (curl_result != CURLE_OK) { + result = CHANNEL_EINIT; + ERROR("Set POST/PATCH channel method option failed."); + goto cleanup_header; + } + if (curl_easy_setopt(channel_curl->handle, CURLOPT_POSTFIELDS, channel_data->request_body) != CURLE_OK) { result = CHANNEL_EINIT; - ERROR("Set POST channel method option failed."); + ERROR("Set POST/PATCH channel data option failed."); goto cleanup_header; } if (channel_data->debug) { - TRACE("Posted to %s: %s", channel_data->url, channel_data->request_body); + TRACE("POSTed/PATCHed to %s: %s", channel_data->url, channel_data->request_body); } CURLcode curlrc = curl_easy_perform(channel_curl->handle); if (curlrc != CURLE_OK) { - ERROR("Channel put operation failed (%d): '%s'", curlrc, + ERROR("Channel POST/PATCH operation failed (%d): '%s'", curlrc, curl_easy_strerror(curlrc)); result = channel_map_curl_error(curlrc); goto cleanup_header; @@ -908,9 +917,10 @@ channel_op_res_t channel_put(channel_t *this, void *data) case CHANNEL_PUT: return channel_put_method(this, data); case CHANNEL_POST: - return channel_post_method(this, data); + case CHANNEL_PATCH: + return channel_post_method(this, data, channel_data->method); default: - TRACE("Channel method (POST, PUT) is not set !"); + TRACE("Channel method (POST, PUT, PATCH) is not set !"); return CHANNEL_EINIT; } } diff --git a/include/channel_curl.h b/include/channel_curl.h index 6b4f4da..c3418a5 100644 --- a/include/channel_curl.h +++ b/include/channel_curl.h @@ -25,6 +25,7 @@ typedef enum { CHANNEL_GET, CHANNEL_POST, CHANNEL_PUT, + CHANNEL_PATCH, } channel_method_t; typedef enum {