cURL / Mailing Lists / curl-library / Single Mail


Aborting a transfer safely

From: MingHeng Wang <>
Date: Tue, 17 May 2016 15:35:30 +0800

Hello libcurl Devs/Users,
  Following the multi-uv.c example, I use multi socket interface to
implement a multithreading like DM by setting range for each easy
handle in a multi handle. I first add a single easy handle to the
multi-handle in the polling loop. Then I try adding second one in the
multi-handle with range request set to determine if the server
supports range. I retrieve the response code in the write function
callback specific to the test handle, with write data pointer set to
the handle itself. This function returns 0 to abort this transfer.
After that I remove this handle from the multi-handle. But sometimes
my program crashes because of double freeing the uv_poll_t on
stopping polling a socket. I'm not very experienced or sure if it's
something of my code goes wrong. But my question is: will aborting a
transfer by returning 0 from the write callback and removing a handle
from a multi-handle both cause CURL_POLL_REMOVE passed to the socket
function for the same socket? Or how to safely abort a transfer in a

Wang Ming Heng
List admin:
Received on 2016-05-17