robertleahy / asio-curl Goto Github PK
View Code? Open in Web Editor NEWAsynchronous libcurl using ASIO
License: The Unlicense
Asynchronous libcurl using ASIO
License: The Unlicense
Running the code in the attached file (uploaded as ZIP, because direct cpp is not supported, for whatever reason), which is based mostly on the example from the main project page, with include files and proper termination added, leads to a crash.
System: Ubuntu 20.04 LTS
Boost Version: 1.73.0 (self compiled)
libcurl-gnutls as packaged with Ubuntu 20.04 LTS
The crash happens in the main thread in the call to curl.add(easy), which in turn calls curl_multi_add_handle(), which calls back to asiocurl::io_service::timer(), which calls asiocurl::io_service::do_action(), which calls curl_multi_socket_action(), which calls asiocurl::io_service::socket().
When breaking with GDB into asiocurl::io_service::socket() and analyzing the passed in userp, the good news is, that it seems to point to a valid asiocurl::io_service. The bad news is, that the sockets_ field of that io_service is an empty std::unordered_map . Somehow, curl is calling back asiocurl::io_service::socket(), when the io_service is not even aware of any socket, yet.
No need to say, that the following line of asiocurl::io_service::socket()
auto & ss=self.sockets_.find(socket)->second;
doesn't find anything and thus continues with an invalid pointer, which soon leads to a SEGFAULT.
With all the changes of both boost::asio and libcurl during the last years, I am not going to debug this problem any further.
test.zip
Two problems:
It would be nice if this library could be used without having to include all of Boost. Also, it would be nice if it was possible to use the version of ASIO that isn't part of Boost.
I understand this code is old and may not be maintained, but I noticed a issue while using it as a example reference.
If you request something that can't fit in a single buffer eg 16KB the code will stall indefinitely.
This is because the code is only calling socket read/write once in response to ::socket calls.
Instead it should enter a async loop calling read/write over and over unless otherwise instructed by another call to ::socket.
In order to fix it I suggest moving the socket read/write logic into another function and calling that function again instead of do_action after a read/write completes.
Since I only used this as a reference I don't have changes for a pull request, sorry.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.