Beispiel #1
0
int grpc_chttp2_hptbl_set_current_table_size(grpc_chttp2_hptbl *tbl,
                                             uint32_t bytes) {
  if (tbl->current_table_bytes == bytes) {
    return 1;
  }
  if (bytes > tbl->max_bytes) {
    if (grpc_http_trace) {
      gpr_log(GPR_ERROR,
              "Attempt to make hpack table %d bytes when max is %d bytes",
              bytes, tbl->max_bytes);
    }
    return 0;
  }
  if (grpc_http_trace) {
    gpr_log(GPR_DEBUG, "Update hpack parser table size to %d", bytes);
  }
  while (tbl->mem_used > bytes) {
    evict1(tbl);
  }
  tbl->current_table_bytes = bytes;
  tbl->max_entries = entries_for_bytes(bytes);
  if (tbl->max_entries > tbl->cap_entries) {
    rebuild_ents(tbl, GPR_MAX(tbl->max_entries, 2 * tbl->cap_entries));
  } else if (tbl->max_entries < tbl->cap_entries / 3) {
    uint32_t new_cap = GPR_MAX(tbl->max_entries, 16u);
    if (new_cap != tbl->cap_entries) {
      rebuild_ents(tbl, new_cap);
    }
  }
  return 1;
}
Beispiel #2
0
static struct mds_apf* rebuild(
    struct mds_apf* m,
    struct mds_tag* new_of,
    int ignore_peers)
{
  struct mds_apf* m2;
  struct mds_tag* old_of;
  m2 = mds_apf_create(m->user_model, m->mds.d, m->mds.n);
  old_of = invert(&m->mds, m2, new_of);
  rebuild_verts(m, m2, old_of);
  rebuild_ents(m, m2, old_of, new_of);
  rebuild_tags(m, m2, old_of, new_of);
  rebuild_coords(m, m2, old_of);
  rebuild_parts(m, m2, old_of);
  if (!ignore_peers) {
    rebuild_net(&m->remotes, &m->mds,
                &m2->remotes, &m2->mds,
                new_of);
    rebuild_net(&m->matches, &m->mds,
                &m2->matches, &m2->mds,
                new_of);
  }
  mds_destroy_tag(&m2->tags, old_of);
  return m2;
}