From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EF07FA00C4; Fri, 29 Jul 2022 18:00:36 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D53DF4069C; Fri, 29 Jul 2022 18:00:36 +0200 (CEST) Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) by mails.dpdk.org (Postfix) with ESMTP id E4BA640151 for ; Fri, 29 Jul 2022 18:00:35 +0200 (CEST) Received: by mail-ej1-f53.google.com with SMTP id mf4so9310460ejc.3 for ; Fri, 29 Jul 2022 09:00:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xudk1Ncjg0JrAtq3ZCwbmaa3QC4SUR0lknVZZBXf4bo=; b=ArPlNg64AtU13L29PVAF2W0DtIbY3eaQM2QZTQ2O+ihJVEzv/kodWM8UiUEzJj5gDN nDQYIir1aJd62wwl8sFDkHDnVj5tI/iAFV69608aZkvE51Moj4ErtYRvj3CtyHDKOkOq gn8azjSUnv3kSZqTOZBLSsO6SwGdgVVlLpLTKm8eH+CRJcLlHK/PrRDd8SujGAoA4blL qYX//B53yoE9A0Xc2ArsKvLrnsvzs+Ad9597oPUeJ4d+uqPLcsagJ59atyBKYUHobdAk XHXxgvRyH+64nEtcqF3s/yEkIflBqEXctK9lIfIV72iaxo7Z8j3hUrahpWT3fLGL7u1I MTHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xudk1Ncjg0JrAtq3ZCwbmaa3QC4SUR0lknVZZBXf4bo=; b=kArx6l3z52AAZta0J4xelgVQUdOGtjRd25JjkDeKc5HRTC1eU7QChVpvtkSGosGvFb oHdQcOINp9GQjxR5Z0dOR4OlJrQ484xd4tYreUD9T6sHykiUgl68EbkepY0272/TxtFv GFX+rrcMJLg5RDqAmZayMIhuqe0Qm5+M6wxcI6Qg4daPllAWFEsSfQWTjS/+jAFrVL88 JczL6cjkv06YHwQmPyDN7Ru3hinzPLo8Nf1g3ib0QgO8GWTA41G1Qqk7CD4cSZK/T/5O lTWB33QcKwxIidJK/ucYs7yPses2AIlyeGLhXcWahodUGAImHQ/T/MDc8vrLmkJ0iNeL txMw== X-Gm-Message-State: AJIora/6xShk486QGBmdo8yCro2XIKF4/1lxkBhRz33h5BWR4ZJQBBM0 D+fERyi+yaTKq+WSvgVCWbXsCA== X-Google-Smtp-Source: AGRyM1tn+tf1yrA2tIQndKl5wHvYT8cKaNnYc9PTY1khOzhWHA2cC7FbXhf7V8dM+hXafGz2zP7rtA== X-Received: by 2002:a17:907:7f1a:b0:72e:f9c9:dfe2 with SMTP id qf26-20020a1709077f1a00b0072ef9c9dfe2mr3376644ejc.84.1659110435399; Fri, 29 Jul 2022 09:00:35 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id b12-20020aa7df8c000000b0043ba0cf5dbasm2549475edy.2.2022.07.29.09.00.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Jul 2022 09:00:34 -0700 (PDT) Date: Fri, 29 Jul 2022 09:00:28 -0700 From: Stephen Hemminger To: =?UTF-8?B?TcOhcmlv?= Kuka Cc: dev@dpdk.org, mdr@ashroe.eu, reshma.pattan@intel.com Subject: Re: [PATCH v2 2/2] pcapng: check if writev() returns a partial write Message-ID: <20220729090028.25674943@hermes.local> In-Reply-To: <20220729071841.18198-3-kuka@cesnet.cz> References: <20220725152811.409447-1-kuka@cesnet.cz> <20220729071841.18198-1-kuka@cesnet.cz> <20220729071841.18198-3-kuka@cesnet.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Fri, 29 Jul 2022 09:18:41 +0200 M=C3=A1rio Kuka wrote: > +pcapng_writev(int fd, struct iovec *iov, const int count) > +{ > + size_t total =3D 0; > + int at =3D 0; > + > + while (at < count) { > + /* > + * Note: writev() can return the following on a write request: > + * Complete: > + * written =3D [sum of all iov.iov_len] > + * Partial: > + * written < [sum of all iov.iov_len] > + * Deferred: > + * written =3D -1, errno =3D [EAGAIN] > + * > + * Partial and deferred writes are only possible with O_NONBLOCK set. > + * > + * If we get a partial result, we have to call the writev() again on a= ny ivo buffers > + * that have not been fully written. > + */ > + ssize_t written =3D writev(fd, &iov[at], count - at); > + if (unlikely(written < 0)) > + return written; > + > + total +=3D written; > + at +=3D pcapng_update_iov(&iov[at], count - at, written); > + } > + > + return total; Since this is being written to a file, handling partial writes makes little sense. The only case where partial write would happen would be if filesystem was full. Retrying just adds unnecessary complexity. If you really want to track this, then add a dropped counter.