]> andersk Git - openssh.git/blobdiff - atomicio.c
- (tim) [configure.ac] Bug #1149. Changes in QNX section only. Patch by
[openssh.git] / atomicio.c
index dfc1553c5c00c22c5c349e12dd8e189b0ff3a1f2..12abbda16bb157448caeac5ed734d06eaf9b54f9 100644 (file)
@@ -1,4 +1,5 @@
 /*
+ * Copyright (c) 2005 Anil Madhavapeddy. All rights reserved.
  * Copyright (c) 1995,1999 Theo de Raadt.  All rights reserved.
  * All rights reserved.
  *
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: atomicio.c,v 1.11 2003/06/28 16:23:06 deraadt Exp $");
+RCSID("$OpenBSD: atomicio.c,v 1.13 2005/05/24 17:32:43 avsm Exp $");
 
 #include "atomicio.h"
 
 /*
- * ensure all of data on socket comes through. f==read || f==write
+ * ensure all of data on socket comes through. f==read || f==vwrite
  */
-ssize_t
+size_t
 atomicio(f, fd, _s, n)
        ssize_t (*f) (int, void *, size_t);
        int fd;
@@ -39,7 +40,8 @@ atomicio(f, fd, _s, n)
        size_t n;
 {
        char *s = _s;
-       ssize_t res, pos = 0;
+       size_t pos = 0;
+       ssize_t res;
 
        while (n > pos) {
                res = (f) (fd, s + pos, n - pos);
@@ -51,10 +53,12 @@ atomicio(f, fd, _s, n)
                        if (errno == EINTR || errno == EAGAIN)
 #endif
                                continue;
+                       return 0;
                case 0:
-                       return (res);
+                       errno = EPIPE;
+                       return pos;
                default:
-                       pos += res;
+                       pos += (u_int)res;
                }
        }
        return (pos);
This page took 0.084434 seconds and 4 git commands to generate.