From patchwork Thu Oct 26 09:30:20 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: 10027897 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 D90426032C for ; Thu, 26 Oct 2017 09:30:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF60928D75 for ; Thu, 26 Oct 2017 09:30:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C439328D8A; Thu, 26 Oct 2017 09:30:37 +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 A39FD28D99 for ; Thu, 26 Oct 2017 09:30:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751918AbdJZJad (ORCPT ); Thu, 26 Oct 2017 05:30:33 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:52353 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751476AbdJZJab (ORCPT ); Thu, 26 Oct 2017 05:30:31 -0400 Received: by mail-lf0-f68.google.com with SMTP id b190so2967129lfg.9; Thu, 26 Oct 2017 02:30:30 -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=kXM5sPTsLsMGHTTOzbCyj3hmkjMz/OIRPyn7neCQB8fYN8t6k/KxJizuez62Cbqy21 Fzf3F89HAf3imSEguxfnDqr1wGt0sI0UfCjTviEO77wxjaT+PRtRhIo1u1a42CKojPIK GMqJSbbaVsP9avO51YyxQCOmnn8kJXMjLYUSmvj8juzdyhYSJzvTjzWFCgvAes5ieyzL X1bugxXYL6h7k2Bb3RshepKMSR34i/RT9Xw7vik75vQLe4YwRWWJiIv7X/57WGxefOWJ /4YzOh7mL8NnYl/fS82a/ylmWEcFEqKq6gya2g99AJYrN9h98U0Bj94katYMlD74YG+D aBnQ== 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=uC0oP0ns8t+qcWRXytUq1ulKZXeBlQKPg1KYUfMI3AWbC6tDTF0yN0tonSkxLB7sBV Vq/FgKj6TKMo0O3aeBpWI9yR+iWV7xbQ4lFsb909xs+qelQk2mS1Iclrrl4sTHuR0rG2 d1xtEHHYtU7ch3X2i7Qd9BZca++/l8ago3QftMdy8b1/FE89T788kBrKDTZ6N+Cl/CZ/ dPxEmAYoFHRVWCPPiyd2LA5ClCvPbGI6pNPsvs4e+jcboCyoGUxSpq9/sAcKD8hcdWHs L+5+D7XhfTBmsV5vSkKwBAcQHr1ElY4zf1NKBKe1P7hZTsfM7yyYoePMOjvYQ6X7lMHO 0NJQ== X-Gm-Message-State: AMCzsaVzbMZ4QQwlYMbqIXH4IkwWEdfg/3KuTlUowY1UQJJMcoJ02pgc /fIq2PNhA41OA+CS23KzkbGnOW2X X-Google-Smtp-Source: ABhQp+RSn1M5pdXMoU6/hdMo4mdq0Ufbdt6zKm9XKuQTtRJkfDSTwWujZaFR3sAR0zL4uThb7VfEBA== X-Received: by 10.25.216.95 with SMTP id p92mr6553877lfg.219.1509010229258; Thu, 26 Oct 2017 02:30:29 -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 p28sm1322691lje.13.2017.10.26.02.30.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 26 Oct 2017 02:30:28 -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: [PATCH v2 1/7] shared/io: Add io_recv Date: Thu, 26 Oct 2017 12:30:20 +0300 Message-Id: <20171026093026.27952-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171026093026.27952-1-luiz.dentz@gmail.com> References: <20171026093026.27952-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);