I never said you should use uv_queue_work :-) The work item will be called in a different thread, so you're back to undefined behavior!
You must make the curl_multi_add_handle function run in the loop thread. An async handle could help you with that. But watch out with where you call uv_async_init, only, I repeat *ONLY* uv_async_send is thread-safe. Cheers, On Mon, Jun 5, 2017 at 5:55 PM, Przemysław Sobala <[email protected]> wrote: > W dniu poniedziałek, 5 czerwca 2017 17:25:00 UTC+2 użytkownik Saúl Ibarra > Corretgé napisał: >> >> I suggest you re-read my suggestion a few emails back. Move handling of >> the entire curl handle to the uv thread with a queue, a muted and an async >> handle. >> >> >> -Saúl > > > Hello Saúl > Thanks for still being here :-) > > If I understood correctly, I did something like this: > > (inside the thread that should add a downloading request to uv_loop) > synchronized(request_queue_mutex) { > request_queue.data = curl_easy_handle; > uv_queue_work(loop, &request_queue, > [](uv_work_t* req) {}, > [](uv_work_t* req, int status) { > LOG(INFO) << "working done: "; > curl_multi_add_handle(curl_handle, (CURL *) req->data); > }); > } > > but after running 2 simultaneous request my code breaks with: > ==18186== Process terminating with default action of signal 6 (SIGABRT): > dumping core > ==18186== at 0x687C765: raise (in /usr/lib64/libc-2.23.so) > ==18186== by 0x687E482: abort (in /usr/lib64/libc-2.23.so) > ==18186== by 0x4B7D52: MagickPanicSignalHandler (magick.c:840) > ==18186== by 0x663CC2F: ??? (in /usr/lib64/libpthread-2.23.so) > ==18186== by 0xC29997: ??? > ==18186== by 0x80A30B: uv__work_done (threadpool.c:245) > ==18186== by 0x80C0FA: uv__async_io (async.c:118) > ==18186== by 0x8161F7: uv__io_poll (linux-core.c:400) > ==18186== by 0x80C923: uv_run (core.c:359) > ==18186== by 0x41768C: imageresizer::engine::FileDownloader::StartLoop() > (FileDownloader.cpp:103) > ==18186== by 0x4199A3: void std::__invoke_impl<void, void > (imageresizer::engine::FileDownloader::* const&)(), > imageresizer::engine::FileDownloader*>(std::__invoke_memfun_deref, void > (imageresizer::engine::FileDownloader::* const&)(), > imageresizer::engine::FileDownloader*&&) (functional:227) > ==18186== by 0x419930: std::result_of<void > (imageresizer::engine::FileDownloader::* > const&(imageresizer::engine::FileDownloader*&&))()>::type std::__invoke<void > (imageresizer::engine::FileDownloader::* const&)(), imageresizer::engine: > :FileDownloader*>(void (imageresizer::engine::FileDownloader::* const&)(), > imageresizer::engine::FileDownloader*&&) (functional:251) > -- > regards > Przemysław Sobala > > -- > 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. -- /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.
