~brianaker/libmemcached/gear-clean

« back to all changes in this revision

Viewing changes to tests/libmemcached-1.0/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:
35
35
 *
36
36
 */
37
37
 
38
 
#include <mem_config.h>
 
38
#include <config.h>
39
39
#include <libtest/test.hpp>
40
40
 
41
41
using namespace libtest;
55
55
#include <pthread.h>
56
56
#include <poll.h>
57
57
 
58
 
#include "libmemcached/instance.hpp"
 
58
#include "libmemcached/instance.h"
59
59
 
60
60
#ifndef __INTEL_COMPILER
61
61
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
243
243
static __attribute__((noreturn)) void* connection_release(void *arg)
244
244
{
245
245
  test_pool_context_st *resource= static_cast<test_pool_context_st *>(arg);
246
 
  FATAL_IF(resource == NULL);
 
246
  if (resource == NULL)
 
247
  {
 
248
    fatal_message("resource == NULL");
 
249
  }
247
250
 
248
251
  // Release all of the memc we are holding 
249
252
  resource->rc= memcached_pool_release(resource->pool, resource->mmc);
340
343
   * I only want to hit _one_ server so I know the number of requests I'm
341
344
   * sending in the pipeline.
342
345
   */
343
 
  const memcached_instance_st * instance= memcached_server_instance_by_position(original_memc, 0);
 
346
  memcached_server_instance_st instance= memcached_server_instance_by_position(original_memc, 0);
344
347
 
345
348
  char server_string[1024];
346
349
  int server_string_length;
393
396
static void set_running(const bool arg)
394
397
{
395
398
  int error;
396
 
  FATAL_IF_((error= pthread_mutex_lock(&mutex)) != 0, strerror(error));
 
399
  if ((error= pthread_mutex_lock(&mutex)) != 0)
 
400
  {
 
401
    fatal_message(strerror(error));
 
402
  }
397
403
 
398
404
  _running= arg;
399
405
 
400
 
  FATAL_IF_((error= pthread_mutex_unlock(&mutex)) != 0, strerror(error));
 
406
  if ((error= pthread_mutex_unlock(&mutex)) != 0)
 
407
  {
 
408
    fatal_message(strerror(error));
 
409
  }
401
410
}
402
411
 
403
412
static bool running()
405
414
  int error;
406
415
  bool ret;
407
416
  
408
 
  FATAL_IF_((error= pthread_mutex_lock(&mutex)) != 0, strerror(error));
 
417
  if ((error= pthread_mutex_lock(&mutex)) != 0)
 
418
  {
 
419
    fatal_message(strerror(error));
 
420
  }
409
421
 
410
422
  ret= _running;
411
423
 
412
 
  FATAL_IF_((error= pthread_mutex_unlock(&mutex)) != 0, strerror(error));
 
424
  if ((error= pthread_mutex_unlock(&mutex)) != 0)
 
425
  {
 
426
    fatal_message(strerror(error));
 
427
  }
413
428
 
414
429
  return ret;
415
430
}
489
504
    test_compare(0, pthread_join(pid[x], NULL));
490
505
  }
491
506
 
492
 
  memcached_pool_destroy(pool);
 
507
  if (pool)
 
508
  {
 
509
    memcached_pool_destroy(pool);
 
510
  }
493
511
 
494
 
  memcached_free(master);
 
512
  if (master)
 
513
  {
 
514
    memcached_free(master);
 
515
  }
495
516
 
496
517
  return TEST_SUCCESS;
497
518
}