~ubuntu-branches/debian/sid/subversion/sid

« back to all changes in this revision

Viewing changes to subversion/libsvn_subr/cache-memcache.c

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2015-08-07 21:32:47 UTC
  • mfrom: (0.2.15) (4.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20150807213247-ozyewtmgsr6tkewl
Tags: 1.9.0-1
* Upload to unstable
* New upstream release.
  + Security fixes
    - CVE-2015-3184: Mixed anonymous/authenticated path-based authz with
      httpd 2.4
    - CVE-2015-3187: svn_repos_trace_node_locations() reveals paths hidden
      by authz
* Add >= 2.7 requirement for python-all-dev Build-Depends, needed to run
  tests.
* Remove Build-Conflicts against ruby-test-unit.  (Closes: #791844)
* Remove patches/apache_module_dependency in favor of expressing the
  dependencies in authz_svn.load/dav_svn.load.
* Build-Depend on apache2-dev (>= 2.4.16) to ensure ap_some_authn_required()
  is available when building mod_authz_svn and Depend on apache2-bin (>=
  2.4.16) for runtime support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
99
99
    }
100
100
 
101
101
  long_key = apr_pstrcat(pool, "SVN:", cache->prefix, ":", encoded_suffix,
102
 
                         (char *)NULL);
 
102
                         SVN_VA_NULL);
103
103
  long_key_len = strlen(long_key);
104
104
 
105
105
  /* We don't want to have a key that's too big.  If it was going to
120
120
                             apr_pstrmemdup(pool, long_key,
121
121
                                            MEMCACHED_KEY_UNHASHED_LEN),
122
122
                             svn_checksum_to_cstring_display(checksum, pool),
123
 
                             (char *)NULL);
 
123
                             SVN_VA_NULL);
124
124
    }
125
125
 
126
126
  *mc_key = long_key;
214
214
  return SVN_NO_ERROR;
215
215
}
216
216
 
 
217
/* Implement vtable.has_key in terms of the getter.
 
218
 */
 
219
static svn_error_t *
 
220
memcache_has_key(svn_boolean_t *found,
 
221
                 void *cache_void,
 
222
                 const void *key,
 
223
                 apr_pool_t *scratch_pool)
 
224
{
 
225
  char *data;
 
226
  apr_size_t data_len;
 
227
  SVN_ERR(memcache_internal_get(&data,
 
228
                                &data_len,
 
229
                                found,
 
230
                                cache_void,
 
231
                                key,
 
232
                                scratch_pool));
 
233
 
 
234
  return SVN_NO_ERROR;
 
235
}
 
236
 
217
237
/* Core functionality of our setter functions: store LENGH bytes of DATA
218
238
 * to be identified by KEY in the memcached given by CACHE_VOID. Use POOL
219
239
 * for temporary allocations.
347
367
static svn_boolean_t
348
368
memcache_is_cachable(void *unused, apr_size_t size)
349
369
{
350
 
  (void)unused;  /* silence gcc warning. */
 
370
  SVN_UNUSED(unused);
351
371
 
352
372
  /* The memcached cutoff seems to be a bit (header length?) under a megabyte.
353
373
   * We round down a little to be safe.
367
387
 
368
388
  /* we don't have any memory allocation info */
369
389
 
370
 
  info->used_size = 0;
371
 
  info->total_size = 0;
372
 
  info->data_size = 0;
373
 
  info->used_entries = 0;
374
 
  info->total_entries = 0;
375
 
 
376
390
  return SVN_NO_ERROR;
377
391
}
378
392
 
379
393
static svn_cache__vtable_t memcache_vtable = {
380
394
  memcache_get,
 
395
  memcache_has_key,
381
396
  memcache_set,
382
397
  memcache_iter,
383
398
  memcache_is_cachable,
408
423
  wrapper->cache_internal = cache;
409
424
  wrapper->error_handler = 0;
410
425
  wrapper->error_baton = 0;
 
426
  wrapper->pretend_empty = !!getenv("SVN_X_DOES_NOT_MARK_THE_SPOT");
411
427
 
412
428
  *cache_p = wrapper;
413
429
  return SVN_NO_ERROR;
528
544
svn_error_t *
529
545
svn_cache__make_memcache_from_config(svn_memcache_t **memcache_p,
530
546
                                    svn_config_t *config,
531
 
                                    apr_pool_t *pool)
 
547
                                    apr_pool_t *result_pool,
 
548
                                    apr_pool_t *scratch_pool)
532
549
{
533
 
  int server_count;
534
 
  apr_pool_t *subpool = svn_pool_create(pool);
535
 
 
536
 
  server_count =
 
550
  int server_count =
537
551
    svn_config_enumerate2(config,
538
552
                          SVN_CACHE_CONFIG_CATEGORY_MEMCACHED_SERVERS,
539
 
                          nop_enumerator, NULL, subpool);
 
553
                          nop_enumerator, NULL, scratch_pool);
540
554
 
541
555
  if (server_count == 0)
542
556
    {
543
557
      *memcache_p = NULL;
544
 
      svn_pool_destroy(subpool);
545
558
      return SVN_NO_ERROR;
546
559
    }
547
560
 
551
564
#ifdef SVN_HAVE_MEMCACHE
552
565
  {
553
566
    struct ams_baton b;
554
 
    svn_memcache_t *memcache = apr_pcalloc(pool, sizeof(*memcache));
555
 
    apr_status_t apr_err = apr_memcache_create(pool,
 
567
    svn_memcache_t *memcache = apr_pcalloc(result_pool, sizeof(*memcache));
 
568
    apr_status_t apr_err = apr_memcache_create(result_pool,
556
569
                                               (apr_uint16_t)server_count,
557
570
                                               0, /* flags */
558
571
                                               &(memcache->c));
561
574
                                _("Unknown error creating apr_memcache_t"));
562
575
 
563
576
    b.memcache = memcache->c;
564
 
    b.memcache_pool = pool;
 
577
    b.memcache_pool = result_pool;
565
578
    b.err = SVN_NO_ERROR;
566
579
    svn_config_enumerate2(config,
567
580
                          SVN_CACHE_CONFIG_CATEGORY_MEMCACHED_SERVERS,
568
581
                          add_memcache_server, &b,
569
 
                          subpool);
 
582
                          scratch_pool);
570
583
 
571
584
    if (b.err)
572
585
      return b.err;
573
586
 
574
587
    *memcache_p = memcache;
575
588
 
576
 
    svn_pool_destroy(subpool);
577
589
    return SVN_NO_ERROR;
578
590
  }
579
591
#else /* ! SVN_HAVE_MEMCACHE */