Commits

David Krentzlin  committed 2bd100b

fixed offset bug for bsd

  • Participants
  • Parent commits 7f3afbc

Comments (0)

Files changed (1)

File strategies/sendfile.bsd.scm

        "  C_return(-1);"
        "}"
        "if(sendfile(src,dst,tmpoffset,to_send,NULL,&res,0) < 0){"
-       "  C_return(errno == EAGAIN ? -2 : -1);"
+       "  if(errno == EAGAIN){"
+       "    C_return(res == 0 ? -2 : (double)(tmpoffset + res));"
+       "  }else{"
+       "    C_return(-1);"
+       "  }"
        "}"
        " if(((off_t)offset & ~(READ_AHEAD - 1)) != (((off_t)offset + res) & ~(READ_AHEAD - 1))){"
        "  if(posix_fadvise(src,((off_t)offset + res) & ~(READ_AHEAD - 1),READ_AHEAD,POSIX_FADV_NOREUSE) < 0){"
        "    C_return(-1)"
        "  }"
        "}"
-       "C_return((double)(rtmpoffset + res));")))
+       "C_return((double)(tmpoffset + res));")))
   (else
    (define %sendfile-implementation
      (foreign-lambda*  double ((integer src) (integer dst) (double offset) (unsigned-integer to_send))
        "size_t res = 0;"
        "off_t tmpoffset = (off_t)offset;"
        "if(sendfile(src,dst,tmpoffset,to_send,NULL,&res,0) < 0){"
-       "  C_return(errno == EAGAIN ? -2 : -1);"
+       "  if(errno == EAGAIN){"
+       "    C_return(res == 0 ? -2 : (double)(tmpoffset + res));"
+       "  }else{"
+       "    C_return(-1);"
+       "  }"
        "}"
        "C_return((double)(tmpoffset + res));"))))