[Openmcl-devel] Transfer the contents of a file to a tcp stream
Gary Byers
gb at clozure.com
Wed Aug 3 21:44:51 PDT 2005
Sorry that this has taken me so long; I have spent some time looking
at the relevant code, but haven't seen a problem yet.
On Wed, 13 Jul 2005, [ISO-8859-1] Christian Nybø wrote:
> Hello,
>
> A function written in platform-independent CL barfs at times in
> input-file-ioblock-advance. Seems there are times when a read-sequence
> returns less than what it's asked
> for, and this mismatch is detected by the advance function. I have tried to
> narrow this down to an example where we copy the contents of a file to
> another file, and set up lots of processes that each have such a separate
> task.
>
> With a directory "/Users/chr/Sites/formula/drobak/07-Images/" containing some
> images, I can provoke the error by doing the following. This is with
> ccl::*MULTIPROCESSING-SOCKET-IO* set to nil, when it is set to t, similar
> errors are reported by CCL::OUTPUT-FILE-FORCE-OUTPUT:
What's puzzling about this is that CCL:*MULTIPROCESSING-SOCKET-IO* controls
whether or not a socket is set to non-blocking mode or not; it shouldn't
have any effect on how file streams behave.
When you get these errors, is there any socket activity in the lisp
you're running in ? (I'm not sure if/how that would matter, but it'd
be slightly more puzzling if there were no such activity and the
value of CCL::*MULTIPROCESSING-SOCKET-IO* had some effect on how
things failed.)
>
> (defun stream-file (in out)
> "Copy from pathname <in> to pathname <out>."
> (with-open-file (is in :element-type '(unsigned-byte 8))
> (with-open-file (os out
> :direction :output
> :if-exists :overwrite
> :if-does-not-exist :create
> :element-type '(unsigned-byte 8))
> (loop with buffer-size = 2048
> with buffer = (make-array buffer-size :element-type '(unsigned-byte
> 8))
> for nread = (read-sequence buffer is)
> do (write-sequence buffer os :end nread)
> while (= nread buffer-size)))))
>
> (defun stream-file-process (pathname)
> (process-run-function (format nil "slave-~A" (pathname-name pathname))
> #'stream-file pathname (pathname
> (format nil "/tmp/foo.~A"
> (pathname-name pathname)))))
>
> (defun stream-file-process-directory (wild-pathname)
> (mapcar #'stream-file-process
> (directory wild-pathname)))
>
> (defparameter *directory-with-certain-files*
> #P"/Users/chr/Sites/formula/drobak/07-Images/*.jpg")
>
> ;; this one has trouble in input-file-ioblock-advance
> (setf ccl::*MULTIPROCESSING-SOCKET-IO* nil)
> (stream-file-process-directory *directory-with-certain-files*)
>
> ;; Could some of you alter *directory-with-certain-files*
> ;; and report back on whether this works on your systems?
>
I wasn't able to reproduce this by copying a directory of
lisp sources around.
When this happens to you, does it always happen when copying
the same file, or is it more-or-less random ?
> Thanks,
> --
> chr
>
> --
> chr
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>
>
More information about the Openmcl-devel
mailing list