Brandon, Your reading on my code is quite correct. So you are suggesting that the Haskell aiocb contain a ForeignPtr to actual aiocb that is passed the C functions. In this scenario, whose responsibility to allocate the "chunk" of memory for the aiocb?
Vasili On Mon, Jul 28, 2008 at 2:04 AM, Brandon S. Allbery KF8NH < [EMAIL PROTECTED]> wrote: > > On 2008 Jul 28, at 2:36, Galchin, Vasili wrote: > > Hi Brandon, > > So even if I go to ForeignPtr is a problem? And/Or is this a "by > reference" vs "by value" issue? > > > As I read your code, you're allocating a C object, poking the Haskell > fields into it, and passing it on, then peeking the values back out. This > won't work; the C pointer value passed to aio_write() is the value that must > be passed to subsequent operations on that aiocb (such as aio_return()). > More to the point: the exact chunk of memory passed to aio_write(), > unmodified, must be passed to any other aio functions checking for or > blocking on completion of the write. You may not move it around or > arbitrarily change values within it. > > You could do this if your Haskell aiocb also retained the ForeignPtr to the > originally allocated C object... but after the initial pokes, the only thing > you can safely do with that object is pass it to C and peek the current > values out of it, unless the C API specifically says you can modify fields > within it while I/O operations are pending (and I'd be rather surprised if > it did). > > -- > brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED] > system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED] > electrical and computer engineering, carnegie mellon university KF8NH > > >
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe