From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14607 invoked by alias); 3 Feb 2012 19:14:24 -0000 Received: (qmail 14599 invoked by uid 22791); 3 Feb 2012 19:14:23 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO sourceware.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 03 Feb 2012 19:14:11 +0000 From: "teodori.serge at hotmail dot com" To: glibc-bugs@sources.redhat.com Subject: [Bug libc/13660] New: poll wrong revents returned Date: Fri, 03 Feb 2012 19:14:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Keywords: X-Bugzilla-Severity: critical X-Bugzilla-Who: teodori.serge at hotmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: drepper.fsp at gmail dot com X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org X-SW-Source: 2012-02/txt/msg00012.txt.bz2 http://sourceware.org/bugzilla/show_bug.cgi?id=13660 Bug #: 13660 Summary: poll wrong revents returned Product: glibc Version: 2.14 Status: NEW Severity: critical Priority: P2 Component: libc AssignedTo: drepper.fsp@gmail.com ReportedBy: teodori.serge@hotmail.com Classification: Unclassified Hello, poll() is not returning the right events. If socket has data to read, POLLIN is set, but if socket is closed or shutdown it also sets POLLIN? It should normally be POLLERR POLLHUP or POLLNVAL, at least not POLLIN. Ex.: int prc = 0; struct pollfd pfd; while(prc != -1){ pfd.fd = connectedsocket; pfd.events = POLLIN; prc = poll(&pfd, 1, 1000); if(prc == -1){ perror("poll"); }else if(prc == 0){ printf("timeout"); }else if(prc == 1 && pfd.revents == POLLIN){ recv(pfd.fd, buff, sizeof(buff), 0); printf("data: %s\n", buff); }else if(prc == 1 && pfd.revents != POLLIN){ close(pfd.fd); printf("socket closed\n"); prc = -1; } } Output: timeout timeout timeout data: Hello //peer send data timeout timeout timeout data: // peer closed or shutdown socket -> poll is heating up 100% CPU data: data: data: This is the case on Ubuntu and on my own linux from scratch (linux-3.2.2 + glibc-2.14.1 compiled with gcc-4.6.2 and the linux-3.2.2 headers). I doubt that it could be and build error, because I tried it on i386 and x86 with different. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.