On Thu, Mar 22, 2018 at 11:49 PM, CM <[email protected]> wrote:
> Hi,
>
> 1. does libuv provide any guarantees wrt callback order in case when
> uv_close() cancels all outstanding requests on given handle -- i.e. can I
> rely that in close_cb all canceled requests callbacks have already been
> called?

Yes, request callbacks run before the close callback.

You should probably not rely on the order in which different request
types run, e.g., whether a connect callback comes before or after a
write callback.

> 2. can uv_close callback be cancelled or not completed? E.g. if I ask event
> loop to terminate -- will it wait for all callbacks to complete? what if
> these callbacks try to queue another requests -- will they get cancelled or
> those requests will fail to submit?

If "ask to terminate" means calling:

1. uv_stop() -> uv_stop() just tells uv_run() to return at its
earliest convenience, it doesn't shut down anything.
2. uv_loop_close() -> uv_loop_close() fails with UV_EBUSY if there are
active handles or requests.

A closing handle is considered active, even if it has been unref'd
with uv_unref().

When a callback creates another handle or request, it keeps the event
loop alive.

> 2.1. does ev_run() guarantee that no outstanding requests are alive or
> callbacks are pending on return?

Yes, provided you called it with mode=UV_RUN and didn't call
uv_stop().  Call uv_loop_alive() if you want to be sure.

> 3. Can I move uv_tcp_t (or any other handle) instance in memory?

No.

> 4. if I submit two write requests -- is it possible for first one to fail
> and for second one to succeed? (uv_tcp_t/uv_file_t/etc, Windows/Linux)

In theory, yes; in practice, no.  Libuv stops reading and writing when
an I/O error happens.  It is theoretically possible to start reading
and writing again if the error is transient, but in practice you
simply close the handle.

-- 
You received this message because you are subscribed to the Google Groups 
"libuv" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/libuv.
For more options, visit https://groups.google.com/d/optout.

Reply via email to