]> arthur.barton.de Git - netatalk.git/blobdiff - libatalk/dsi/dsi_stream.c
Fix a possible bug handling disconnected sessions, NetAFP Bug ID #16
[netatalk.git] / libatalk / dsi / dsi_stream.c
index c709f2166fc8972e6a693fabc98fd535aab6663e..ab1339184b48b1394a89415c481f2689ad0d83c9 100644 (file)
@@ -62,6 +62,9 @@ static int dsi_peek(DSI *dsi)
     maxfd = dsi->socket + 1;
 
     while (1) {
+        if (dsi->socket == -1)
+            /* eg dsi_disconnect() might have disconnected us */
+            return -1;
         FD_ZERO(&readfds);
         FD_ZERO(&writefds);
 
@@ -342,7 +345,7 @@ ssize_t dsi_stream_read_file(DSI *dsi, int fromfd, off_t offset, const size_t le
           goto exit;
       }          
       if (errno == EAGAIN || errno == EWOULDBLOCK) {
-#ifdef SOLARIS
+#if defined(SOLARIS) || defined(FREEBSD)
           if (pos > offset) {
               /* we actually have sent sth., adjust counters and keep trying */
               len = pos - offset;