Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 178
Description
Currently, curl_multi provides a copy constructor and a copy assignment operator.
The copy constructor actually creates a completely independent new multi handle but assigns message_queued and active_count, which does not make sense at all.
The assignment operator just initializes the new multi handle.
I believe that the copy constructor and assignment operators should be deleted (= delete),
and move constructor and move assignment provided instead if necessary.
Update
Similarly, I think that curl_easy should not be copyable by default either. Otherwise it is too easy to copy accidentally (for example, when storing a curl_easy in a container). Instead, there should be a .clone() method for the case there the user wants to clone the handle.
Update2
Actually, this issues can be easily solved by wrapping the handle into a std::unique_ptr like this:
classcurl_multi{structdeleter{voidoperator()(CURLM* h) const{curl_multi_cleanup(h)} }; std::unique_ptr<CURLM, deleter> handle_; // other members here... }This will automatically provide safe moving and prohibit copying and automatically provide a destructor.