IOW, I cannot call uv_udp_send() from the threadpool, because it is not the 
same thread, where loop runs, correct?

If yes, more questions:

1) is calling uv_udp_send() from on_read callback considered safe (I guess, 
it should be)?
2) if i call uv_udp_send(), does it buffer/queue this request immediately, 
or it waits until the data are *really* sent?

Thanks.

середа, 25 січня 2017 р. 17:44:16 UTC+1 користувач Saúl Ibarra Corretgé 
написав:
>
> On Wed, Jan 25, 2017 at 9:53 AM,  <[email protected] <javascript:>> wrote: 
> > Hello. 
> > 
> > I'm playing with libuv and have this code [1]. This is, basically, just 
> UDP 
> > echo server which replies with "hello" on every request. 
> > 
> > The workflow is as follows: UDP packet arrives, in on_read callback new 
> work 
> > is queued via uv_queue_work() (line 138), and in this "work" 
> uv_udp_send() 
> > is being used to send a reply (line 92). 
>
> You can't do that, it's not thread-safe.  libuv APIs are not 
> thread-safe, unless stated otherwise.  Since you are queuing the work 
> to be run in another thread, you cannot call uv_udp_send from there. 
> You'll need to restructure your code so you send the packet from the 
> libuv thread. 
>
>
> Cheers, 
>
> -- 
> /Saúl 
> bettercallsaghul.com 
>

-- 
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