Changeset 14071


Ignore:
Timestamp:
Apr 13, 2013, 8:56:24 PM (8 years ago)
Author:
jordan
Message:

(trunk libT) #1079 'webseeds don't respect speed limits': fixed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/web.c

    r14070 r14071  
    2525
    2626#include "transmission.h"
     27#include "list.h"
    2728#include "log.h"
    2829#include "net.h" /* tr_address */
     
    4142enum
    4243{
    43   THREADFUNC_MAX_SLEEP_MSEC = 1000,
     44  THREADFUNC_MAX_SLEEP_MSEC = 200,
    4445};
    4546
     
    9697***/
    9798
     99static tr_list  * paused_easy_handles = NULL;
     100
    98101struct tr_web
    99102{
     
    116119  const size_t byteCount = size * nmemb;
    117120  struct tr_web_task * task = vtask;
     121
     122  /* webseed downloads should be speed limited */
     123  if (task->torrentId != -1)
     124    {
     125      tr_torrent * tor = tr_torrentFindFromId (task->session, task->torrentId);
     126
     127      if (tor && !tr_bandwidthClamp (&tor->bandwidth, TR_DOWN, nmemb))
     128        {
     129          tr_list_append (&paused_easy_handles, task->curl_easy);
     130          return CURL_WRITEFUNC_PAUSE;
     131        }
     132    }
     133
    118134  evbuffer_add (task->response, ptr, byteCount);
    119135  dbgmsg ("wrote %zu bytes to task %p's buffer", byteCount, task);
     
    412428        }
    413429      tr_lockUnlock (web->taskLock);
     430
     431      /* unpause any paused curl handles */
     432      if (paused_easy_handles != NULL)
     433        {
     434          CURL * handle;
     435          while ((handle = tr_list_pop_front (&paused_easy_handles)))
     436            curl_easy_pause (handle, CURLPAUSE_CONT);
     437        }
    414438
    415439      /* maybe wait a little while before calling curl_multi_perform () */
Note: See TracChangeset for help on using the changeset viewer.