Return-Path: Delivered-To: apache-bugdb-archive@hyperreal.org Received: (qmail 15032 invoked by uid 6000); 20 Dec 1999 21:50:08 -0000 Received: (qmail 14965 invoked by uid 2001); 20 Dec 1999 21:50:00 -0000 Date: 20 Dec 1999 21:50:00 -0000 Message-ID: <19991220215000.14964.qmail@hyperreal.org> To: jserv-bugdb@apache.org Cc: apache-bugdb@apache.org, From: jon * Subject: mod_jserv/5498: Pages being returned are empty Reply-To: jon * Sender: apache-bugdb-owner@apache.org Precedence: bulk The following reply was made to PR mod_jserv/5498; it has been noted by GNATS. From: jon * To: Cc: Subject: mod_jserv/5498: Pages being returned are empty Date: Mon, 20 Dec 1999 13:48:06 -0800 ---------- From: Michal Mosiewicz Reply-To: "Java Apache" Date: Mon, 20 Dec 1999 22:36:46 +0100 To: Java Apache Subject: Re: FW: mod_jserv/5498: Pages being returned are empty jon * wrote: +1 on the patch. However the real reason that pages was empty was that the servlet author didn't close the output. So this patch actually closes the output for him, and corrects his mistake. > [...] > Why is this loop needed in the JServOutputStream close function? > > public void close() throws IOException { > int l; > do { > l = in.available(); > in.skip(l); > } while (l > 0); > > sendHttpHeaders(); > out.close(); It's a "linger on close" feature. The loop is to protect that your data will be received by the browser even if you haven't received all the input stream. In case you have unread data waiting for being received in the socket, and you close the socket, depending on the operating system your output data that are buffered in the socket may get lost. Many OS'es assume "no SO_LINGER" as a default policy, setting socket options sometimes has no effect in JVM's. So this is safe way to go around this problem. AFAIK Costin suggested that calling available() is enough, but this seem to be safer. -- Mike -- ---------------------------------------------------------- To subscribe: java-apache-on@list.working-dogs.com To unsubscribe: java-apache-off@list.working-dogs.com Archives and Other: Problems?: jon@working-dogs.com