From owner-freebsd-bugs@FreeBSD.ORG Thu Jan 6 23:30:05 2011 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C78591065672 for ; Thu, 6 Jan 2011 23:30:05 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id A48F78FC13 for ; Thu, 6 Jan 2011 23:30:05 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p06NU5kX097095 for ; Thu, 6 Jan 2011 23:30:05 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p06NU5jl097094; Thu, 6 Jan 2011 23:30:05 GMT (envelope-from gnats) Resent-Date: Thu, 6 Jan 2011 23:30:05 GMT Resent-Message-Id: <201101062330.p06NU5jl097094@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Aleksey Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 42F351065670 for ; Thu, 6 Jan 2011 23:23:40 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (unknown [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 321B48FC17 for ; Thu, 6 Jan 2011 23:23:40 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p06NNdaj041458 for ; Thu, 6 Jan 2011 23:23:39 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id p06NNdXi041455; Thu, 6 Jan 2011 23:23:39 GMT (envelope-from nobody) Message-Id: <201101062323.p06NNdXi041455@red.freebsd.org> Date: Thu, 6 Jan 2011 23:23:39 GMT From: Aleksey To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: misc/153748: [libfetch] in ftp_request: closing of the connection happens too earlier X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jan 2011 23:30:06 -0000 >Number: 153748 >Category: misc >Synopsis: [libfetch] in ftp_request: closing of the connection happens too earlier >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Jan 06 23:30:05 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Aleksey >Release: >Organization: >Environment: FreeBSD r2d2.homenet 8.1-STABLE FreeBSD 8.1-STABLE #7 r215308: Sun Nov 14 21:31:16 UTC 2010 admin@r2d2.homenet:/usr/obj/usr/src/sys/kernel i386 >Description: libfetch/ftp.c - ftp_request sends command QUIT when it is called only for stat. Therefore, after calling fetchStatURL(..) it's not possible to work with this ftp-cached_connection, because the server closes this connection. >How-To-Repeat: #include #include #include int main() { FILE *ftp; const char *url = "ftp://ftp2.freebsd.org/pub/FreeBSD/ports/i386/packages-8-stable/UPDATING"; struct url_stat f_stat; if (fetchStatURL(url, &f_stat, "") == -1) { printf("fetchStatURL error\n"); return -1; } if ((ftp = fetchGetURL(url, "")) == NULL) { printf("fetchGetURL error\n"); return -1; } fclose(ftp); return 0; } this code produces "Broken pipe". >Fix: To fix this problem, don't send QUIT in the ftp_request(..), just decrease the count reference to this cached connection. Patch attached. Patch attached with submission follows: --- /usr/src/lib/libfetch/ftp.c 2011-01-06 03:00:01.000000000 +0000 +++ /usr/src/lib/libfetch/ftp.c 2011-01-06 03:00:27.000000000 +0000 @@ -1132,7 +1132,7 @@ /* just a stat */ if (strcmp(op, "STAT") == 0) { - ftp_disconnect(conn); + fetch_close(conn); return (FILE *)1; /* bogus return value */ } if (strcmp(op, "STOR") == 0 || strcmp(op, "APPE") == 0) >Release-Note: >Audit-Trail: >Unformatted: