This message generated a parse failure. Raw output follows here. Please use 'back' to navigate. From devnull@lkml.org Fri Apr 26 07:05:46 2024 Delivery-date: Fri, 12 May 2006 16:57:56 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932110AbWELO5R (ORCPT ); Fri, 12 May 2006 10:57:17 -0400 Received: from odyssey.analogic.com ([204.178.40.5]:18183 "EHLO odyssey.analogic.com") by vger.kernel.org with ESMTP id S932109AbWELO5Q convert rfc822-to-8bit (ORCPT ); Fri, 12 May 2006 10:57:16 -0400 Received: from chaos.analogic.com ([10.112.50.11]) by phoenix.analogic.com with Microsoft SMTPSVC(6.0.3790.211); Fri, 12 May 2006 10:57:15 -0400 Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Received: from chaos.analogic.com (localhost [127.0.0.1]) by chaos.analogic.com (8.12.11/8.12.11) with ESMTP id k4CEvF0m009233; Fri, 12 May 2006 10:57:15 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Received: (from linux-os@localhost) by chaos.analogic.com (8.12.11/8.12.11/Submit) id k4CEvF5P009232; Fri, 12 May 2006 10:57:15 -0400 X-OriginalArrivalTime: 12 May 2006 14:57:15.0538 (UTC) FILETIME=[5B81AF20:01C675D4] content-class: urn:content-classes:message Subject: Re: Linux poll() again Date: Fri, 12 May 2006 10:57:15 -0400 Message-Id: In-Reply-To: <44649FAB.4080806@huawei.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Linux poll() again Thread-Index: AcZ11FuNHlkKuOW+SOS1RuyN7lui2Q== References: <6bkl7-56Y-11@gated-at.bofh.it> <4463D1E4.5070605@shaw.ca> <44649C85.5000704@shaw.ca> <44649FAB.4080806@huawei.com> From: "linux-os \(Dick Johnson\)" To: "jimmy" Cc: "Robert Hancock" , "linux-kernel" Reply-To: "linux-os \(Dick Johnson\)" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 12 May 2006, jimmy wrote: > Robert Hancock wrote: >> linux-os (Dick Johnson) wrote: >>>> POLLHUP means "The device has been disconnected." This would obvio= usly >>>> be appropriate for a device such as a serial line or TTY, etc. but= for a >>>> socket it is less obvious that this return value is appropriate. >>>> >>> >>> Hardly "less obvious". SunOs has returned POLLHUP as has other >>> Unixes like Interactive, from which the software was ported. It >>> went from Interactive, to SunOs, to Linux. Linux was the first >>> OS that required the hack. This was reported several years ago >>> and I was simply excoriated for having the audacity to report >>> such a thing. So, I just implemented a hack. Now the hack is >>> biting me. It's about time for poll() to return the correct >>> stuff. >> >> The standard doesn't require that a close on a socket should report >> POLLHUP. Thus this behavior may differ between UNIX implementations.= If >> your software is requiring a POLLHUP to indicate the socket is close= d I >> think it is being unnecessarily picky since read returning 0 univers= ally >> indicates that the connection has been closed. Such are the compromi= ses >> that are sometimes required to write portable software. This is from the Linux man-page shipped with recent distributions SOCKET(7) Linux Programmer=E2EUR(tm)s Manual = SOCKET(7) +--------------------------------------------------------------= ------+ | I/O events = | +-----------+-----------+--------------------------------------= ------+ |Event | Poll flag | Occurrence = | +-----------+-----------+--------------------------------------= ------+ |Read | POLLIN | New data arrived. = | +-----------+-----------+--------------------------------------= ------+ |Read | POLLIN | A connection setup has been completed= (for | | | | connection-oriented sockets) = | +-----------+-----------+--------------------------------------= ------+ |Read | POLLHUP | A disconnection request has been init= iated | | | | by the other end. = | +-----------+-----------+--------------------------------------= ------+ |Read | POLLHUP | A connection is broken (only for co= nnec- | | | | tion-oriented protocols). When the s= ocket | | | | is written SIGPIPE is also sent. = | +-----------+-----------+--------------------------------------= ------+ |Write | POLLOUT | Socket has enough send buffer space= for | | | | writing new data. = | +-----------+-----------+--------------------------------------= ------+ |Read/Write | POLLIN| | An outgoing connect(2) finished. = | | | POLLOUT | = | +-----------+-----------+--------------------------------------= ------+ |Read/Write | POLLERR | An asynchronous error occurred. = | +-----------+-----------+--------------------------------------= ------+ |Read/Write | POLLHUP | The other end has shut down one direc= tion. | +-----------+-----------+--------------------------------------= ------+ |Exception | POLLPRI | Urgent data arrived. SIGURG is sent = then. | +-----------+-----------+--------------------------------------= ------+ If linux doesn't support POLLHUP, then it shouldn't be documented. I got the same king of crap^M^M^M^Mresponse the last time I reported this __very__ __obvious__ defect! The information is available in the kernel. It should certainly report it, just like other operating systems do, including wsock32. >> >>> >>>>> I have used the subsequent read() with a returned >>>>> value of zero, to indicate that the client disconnected >>>>> (as a work around). However, on recent versions of >>>>> Linux, this is not reliable and the read() may >>>>> wait forever instead of immediately returning. >>>> If you want nonblocking behavior, you should set the socket to >>>> nonblocking. This is a bit strange though, unless the data was sto= len by >>>> another thread or something. Are you sure you've seen this? >>> >>> I don't use threads. The hang under the specified conditions was fi= rst >>> observed on 2.6.16.4 (that I'm running on this system). The hack, >>> previously >>> used, i.e., the read of zero was used since 2.4.x with success exce= pt >>> it's >>> a hack and shouldn't be required. It was not ever required on SunOs= from >>> which the software was ported. >> >> This may be a bug somewhere.. however, once again if you don't want = read >> to block under any circumstances, set your sockets to non-blocking! >> > But that's another hack. AFAICS why ppl (mostly) use select/poll wud = be > to know if their send/recv/read/write would go thru rather than getti= ng > blocked! > Yes. You need to know if something has changed. This could mean many things such as new data available or a disconnection. This is a communications link for crysake, one needs to handle communications events. > > -jb > --=0D > Only two things are infinite, the universe and human stupidity, and I= 'm > not sure about the former. - Albert Einstein > Cheers, Dick Johnson Penguin : Linux version 2.6.16.4 on an i686 machine (5592.89 BogoMips). New book: http://www.lymanschool.com _ =1A=04 **************************************************************** The information transmitted in this message is confidential and may be = privileged. Any review, retransmission, dissemination, or other use of= this information by persons or entities other than the intended recipi= ent is prohibited. If you are not the intended recipient, please notif= y Analogic Corporation immediately - by replying to this message or by = sending an email to DeliveryErrors@analogic.com - and destroy all copie= s of this information, including any attachments, without reading or di= sclosing them. Thank you. - To unsubscribe from this list: send the line "unsubscribe linux-kernel"= in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/