Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp742312ybl; Sat, 17 Aug 2019 09:39:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6p9UF/3aubbI2dfJh8BiRTqS1UUqEp6WyRLzWk8Gyq4LG917hfgtPXMIqAVunv2zf/3ah X-Received: by 2002:aa7:991a:: with SMTP id z26mr12376459pff.43.1566059943585; Sat, 17 Aug 2019 09:39:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566059943; cv=none; d=google.com; s=arc-20160816; b=KxxTioMq4lSiMavlMX9KWTk/d7wUR9M9Ag1rz4Ju4ahmvr9NWOHgGGc3gXT4dRBnOW ce6eoXPGjG6s9miUohnPJLX/TkOrKGLcOaVLpBKRWYzsUuKFxHm0D+vbJSVeAS9zXg3H pvq71K1QaoPVC3pRQKn0Fxekho6DMdJ6nvY5Pb2bVb5js05GCzUCm9XBF/Vq0YVyT1oo TvQj/+opoqKJlYeCIbL74EaxLaufd2oLDSf0zEAnAGMsOuvr4Y89fqUw1XNa9vnKuydy 2AvrnHXLmCS9C+uLVQWrjCPNE23OuMJM3FEOWuhBJz/ECjw4hur/zYaHI+cp+Zl5av9a BWFQ== 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 :mime-version:dkim-signature; bh=gh4Uf54lGK4BZME7LVlHMNrohQu549X8RdaI8EEyc2U=; b=SAzCSCQ8C3WnIXIMlayp3DoOd1UbWwQ4UjjX+dnKJiOCawNYRjX7ZwV+1vnwLKOB1G yQXcLubxSEMUlen7UcyEaicY8A5lbkg/35TFOZhxEcu6CcEDlXZ53spM1aU8Y1nGvEgR Xr6Wr14YHNQDvEtMSaQWzzUs2XMtLJxZeffhL41jU2skicAH1xUQu7cQBWxXfGEXhph2 UKWpYU/y5ZvC4mVW5PfFI3tpxlY0jVk0Mb+Fj+HvDsIiyPUg2PZrHfy6AEom6SlOIeQe X1v/Rf1Xvu+M+npQB9A1vK6MUXPJEf+OM2aDIzlItbe4IWN7qFWXn4P0caRxCwwEt9bx g9Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hev-cc.20150623.gappssmtp.com header.s=20150623 header.b=ucmSPP0T; 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 s18si2546972pgq.177.2019.08.17.09.38.49; Sat, 17 Aug 2019 09:39:03 -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=ucmSPP0T; 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 S1726257AbfHQQhA (ORCPT + 99 others); Sat, 17 Aug 2019 12:37:00 -0400 Received: from mail-lj1-f174.google.com ([209.85.208.174]:40491 "EHLO mail-lj1-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725937AbfHQQg7 (ORCPT ); Sat, 17 Aug 2019 12:36:59 -0400 Received: by mail-lj1-f174.google.com with SMTP id e27so7923655ljb.7 for ; Sat, 17 Aug 2019 09:36:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hev-cc.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to:cc; bh=gh4Uf54lGK4BZME7LVlHMNrohQu549X8RdaI8EEyc2U=; b=ucmSPP0TeU4H54GmmFSX4Cbw/YJZftuFiiY89vjitwPTk9KKJY5ycyYQfwfYFdHg5c ZMpTLVGFFJx541rvL34eMhfZM/MzoscItMRHiVw2GSlweHhfuE/GFEwcIlgjcDkwPjZb s91eCkJZi50Zd82fmuQtlTG7cm7+EpxqhWLQP2T53D5zMMs9Jl8FtyEfQ29/yLEaIS3L iAcSvON1BBiNBJXR4tHKjfD1/dlbJK09TCRh6ey1KyPlOE9wZUzx7mmnVneQMOolnM8/ Ta+isnau03b0FOX2KMb95v8o0sVN35kL8AO9XFsQnbhGL2ArPxZx6ud9C9V5ce4GOQSU Pdlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=gh4Uf54lGK4BZME7LVlHMNrohQu549X8RdaI8EEyc2U=; b=oy2artkBtm65MSzWnFBTK6gRF+OM7RUB6uesgC34yQUV/D4VdDNbSJohnJ+83AjUm5 OCsCvWh+fwPXBl+eWsr3zdyeF6pyGmfae5zqYttkoAPI5rQ2otkopOe650eIb5dbwKWO fhxe56WAvgAGQJQ6AvcSpmM+uYuBCz//IIt2SxCRtT91rfAnMrElvLos4euH6AgQwnaL mlSrkoZHNRea2V3/1d/I+aDqb4YTB61VA2EDkxWXXTi0WuOAv7xNj1XJKUtObFeaTQKW JCot1yg0B2VEOMSi2foEtwBXUr3c0lmB2IflRVajRTh6qG4MAn0M/btEEWsr2yJqBUZn tV2Q== X-Gm-Message-State: APjAAAUiclK1NkLPwPAYDlrsQGra06gD9H3gomiewFEGgCSCf4sIj30f ZDbFohVsBWCWVbuM4DYu8nm4x8avUKJO8voEWFxLrwhem2eJvA== X-Received: by 2002:a2e:6393:: with SMTP id s19mr8076155lje.46.1566059817953; Sat, 17 Aug 2019 09:36:57 -0700 (PDT) MIME-Version: 1.0 From: Heiher Date: Sun, 18 Aug 2019 00:36:46 +0800 Message-ID: Subject: Why the edge-triggered mode doesn't work for epoll file descriptor? To: linux-fsdevel@vger.kernel.org Cc: 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 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