Changeset 14182


Ignore:
Timestamp:
Aug 25, 2013, 4:27:19 PM (8 years ago)
Author:
jordan
Message:

make accessing tr_list's recycle nodes threadsafe. patch by mike.did, fixes #5352

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/list.c

    r13625 r14182  
    1313#include "transmission.h"
    1414#include "list.h"
     15#include "platform.h"
    1516#include "utils.h"
    1617
     
    1819
    1920static tr_list * recycled_nodes = NULL;
     21
     22static tr_lock*
     23getRecycledNodesLock (void)
     24{
     25  static tr_lock * l = NULL;
     26
     27  if (!l)
     28    l = tr_lockNew ();
     29
     30  return l;
     31}
    2032
    2133static tr_list*
     
    3042  else
    3143    {
     44      tr_lockLock (getRecycledNodesLock ());
    3245      ret = recycled_nodes;
    3346      recycled_nodes = recycled_nodes->next;
     47      tr_lockUnlock (getRecycledNodesLock ());
    3448    }
    3549
     
    4458    {
    4559      *node = TR_LIST_CLEAR;
     60      tr_lockLock (getRecycledNodesLock ());
    4661      node->next = recycled_nodes;
    4762      recycled_nodes = node;
     63      tr_lockUnlock (getRecycledNodesLock ());
    4864    }
    4965}
Note: See TracChangeset for help on using the changeset viewer.