~brianaker/libmemcached/gear-clean

« back to all changes in this revision

Viewing changes to libmemcachedutil/pool.cc

  • Committer: Brian Aker
  • Date: 2012-09-24 01:36:01 UTC
  • mto: This revision was merged to the branch mainline in revision 1072.
  • Revision ID: brian@tangent.org-20120924013601-4f0zeykol10ka6so
Updates from ddm4

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
    for (int x= 0; x <= firstfree; ++x)
87
87
    {
88
88
      memcached_free(server_pool[x]);
89
 
      server_pool[x]= NULL;
90
 
    }
91
 
 
92
 
    int error;
93
 
    if ((error= pthread_mutex_destroy(&mutex)) != 0)
94
 
    {
95
 
      assert_vmsg(error != 0, "pthread_mutex_destroy() %s(%d)", strerror(error), error);
96
 
    }
97
 
 
98
 
    if ((error= pthread_cond_destroy(&cond)) != 0)
99
 
    {
100
 
      assert_vmsg(error != 0, "pthread_cond_destroy() %s", strerror(error));
101
 
    }
102
 
 
 
89
      server_pool[x] = NULL;
 
90
    }
 
91
 
 
92
    pthread_mutex_destroy(&mutex);
 
93
    pthread_cond_destroy(&cond);
103
94
    delete [] server_pool;
104
95
    if (_owns_master)
105
96
    {
148
139
bool memcached_pool_st::init(uint32_t initial)
149
140
{
150
141
  server_pool= new (std::nothrow) memcached_st *[size];
151
 
  if (server_pool == NULL)
152
 
  {
 
142
  if (not server_pool)
153
143
    return false;
154
 
  }
155
144
 
156
145
  /*
157
146
    Try to create the initial size of the pool. An allocation failure at
286
275
        int unlock_error;
287
276
        if ((unlock_error= pthread_mutex_unlock(&mutex)) != 0)
288
277
        {
289
 
          assert_vmsg(error != 0, "pthread_mutex_unlock() %s", strerror(error));
290
278
        }
291
279
 
292
280
        if (thread_ret == ETIMEDOUT)
307
295
      int unlock_error;
308
296
      if ((unlock_error= pthread_mutex_unlock(&mutex)) != 0)
309
297
      {
310
 
        assert_vmsg(error != 0, "pthread_mutex_unlock() %s", strerror(error));
311
298
      }
312
299
 
313
300
      return NULL;
316
303
 
317
304
  if ((error= pthread_mutex_unlock(&mutex)) != 0)
318
305
  {
319
 
    assert_vmsg(error != 0, "pthread_mutex_unlock() %s", strerror(error));
320
306
  }
321
307
 
322
308
  return ret;
358
344
    /* we might have people waiting for a connection.. wake them up :-) */
359
345
    if ((error= pthread_cond_broadcast(&cond)) != 0)
360
346
    {
361
 
      assert_vmsg(error != 0, "pthread_cond_broadcast() %s", strerror(error));
362
347
    }
363
348
  }
364
349
 
459
444
  {
460
445
    if ((error= pthread_mutex_unlock(&pool->mutex)) != 0)
461
446
    {
462
 
      assert_vmsg(error != 0, "pthread_mutex_unlock() %s", strerror(error));
463
447
    }
464
448
    return rc;
465
449
  }
491
475
 
492
476
  if ((error= pthread_mutex_unlock(&pool->mutex)) != 0)
493
477
  {
494
 
    assert_vmsg(error != 0, "pthread_mutex_unlock() %s", strerror(error));
495
478
  }
496
479
 
497
480
  return rc;
516
499
 
517
500
  if ((error= pthread_mutex_unlock(&pool->mutex)) != 0)
518
501
  {
519
 
    assert_vmsg(error != 0, "pthread_mutex_unlock() %s", strerror(error));
520
502
  }
521
503
 
522
504
  return MEMCACHED_SUCCESS;