Exemplo n.º 1
0
/* allocate memory for an instance of dashboard */
static void
allocate_data (void)
{
  GModule module;
  int col_data = get_num_collapsed_data_rows ();
  int size = 0;

  dash = new_gdash ();
  for (module = 0; module < TOTAL_MODULES; module++) {
    if (ignore_panel (module))
      continue;

    switch (module) {
    case VISITORS:
      dash->module[module].head =
        (!conf.ignore_crawlers ? VISIT_HEAD INCLUDE_BOTS : VISIT_HEAD);
      break;
    case REQUESTS:
      dash->module[module].head = REQUE_HEAD;
      break;
    case REQUESTS_STATIC:
      dash->module[module].head = STATI_HEAD;
      break;
    case NOT_FOUND:
      dash->module[module].head = FOUND_HEAD;
      break;
    case HOSTS:
      dash->module[module].head = HOSTS_HEAD;
      break;
    case OS:
      dash->module[module].head = OPERA_HEAD;
      break;
    case BROWSERS:
      dash->module[module].head = BROWS_HEAD;
      break;
    case VISIT_TIMES:
      dash->module[module].head = VTIME_HEAD;
      break;
    case REFERRERS:
      dash->module[module].head = REFER_HEAD;
      break;
    case REFERRING_SITES:
      dash->module[module].head = SITES_HEAD;
      break;
    case KEYPHRASES:
      dash->module[module].head = KEYPH_HEAD;
      break;
#ifdef HAVE_LIBGEOIP
    case GEO_LOCATION:
      dash->module[module].head = GEOLO_HEAD;
      break;
#endif
    case STATUS_CODES:
      dash->module[module].head = CODES_HEAD;
      break;
    }

    size = holder[module].idx;
    if (gscroll.expanded && module == gscroll.current) {
      size = size > MAX_CHOICES ? MAX_CHOICES : holder[module].idx;
    } else {
      size = holder[module].idx > col_data ? col_data : holder[module].idx;
    }

    dash->module[module].alloc_data = size;     /* data allocated  */
    dash->module[module].ht_size = holder[module].ht_size;      /* hash table size */
    dash->module[module].idx_data = 0;
    dash->module[module].pos_y = 0;

    if (gscroll.expanded && module == gscroll.current)
      dash->module[module].dash_size = DASH_EXPANDED;
    else
      dash->module[module].dash_size = DASH_COLLAPSED;
    dash->total_alloc += dash->module[module].dash_size;

    pthread_mutex_lock (&gdns_thread.mutex);
    load_data_to_dash (&holder[module], dash, module, &gscroll);
    pthread_mutex_unlock (&gdns_thread.mutex);
  }
}
Exemplo n.º 2
0
/* allocate memory for an instance of dashboard */
static void
allocate_data (void)
{
  int col_data = DASH_COLLAPSED - DASH_NON_DATA;
  int size = 0, ht_size = 0;

  int i;
  GModule module;

  dash = new_gdash ();
  for (i = 0; i < TOTAL_MODULES; i++) {
    module = i;

    switch (module) {
    case VISITORS:
      dash->module[module].head = VISIT_HEAD;
      dash->module[module].desc = VISIT_DESC;
      break;
    case REQUESTS:
      dash->module[module].head = REQUE_HEAD;
      dash->module[module].desc = REQUE_DESC;
      break;
    case REQUESTS_STATIC:
      dash->module[module].head = STATI_HEAD;
      dash->module[module].desc = STATI_DESC;
      break;
    case NOT_FOUND:
      dash->module[module].head = FOUND_HEAD;
      dash->module[module].desc = FOUND_DESC;
      break;
    case HOSTS:
      dash->module[module].head = HOSTS_HEAD;
      dash->module[module].desc = HOSTS_DESC;
      break;
    case OS:
      dash->module[module].head = OPERA_HEAD;
      dash->module[module].desc = OPERA_DESC;
      break;
    case BROWSERS:
      dash->module[module].head = BROWS_HEAD;
      dash->module[module].desc = BROWS_DESC;
      break;
    case REFERRERS:
      dash->module[module].head = REFER_HEAD;
      dash->module[module].desc = REFER_DESC;
      break;
    case REFERRING_SITES:
      dash->module[module].head = SITES_HEAD;
      dash->module[module].desc = SITES_DESC;
      break;
    case KEYPHRASES:
      dash->module[module].head = KEYPH_HEAD;
      dash->module[module].desc = KEYPH_DESC;
      break;
#ifdef HAVE_LIBGEOIP
    case GEO_LOCATION:
      dash->module[module].head = GEOLO_HEAD;
      dash->module[module].desc = GEOLO_DESC;
      break;
#endif
    case STATUS_CODES:
      dash->module[module].head = CODES_HEAD;
      dash->module[module].desc = CODES_DESC;
      break;
    }

    ht_size = get_ht_size_by_module (module);
    size = ht_size > col_data ? col_data : ht_size;
    if ((size > MAX_CHOICES) ||
        (scrolling.expanded && module == scrolling.current))
      size = MAX_CHOICES;

    dash->module[module].alloc_data = size;     /* data allocated  */
    dash->module[module].ht_size = ht_size;     /* hash table size */
    dash->module[module].idx_data = 0;
    dash->module[module].pos_y = 0;

    if (scrolling.expanded && module == scrolling.current)
      dash->module[module].dash_size = DASH_EXPANDED;
    else
      dash->module[module].dash_size = DASH_COLLAPSED;
    dash->total_alloc += dash->module[module].dash_size;

    pthread_mutex_lock (&gdns_thread.mutex);
    load_data_to_dash (&holder[module], dash, module, &scrolling);
    pthread_mutex_unlock (&gdns_thread.mutex);
  }
}