bes Updated for version 3.20.13
dmrpp::CurlHandlePool Class Reference

#include <CurlHandlePool.h>

Collaboration diagram for dmrpp::CurlHandlePool:
Collaboration graph

Public Member Functions

 CurlHandlePool (unsigned int max_handles)
 
dmrpp_easy_handleget_easy_handle (Chunk *chunk)
 
unsigned int get_handles_available () const
 
unsigned int get_max_handles () const
 Get the number of handles in the pool.
 
void release_all_handles ()
 
void release_handle (Chunk *chunk)
 Release the handle associated with a given chunk This is intended for use in error clean up code.
 
void release_handle (dmrpp_easy_handle *h)
 

Friends

class Lock
 

Detailed Description

Get a CURL easy handle, assign a URL and other values, use the handler, return it to the pool. This class helps take advantage of libculr's built-in reuse capabilities (connection keep-alive, DNS pooling, etc.).

Note
It may be that TCP Keep Alive is not supported in libcurl versions prior to 7.25, which means CentOS 6 will not have support for this.

See https://ec.haxx.se/libcurl-connectionreuse.html for more information.

See d_max_easy_handles below for the limit on the total number of easy handles.

Definition at line 79 of file CurlHandlePool.h.

Constructor & Destructor Documentation

◆ CurlHandlePool()

CurlHandlePool::CurlHandlePool ( unsigned int  max_handles)
explicit

Definition at line 293 of file CurlHandlePool.cc.

◆ ~CurlHandlePool()

dmrpp::CurlHandlePool::~CurlHandlePool ( )
inline

Definition at line 91 of file CurlHandlePool.h.

Member Function Documentation

◆ get_easy_handle()

dmrpp_easy_handle * CurlHandlePool::get_easy_handle ( Chunk chunk)

Get a CURL easy handle to transfer data from

  • url into the given
  • chunk.
Note
This method and release_handle() use the same lock to prevent the handle's chunk pointer from being cleared by another thread after a thread running this method has set it. However, there's no protection against calling this when no more handles are available. If that happens a thread calling release_handle() will block until this code returns (and this code will return NULL).
Parameters
chunkUse this Chunk to set a libcurl easy handle so that it will fetch the Chunk's data.
Returns
A CURL easy handle configured to transfer data, or null if there are no more handles in the pool.

Definition at line 314 of file CurlHandlePool.cc.

◆ get_handles_available()

unsigned int dmrpp::CurlHandlePool::get_handles_available ( ) const
inline

Definition at line 102 of file CurlHandlePool.h.

◆ get_max_handles()

unsigned int dmrpp::CurlHandlePool::get_max_handles ( ) const
inline

Get the number of handles in the pool.

Definition at line 99 of file CurlHandlePool.h.

◆ release_all_handles()

void CurlHandlePool::release_all_handles ( )

@breif release all outstanding curl handles If one access in a multi-transfer fails because of an error such as Access Denied, end the entire process and free all curl handles. This is different from an Internal Server Error response, which should be retried without ending the other accesses.

Definition at line 485 of file CurlHandlePool.cc.

◆ release_handle() [1/2]

void CurlHandlePool::release_handle ( Chunk chunk)

Release the handle associated with a given chunk This is intended for use in error clean up code.

Parameters
chunkFind the handle for this chunk and release it.

Definition at line 469 of file CurlHandlePool.cc.

◆ release_handle() [2/2]

void CurlHandlePool::release_handle ( dmrpp_easy_handle handle)

Release a DMR++ easy_handle. This returns the handle to the pool of handles that can be used for serial transfers or, with multi curl, for parallel transfers.

Parameters
handle

Definition at line 434 of file CurlHandlePool.cc.

Friends And Related Function Documentation

◆ Lock

friend class Lock
friend

Definition at line 85 of file CurlHandlePool.h.


The documentation for this class was generated from the following files: