<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 2008 Jul 28, at 2:36, Galchin, Vasili wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">Hi Brandon,<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; So even if I go to ForeignPtr is a problem? And/Or is this a "by reference" vs "by value" issue?<br></div></blockquote></div><div><br></div><div>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. &nbsp;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()). &nbsp;More to the point: &nbsp;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. &nbsp;You may not move it around or arbitrarily change values within it.</div><div><br></div><div>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).</div><br><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-family: Monaco; "><span class="Apple-style-span" style="font-family: Monaco; ">--&nbsp;</span></span></font></div><div><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-family: Monaco; "><span class="Apple-style-span" style="font-family: Monaco; ">brandon s. allbery [solaris,freebsd,perl,pugs,haskell] <a href="mailto:allbery@kf8nh.com">allbery@kf8nh.com</a></span></span></font></div><div><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-family: Monaco; "><span class="Apple-style-span" style="font-family: Monaco; ">system administrator [openafs,heimdal,too many hats] <a href="mailto:allbery@ece.cmu.edu">allbery@ece.cmu.edu</a></span></span></font></div><div><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-family: Monaco; "><span class="Apple-style-span" style="font-family: Monaco; ">electrical and computer engineering, carnegie mellon university &nbsp; &nbsp;KF8NH</span></span></font></div><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><br class="Apple-interchange-newline"></span></span></span></div></span> </div><br></body></html>