On Fri, Jul 27, 2012 at 8:00 PM, Ben Noordhuis <[email protected]> wrote: > On Fri, Jul 27, 2012 at 9:38 AM, Felix Halim <[email protected]> wrote: >> Is it mandatory to call uv_close in the callback of uv_write? >> >> Or we can just write it like this (3 uv_writes, followed by one uv_close): >> >> uv_write(&write_req, (uv_stream_t*)&handle, &resbuf, 1, 0); >> uv_write(&write_req, (uv_stream_t*)&handle, &resbuf, 1, 0); >> uv_write(&write_req, (uv_stream_t*)&handle, &resbuf, 1, 0); >> uv_close((uv_handle_t*)req->handle, on_close); >> >> Is it guaranteed that the close will happen after all writes are finished? >> >> I couldn't find any info regarding this in the uv.h >> >> Felix Halim > > The handle gets closed, your callbacks get called with status=-1, > error code UV_EINTR. The data is not written.
I discovered that there is a problem in calling multiple uv_writes using the SAME &write_req like the above example. What happened is that the callback after_write get called infinitely (endless loop). Is it true that each uv_write() must be specified different uv_write_t, and each uv_write_t variable must be valid until the callback is fired? (thus, it is not dispose-able like uv_buf_t) If that's true, then someone should insert an assertion there to catch on the attempts to call uv_write with the same &write_req. Also, please add that to the uv.h comments. Thanks. Today, I spend all of my time just to understand these quirks -_-' Felix Halim -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
