Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2078017ybl; Sun, 18 Aug 2019 17:59:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqzUQ3r9NurUWVWrABv5SJ+mCeUIpVVXsr9gIiBxi3E105jvbdbxUx+hhaydmKPaNML5RXOT X-Received: by 2002:a63:290:: with SMTP id 138mr16179066pgc.402.1566176386906; Sun, 18 Aug 2019 17:59:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566176386; cv=none; d=google.com; s=arc-20160816; b=ECaQeksF6SPKrEvop2h4x7ILe5JM/t6d71+7C3XruBiAOzvj7VwsEZzZVUdbFBaKvZ m5Uw+ttE14hB6VHs1NaE2ONLEPHxvZPKtd+fC37FJuCU9TBNDcMguSMRx4fdK9gJuLz6 5x9+/FlgwLP3go135QZsDjXJqiZqnYhqtNSQa3B6mxR688WobZXl9OAE0mZ2HSuez5o0 4URABvH4hrZosY37281Boeur9zOLhi0DgKz2wf0wk+dw779SZo7EismuqtviH7xA5Zwd yhB7+SyH2CMi9iyT2S41zMj5v4cwCOCd8gv/dHuCI9O9lG5Qvmm+fbgzZCyL6DvKaZsJ +saA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=gAWLA6RndFaNzG8rdPLbOXymqdUVzWZhT6YCM9vqWCY=; b=W4l5xp5ftXAnPHgDdnPtnfRjGoJXUXXHTUo/h1wmBksDDBe7SUHlcu3szcsQ/Hhj+0 zYrc8cghTE5kOcoQjKFVKP/44loyxlFph9x1M9R1Xqff/dpwEJEthluyqXegPwWSe+dO LHlVskGtlnzYkJry13aHJm5dwo8IXGdniaarrE75p/1XI6mg3X2twnHKCgHPqhl1w9+1 9C3Ta1Kjcrii3CmXCze9vmBtHZ/ycNreDKT30IOm35wvPcBwraj4eExT9ft6ex9SZvpu +TAP++y/I3L4f78ibum5s/Je/8kh9s7fqD2fiwvNH7evrrFuj6DWRayQYCS0c16qIDkm hBkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hev-cc.20150623.gappssmtp.com header.s=20150623 header.b=df9ezSH6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j70si8577716pgd.500.2019.08.18.17.59.29; Sun, 18 Aug 2019 17:59:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@hev-cc.20150623.gappssmtp.com header.s=20150623 header.b=df9ezSH6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726252AbfHSA6T (ORCPT + 99 others); Sun, 18 Aug 2019 20:58:19 -0400 Received: from mail-lj1-f179.google.com ([209.85.208.179]:42330 "EHLO mail-lj1-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726115AbfHSA6T (ORCPT ); Sun, 18 Aug 2019 20:58:19 -0400 Received: by mail-lj1-f179.google.com with SMTP id l14so134823ljj.9 for ; Sun, 18 Aug 2019 17:58:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hev-cc.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=gAWLA6RndFaNzG8rdPLbOXymqdUVzWZhT6YCM9vqWCY=; b=df9ezSH6JtFuameOXtvnUSlJUImajdAavNOPHNXMzUM/qXtlU48707BWIBLOKeH93F kLbZIMi33jMeuWVUcqpfoSwjmaMWvDx9VVXg2qv0Bv6R3GdDXXME+otkbkLosPILaA6u GKNcwX9zGUSCDENvH8v92rMU9Ekj2PxQCRkQuQUHZ9b/45Aca4eWEG8+NuKI8BeXR0vB basnKSN6+IZXibOE5VNU9I5lSyI3C2Aa+TYZMNULZs46MIlbfBzfM8v/NzfL9btl2i/Y Y1PdcmiDD9UmgI/4Kx8mNUNChU2WNAfci3X0WDieWW3EiIy0itzkgplovT2ZCpjDfRh5 2RZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gAWLA6RndFaNzG8rdPLbOXymqdUVzWZhT6YCM9vqWCY=; b=oMS+9HaXGTk05uUdD4NNhQdcbDB9ypVn4pkdpn2+o8qZMwKg97BZJcJjubxqHtUf/H GGPBseaUN8BfBhfT4MH6zaLMWqSFWspp7ubWdJmG9LSnog9aGREcIW3t+2keSUQ0UZX9 KWc6+1R9z0njglxdwiDJ3+/0HBn7DEIeF3k+t6LsYcET6lOEMW9KEsjRXr+njRIPkqXP 5yofaOePfDEHJmA9pHGeICihv18C56XBmZi+oGkCAjUfjKPYVSz8qyt43Y92tUiiPl6s ixkF7nsIaIvG74x++guX0JbCxhUHrxcvkj/574C9J/aHpIzJHxqMBKCWRvtSotinw/rY vJ0A== X-Gm-Message-State: APjAAAVYnsi30UyaNPehJm8OuLah9ti3q4+xxNZF58o0KkxSB8K6hSgG gz29gEFk7PZZPkQOZAaaQBOdfnXDX6uLWZSEJPmQaxKlz3M= X-Received: by 2002:a2e:b4d4:: with SMTP id r20mr11245217ljm.5.1566176296975; Sun, 18 Aug 2019 17:58:16 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Heiher Date: Mon, 19 Aug 2019 08:58:04 +0800 Message-ID: Subject: Re: Why the edge-triggered mode doesn't work for epoll file descriptor? To: Davidlohr Bueso Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Aug 18, 2019 at 12:36 AM Heiher wrote: > > Hello, > > I've added a pipe file descriptor (fd1) to an epoll (fd3) with > EPOLLOUT in edge-triggered mode, and then added the fd3 to another > epoll (fd4) with EPOLLIN in edge-triggered too. > > Next, waiting for fd4 without timeout. When fd1 to be writable, i > think epoll_wait(fd4, ...) only return once, because all file > descriptors are added in edge-triggered mode. > > But, the actual result is returns many and many times until do once > eopll_wait(fd3, ...). > > #include > #include > #include > > int > main (int argc, char *argv[]) > { > int efd[2]; > struct epoll_event e; > > efd[0] = epoll_create (1); > if (efd[0] < 0) > return -1; > > efd[1] = epoll_create (1); > if (efd[1] < 0) > return -2; > > e.events = EPOLLIN | EPOLLET; > e.data.u64 = 1; > if (epoll_ctl (efd[0], EPOLL_CTL_ADD, efd[1], &e) < 0) > return -3; > > e.events = EPOLLOUT | EPOLLET; > e.data.u64 = 2; > if (epoll_ctl (efd[1], EPOLL_CTL_ADD, 1, &e) < 0) > return -4; > > for (;;) { > struct epoll_event events[16]; > int nfds; > > nfds = epoll_wait (efd[0], events, 16, -1); > printf ("nfds: %d\n", nfds); > } > > close (efd[1]); > close (efd[0]); > > return 0; > } > > -- > Best regards! > Hev > https://hev.cc Is this behavior correct? any help? -- Best regards! Hev https://hev.cc