devpipe: on write/writeb, have devpipe return the error from qio
authorRonald G. Minnich <rminnich@gmail.com>
Mon, 2 May 2016 23:05:09 +0000 (16:05 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Tue, 3 May 2016 00:02:41 +0000 (20:02 -0400)
This fixes the 'lost connection' problem on scp. Plus, it makes way
more sense.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/drivers/dev/pipe.c
kern/src/ns/qio.c

index 6dd27d9..fad7b22 100644 (file)
@@ -387,23 +387,9 @@ static struct block *pipebread(struct chan *c, long n, uint32_t offset)
  */
 static long pipewrite(struct chan *c, void *va, long n, int64_t ignored)
 {
-       ERRSTACK(2);
        Pipe *p;
        //Prog *r;
 
-       if (waserror()) {
-               /* avoid exceptions when pipe is a mounted queue */
-               if ((c->flag & CMSG) == 0) {
-/*
-                       r = up->iprog;
-                       if(r != NULL && r->kill == NULL)
-                               r->kill = "write on closed pipe";
-*/
-               }
-               set_errno(EPIPE);
-               nexterror();
-       }
-
        p = c->aux;
 
        switch (NETTYPE(c->qid.path)) {
@@ -425,30 +411,15 @@ static long pipewrite(struct chan *c, void *va, long n, int64_t ignored)
                        panic("pipewrite");
        }
 
-       poperror();
        return n;
 }
 
 static long pipebwrite(struct chan *c, struct block *bp, uint32_t junk)
 {
-       ERRSTACK(2);
        long n;
        Pipe *p;
        //Prog *r;
 
-       if (waserror()) {
-               /* avoid exceptions when pipe is a mounted queue */
-/*
-               if((c->flag & CMSG) == 0) {
-                       r = up->iprog;
-                       if(r != NULL && r->kill == NULL)
-                               r->kill = "write on closed pipe";
-               }
-*/
-               set_errno(EPIPE);
-               nexterror();
-       }
-
        p = c->aux;
        switch (NETTYPE(c->qid.path)) {
                case Qdata0:
@@ -470,7 +441,6 @@ static long pipebwrite(struct chan *c, struct block *bp, uint32_t junk)
                        panic("pipebwrite");
        }
 
-       poperror();
        return n;
 }
 
index 9bf7764..dcfd935 100644 (file)
@@ -1212,11 +1212,11 @@ static bool qwait_and_ilock(struct queue *q, int qio_flags)
                if (q->state & Qclosed) {
                        if (++q->eof > 3) {
                                spin_unlock_irqsave(&q->lock);
-                               error(EFAIL, "multiple reads on a closed queue");
+                               error(EPIPE, "multiple reads on a closed queue");
                        }
                        if (q->err[0]) {
                                spin_unlock_irqsave(&q->lock);
-                               error(EFAIL, q->err);
+                               error(EPIPE, q->err);
                        }
                        return FALSE;
                }
@@ -1504,9 +1504,9 @@ static ssize_t __qbwrite(struct queue *q, struct block *b, int qio_flags)
                if (!(qio_flags & QIO_CAN_ERR_SLEEP))
                        return -1;
                if (q->err[0])
-                       error(EFAIL, q->err);
+                       error(EPIPE, q->err);
                else
-                       error(EFAIL, "connection closed");
+                       error(EPIPE, "connection closed");
        }
        if ((qio_flags & QIO_LIMIT) && (q->len >= q->limit)) {
                /* drop overflow takes priority over regular non-blocking */