cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Question related to Re: How to stop TCP connections

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 5 Nov 2008 22:36:06 +0100 (CET)

On Wed, 5 Nov 2008, dhammika_at_wijesundera.com wrote:

> I do a project similar to the one described in "Re: How to stop TCP
> connections immediately?" (see
> http://curl.haxx.se/mail/lib-2003-03/0102.html). Here you suggest that it is
> better to wait until the download that need to be cancelled is over rather
> than cancelling that thread.

Not entirely true. I suggest you cancel the transfer by the means that are
provided: http://curl.haxx.se/docs/faq.html#How_do_I_stop_an_ongoing_transfe

> My question is that - is there any problem in cancelling the thread and
> using a thread cleanup routine (pthread_cleanup_push()) to do the necessary
> clean up? Would such an approach prevent any memory leaks?

Just killing the thread will cause it to leak all memory that was used at that
moment. pthreads have no magic way to reclaim those resources.

-- 
  / daniel.haxx.se
Received on 2008-11-05