Fri Oct 7 21:09:57 2016 UTC ()
PR/514612: Mateusz Paszwa: When no more data, bail out (reading from empty
files) instead of stuck looping.


(christos)
diff -r1.64 -r1.65 src/usr.sbin/puffs/mount_psshfs/node.c

cvs diff -r1.64 -r1.65 src/usr.sbin/puffs/mount_psshfs/node.c (expand / switch to unified diff)

--- src/usr.sbin/puffs/mount_psshfs/node.c 2012/01/20 22:07:58 1.64
+++ src/usr.sbin/puffs/mount_psshfs/node.c 2016/10/07 21:09:57 1.65
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: node.c,v 1.64 2012/01/20 22:07:58 jakllsch Exp $ */ 1/* $NetBSD: node.c,v 1.65 2016/10/07 21:09:57 christos Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2006-2009 Antti Kantee. All Rights Reserved. 4 * Copyright (c) 2006-2009 Antti Kantee. All Rights Reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE. 25 * SUCH DAMAGE.
26 */ 26 */
27 27
28#include <sys/cdefs.h> 28#include <sys/cdefs.h>
29#ifndef lint 29#ifndef lint
30__RCSID("$NetBSD: node.c,v 1.64 2012/01/20 22:07:58 jakllsch Exp $"); 30__RCSID("$NetBSD: node.c,v 1.65 2016/10/07 21:09:57 christos Exp $");
31#endif /* !lint */ 31#endif /* !lint */
32 32
33#include <assert.h> 33#include <assert.h>
34#include <errno.h> 34#include <errno.h>
35#include <stdio.h> 35#include <stdio.h>
36#include <stdlib.h> 36#include <stdlib.h>
37 37
38#include "psshfs.h" 38#include "psshfs.h"
39#include "sftp_proto.h" 39#include "sftp_proto.h"
40 40
41int 41int
42psshfs_node_lookup(struct puffs_usermount *pu, puffs_cookie_t opc, 42psshfs_node_lookup(struct puffs_usermount *pu, puffs_cookie_t opc,
43 struct puffs_newinfo *pni, const struct puffs_cn *pcn) 43 struct puffs_newinfo *pni, const struct puffs_cn *pcn)
@@ -553,27 +553,27 @@ again: @@ -553,27 +553,27 @@ again:
553 offset += readlen; 553 offset += readlen;
554 } 554 }
555 555
556 out: 556 out:
557 if (max_reads && --psn->readcount >= max_reads) { 557 if (max_reads && --psn->readcount >= max_reads) {
558 TAILQ_FOREACH(pwp, &psn->pw, pw_entries) 558 TAILQ_FOREACH(pwp, &psn->pw, pw_entries)
559 if (pwp->pw_type == PWTYPE_READ2) 559 if (pwp->pw_type == PWTYPE_READ2)
560 break; 560 break;
561 assert(pwp != NULL); 561 assert(pwp != NULL);
562 puffs_cc_schedule(pwp->pw_cc); 562 puffs_cc_schedule(pwp->pw_cc);
563 TAILQ_REMOVE(&psn->pw, pwp, pw_entries); 563 TAILQ_REMOVE(&psn->pw, pwp, pw_entries);
564 } 564 }
565 565
566 if (rv == 0 && *resid > 0) { 566 if (rv == 0 && *resid > 0 && readlen > 0) {
567 reqid = NEXTREQ(pctx); 567 reqid = NEXTREQ(pctx);
568 psbuf_recycleout(pb); 568 psbuf_recycleout(pb);
569 goto again; 569 goto again;
570 } 570 }
571 571
572 farout: 572 farout:
573 /* check if we need a lazyclose */ 573 /* check if we need a lazyclose */
574 if (psn->stat & PSN_HANDLECLOSE && psn->fhand_r) { 574 if (psn->stat & PSN_HANDLECLOSE && psn->fhand_r) {
575 TAILQ_FOREACH(pwp, &psn->pw, pw_entries) 575 TAILQ_FOREACH(pwp, &psn->pw, pw_entries)
576 if (pwp->pw_type == PWTYPE_READ1) 576 if (pwp->pw_type == PWTYPE_READ1)
577 break; 577 break;
578 if (pwp == NULL) 578 if (pwp == NULL)
579 closehandles(pu, psn, HANDLE_READ); 579 closehandles(pu, psn, HANDLE_READ);