From patchwork Fri Oct 20 10:22:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 10019483 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0DBF3603B5 for ; Fri, 20 Oct 2017 10:22:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F279928ED3 for ; Fri, 20 Oct 2017 10:22:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E7733285F1; Fri, 20 Oct 2017 10:22:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F08B28ED3 for ; Fri, 20 Oct 2017 10:22:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752890AbdJTKWr (ORCPT ); Fri, 20 Oct 2017 06:22:47 -0400 Received: from mail-lf0-f43.google.com ([209.85.215.43]:44443 "EHLO mail-lf0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752853AbdJTKWl (ORCPT ); Fri, 20 Oct 2017 06:22:41 -0400 Received: by mail-lf0-f43.google.com with SMTP id 75so12658499lfx.1; Fri, 20 Oct 2017 03:22:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MOfQP/apzlUQb32/9VX7T9Wf9OQ6X4vxxI6t/ecKdQ0=; b=cgyZidENSbCfnJhON4LFdVgoQL9a8lVf62ruSdfgnmwZdOP/WjRQmuRPGBGfkwhOeA 3PsAoekqWw5pQ+3Zeg8XtwnpOPVtR0U7564R+0sQd2d4X1augy6+anLlKfvcLgxRSdIb YEMvRHtN1obLVuR0Ws3RyyAoEeUCGvrvubAo9A9gMTykPhdb3XSo+vb8abwc59nywbjr J/V6T9wZ0n8yL2GFl1rVj9/Tq2INd/WkVF/C/SDSc1Mf5Knd3NOwSV0NhGPyzCSJDSZj SHQsjlaV43fop5YFj+5Orh0Q06psuLyAuXT60ho3K6hxe1IKQUZHwhra8MTd868l71pb BlnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MOfQP/apzlUQb32/9VX7T9Wf9OQ6X4vxxI6t/ecKdQ0=; b=txMPraBrGlL+ML6tznR8rAzEgpLDCEQ3yu5n9Jdiq2mV8cz6XA1pdo6a5PYVxlDJwg ht9VFo0ExcgfQepo5eLR4FmfkMy1+Em6614BfmcYufCZeNS6JcxM5ucKBSTHOV3hw6pf XBOQhCtjJhdWj0GtbWr+ZfZXHfcy/v3bvk3Lcnj93OJILsKas68PBjVaTSUeiwYzkfee 049YiedTt65K+M5+XNCk/rY4XKu+P71SURSX22Ae9YTXIJO5WoP+zdD5uHL1v3b1xn5p X8BeFRVJAQ0kSYvdQQl0S2BldZRr/pKklX6/RmIUauvWs4DkIcmS4kOJc+uzHjXVcYPq +iGQ== X-Gm-Message-State: AMCzsaX14E6q94bg4U1UWIu3zmK/oxxZmiy+VM4JY3HRKWBDE6jm+Du3 z4zugB+YRsxuq9wj0No6yRevTFRD X-Google-Smtp-Source: ABhQp+QjSvzt0MLxmHvqttWkbjAfnWG+aTTlQHlAJHYhSf9UtV98JmB+sNLuwrfqIZ+gT0JI9QnmOw== X-Received: by 10.46.29.65 with SMTP id d62mr1940295ljd.139.1508494959138; Fri, 20 Oct 2017 03:22:39 -0700 (PDT) Received: from vudentzs-t460s.pp.htv.fi (89-27-7-11.bb.dnainternet.fi. [89.27.7.11]) by smtp.gmail.com with ESMTPSA id z71sm168510lje.26.2017.10.20.03.22.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Oct 2017 03:22:38 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Cc: patrik.flykt@linux.intel.com, linux-wpan@vger.kernel.org Subject: [RFC 1/7] shared/io: Add io_recv Date: Fri, 20 Oct 2017 13:22:30 +0300 Message-Id: <20171020102236.17499-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171020102236.17499-1-luiz.dentz@gmail.com> References: <20171020102236.17499-1-luiz.dentz@gmail.com> Sender: linux-wpan-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Luiz Augusto von Dentz This adds io_recv for reading using different buffer pointed by iovec. --- src/shared/io-glib.c | 20 ++++++++++++++++++++ src/shared/io.h | 1 + 2 files changed, 21 insertions(+) diff --git a/src/shared/io-glib.c b/src/shared/io-glib.c index 6687a6b28..3ea68ac4e 100644 --- a/src/shared/io-glib.c +++ b/src/shared/io-glib.c @@ -280,6 +280,26 @@ ssize_t io_send(struct io *io, const struct iovec *iov, int iovcnt) return ret; } +ssize_t io_recv(struct io *io, const struct iovec *iov, int iovcnt) +{ + int fd; + ssize_t ret; + + if (!io || !io->channel) + return -ENOTCONN; + + fd = io_get_fd(io); + + do { + ret = readv(fd, iov, iovcnt); + } while (ret < 0 && errno == EINTR); + + if (ret < 0) + return -errno; + + return ret; +} + bool io_shutdown(struct io *io) { if (!io || !io->channel) diff --git a/src/shared/io.h b/src/shared/io.h index 8bc1111d0..14f0034cf 100644 --- a/src/shared/io.h +++ b/src/shared/io.h @@ -35,6 +35,7 @@ int io_get_fd(struct io *io); bool io_set_close_on_destroy(struct io *io, bool do_close); ssize_t io_send(struct io *io, const struct iovec *iov, int iovcnt); +ssize_t io_recv(struct io *io, const struct iovec *iov, int iovcnt); bool io_shutdown(struct io *io); typedef bool (*io_callback_func_t)(struct io *io, void *user_data);