Exemple #1
0
static int fq_codel_dump_stats(struct Qdisc *sch, struct gnet_dump *d)
{
	struct fq_codel_sched_data *q = qdisc_priv(sch);
	struct tc_fq_codel_xstats st = {
		.type				= TCA_FQ_CODEL_XSTATS_QDISC,
	};
	struct list_head *pos;

	st.qdisc_stats.maxpacket = q->cstats.maxpacket;
	st.qdisc_stats.drop_overlimit = q->drop_overlimit;
	st.qdisc_stats.ecn_mark = q->cstats.ecn_mark;
	st.qdisc_stats.new_flow_count = q->new_flow_count;
	st.qdisc_stats.ce_mark = q->cstats.ce_mark;
	st.qdisc_stats.memory_usage  = q->memory_usage;
	st.qdisc_stats.drop_overmemory = q->drop_overmemory;

	sch_tree_lock(sch);
	list_for_each(pos, &q->new_flows)
		st.qdisc_stats.new_flows_len++;

	list_for_each(pos, &q->old_flows)
		st.qdisc_stats.old_flows_len++;
	sch_tree_unlock(sch);

	return gnet_stats_copy_app(d, &st, sizeof(st));
}
Exemple #2
0
/**
 * zfcp_rec_dbf_event_thread - trace event related to recovery thread operation
 * @id2: identifier for event
 * @adapter: adapter
 * @lock: non-zero value indicates that erp_lock has not yet been acquired
 */
void zfcp_rec_dbf_event_thread(u8 id2, struct zfcp_adapter *adapter, int lock)
{
    struct zfcp_rec_dbf_record *r = &adapter->rec_dbf_buf;
    unsigned long flags = 0;
    struct list_head *entry;
    unsigned ready = 0, running = 0, total;

    if (lock)
        read_lock_irqsave(&adapter->erp_lock, flags);
    list_for_each(entry, &adapter->erp_ready_head)
        ready++;
    list_for_each(entry, &adapter->erp_running_head)
        running++;
    total = adapter->erp_total_count;
    if (lock)
        read_unlock_irqrestore(&adapter->erp_lock, flags);

    spin_lock_irqsave(&adapter->rec_dbf_lock, flags);
    memset(r, 0, sizeof(*r));
    r->id = ZFCP_REC_DBF_ID_THREAD;
    r->id2 = id2;
    r->u.thread.total = total;
    r->u.thread.ready = ready;
    r->u.thread.running = running;
    debug_event(adapter->rec_dbf, 5, r, sizeof(*r));
    spin_unlock_irqrestore(&adapter->rec_dbf_lock, flags);
}
Exemple #3
0
/**
 * zfcp_dbf_rec_trig - trace event related to triggered recovery
 * @tag: identifier for event
 * @adapter: adapter on which the erp_action should run
 * @port: remote port involved in the erp_action
 * @sdev: scsi device involved in the erp_action
 * @want: wanted erp_action
 * @need: required erp_action
 *
 * The adapter->erp_lock has to be held.
 */
void zfcp_dbf_rec_trig(char *tag, struct zfcp_adapter *adapter,
		       struct zfcp_port *port, struct scsi_device *sdev,
		       u8 want, u8 need)
{
	struct zfcp_dbf *dbf = adapter->dbf;
	struct zfcp_dbf_rec *rec = &dbf->rec_buf;
	static int const level = 1;
	struct list_head *entry;
	unsigned long flags;

	if (unlikely(!debug_level_enabled(dbf->rec, level)))
		return;

	spin_lock_irqsave(&dbf->rec_lock, flags);
	memset(rec, 0, sizeof(*rec));

	rec->id = ZFCP_DBF_REC_TRIG;
	memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN);
	zfcp_dbf_set_common(rec, adapter, port, sdev);

	list_for_each(entry, &adapter->erp_ready_head)
		rec->u.trig.ready++;

	list_for_each(entry, &adapter->erp_running_head)
		rec->u.trig.running++;

	rec->u.trig.want = want;
	rec->u.trig.need = need;

	debug_event(dbf->rec, level, rec, sizeof(*rec));
	spin_unlock_irqrestore(&dbf->rec_lock, flags);
}
Exemple #4
0
/* Read an s-expression from a FILE and buffer lines in a linked-list */
char *read_sexp(FILE *in) {
  struct list_t *head = NULL;
  int parens = 0;
  int quote = 0;

  char *buf = malloc(sizeof(*buf) * MAX_LINE);
  if(buf == NULL)
    return NULL;
  buf[0] = '\0';

  /* while there are valid lines and while the parens are not matched */
  char *str;
  while((str = fgets(buf, MAX_LINE, in)) != NULL) {

    quote = strip_comments(buf, quote);
    if(buf[0] == '\n' || buf[0] == '\0') /* skip totally blank lines */
      continue;

    /* break if we've read a matched s-expression */
    if((parens += count_parens(buf, MAX_LINE)) == 0)
      break;

    head = list_push(buf, head);

    buf = malloc(sizeof(*buf) * MAX_LINE);
    if(buf == NULL) {
      list_for_each(head, &list_free_node);
      return NULL;
    }
  }

  if(str == NULL) {
    list_for_each(head, &list_free_node);
    free(buf);
    return NULL;
  }

  quote = strip_comments(buf, quote);
  head = list_push(buf, head);
  head = list_reverse(head);

  size_t len = 0;
  struct list_t *n;
  for(n = head; n != NULL; n = n->next)
    len += strlen((char *) n->data);

  char *concat = malloc(sizeof(*concat) * (len+1));
  char *i = concat;
  for(n = head; n != NULL; n = n->next) {
    len = strlen(n->data);
    strncpy(i, (char*)n->data, len);
    i += len;
  }
  *i = '\0';
  list_for_each(head, &list_free_node);
  return concat;
}
Exemple #5
0
int main(int argc, char **argv) {
  int i;
  struct list_t *head = NULL;
  for(i = 1; i < argc; i++) {
    head = list_push(argv[i], head);
  }

  list_for_each(head, &list_print_node);
  printf("\n");
  head = list_reverse(head);
  list_for_each(head, &list_print_node);
  printf("\n");
}
Exemple #6
0
VbError_t VbExDiskGetInfo(VbDiskInfo **info_ptr, uint32_t *count,
			  uint32_t disk_flags)
{
	*count = 0;

	blockdev_type_t bd_type;
	ListNode *devs;

	if (disk_flags & VB_DISK_FLAG_FIXED)
		bd_type = BLOCKDEV_FIXED;
	else
		bd_type = BLOCKDEV_REMOVABLE;

	*count = get_all_bdevs(bd_type, &devs);

	// Only log for fixed disks to avoid spamming timestamps in recovery.
	if (disk_flags & VB_DISK_FLAG_FIXED)
		timestamp_add_now(TS_VB_STORAGE_INIT_DONE);

	// Allocate enough VbDiskInfo structures.
	VbDiskInfo *disk = NULL;
	if (*count)
		disk = xzalloc(sizeof(VbDiskInfo) * *count);

	*info_ptr = disk;

	// Fill them from the BlockDev structures.
	BlockDev *bdev;
	list_for_each(bdev, *devs, list_node)
		setup_vb_disk_info(disk++, bdev);

	return VBERROR_SUCCESS;
}
Exemple #7
0
bool
t_opt_const(t_opt *o, int ac, char **av)
{
  ZERO_MEM(o);
  if (ac < 2)
    return (usage(av), false);
  o->teams = new_list();
  if (!o->teams)
    return (TRACE("new_list() failed"), t_opt_dest(o), false);
  if (!parse_av(o, ac, av))
    return (t_opt_dest(o), false);
  if (!(is_in_list(o->teams, GRAPHIC_TEAM_NAME)) &&
      !(insert_graphic_team(&o->teams)))
    return (t_opt_dest(o), false);

  o->x_size = (o->x_size > 10) ? o->x_size : 20;
  o->y_size = (o->y_size > 10) ? o->y_size : 20;
  o->max_clients = o->max_clients ? o->max_clients : 10;
  o->time = o->time ? o->time : 100;

  if (!opts_are_valid(o))
    return (usage(av), t_opt_dest(o), false);
  list_for_each(o->teams, &assign_max_clients_nb, &o->max_clients);
  return (true);
}
Exemple #8
0
static char *_build_cluster_string(void)
{
	char *cluster_str = NULL;
	slurmdb_federation_rec_t *fed = NULL;
	slurmdb_federation_cond_t fed_cond;
	List fed_list = NULL;
	List cluster_list = list_create(NULL);

	list_append(cluster_list, slurmctld_conf.cluster_name);
	slurmdb_init_federation_cond(&fed_cond, 0);
	fed_cond.cluster_list = cluster_list;

	if ((fed_list =
	     slurmdb_federations_get(db_conn, &fed_cond)) &&
	    list_count(fed_list) == 1) {
		fed = list_pop(fed_list);
		fed_name = xstrdup(fed->name);
		list_for_each(fed->cluster_list, _foreach_cluster_list_to_str,
			      &cluster_str);
	}
	slurm_destroy_federation_rec(fed);
	FREE_NULL_LIST(cluster_list);
	FREE_NULL_LIST(fed_list);

	return cluster_str;
}
Exemple #9
0
/*
 * Checks for timers which have had their timeout value pass and executes their
 * callback function.  The timer is then removed from the active timer list
 * and then enqueued back into the passive timer queue
 */
void
timer_tick(void)
{
	now = timer_now_forced();
	list_for_each(active_timers, &timer_has_expired);
	list_remove_if_true(active_timers, &timer_deactivate);
}
Exemple #10
0
static void test_empty(void)
{
	struct list_node *spos, *ssafe;
	struct node *pos, *safe;

	check(!slist_is_empty(&slist),
	      "slist is empty but slist_is_empty returned false");
	check(!list_is_empty(&list),
	      "list is empty but list_is_empty returned false");

	check(slist_head(&slist) != &slist,
	      "slist is empty but slist_head returned non-self");
	check(list_head(&list) != NULL,
	      "list is empty but list_head returned non-NULL");

	check(slist_tail(&slist) != &slist,
	      "slist is empty but slist_tail returned non-self");
	check(list_tail(&list) != NULL,
	      "list is empty but list_tail returned non-NULL");

	check_loop_never(slist_for_each(spos, &slist),
			 "slist is empty, but slist_for_each looped");
	check_loop_never(list_for_each(pos, &list),
			 "list is empty, but list_for_each looped");

	check_loop_never(slist_for_each_safe(spos, ssafe, &slist),
			 "slist is empty, but slist_for_each_safe looped");
	check_loop_never(list_for_each_safe(pos, safe, &list),
			 "list is empty, but list_for_each_safe looped");

	check_loop_never(slist_for_each_entry(pos, &slist, node),
			 "slist is empty, but slist_for_each_entry looped");
	check_loop_never(slist_for_each_entry_safe(pos, safe, &slist, node),
			 "slist is empty, but slist_for_each-entry_safe looped");
}
Exemple #11
0
void module_set_param_links(struct fins_module *module, struct finsFrame *ff) {
    PRINT_DEBUG("Entered: module=%p, ff=%p, meta=%p", module, ff, ff->metaData);
    struct fins_module_table *mt = (struct fins_module_table *) module->data;

    if (ff->ctrlFrame.data_len != sizeof(struct linked_list)) {
        PRINT_WARN("todo error");
        freeFinsFrame(ff);
        return;
    }

    if (mt->link_list != NULL) {
        list_free(mt->link_list, free);
    }
    mt->link_list = (struct linked_list *) ff->ctrlFrame.data;

    int i;
    for (i = 0; i < mt->flows_num; i++) {
        mt->flows[i].link = (struct link_record *) list_find1(mt->link_list, link_id_test, &mt->flows[i].link_id);
    }

#ifdef DEBUG
    list_for_each(mt->link_list, link_print);
#endif

    ff->ctrlFrame.data = NULL;
    freeFinsFrame(ff);
}
Exemple #12
0
static void add_stats(struct line *line, struct pattern *p, struct values *vals)
{
	size_t i;

	for (i = 0; i < p->num_parts; i++) {
		if (p->part[i].type == LITERAL)
			continue;
		if (p->part[i].type == FLOAT
		    && line->pattern->part[i].type == INTEGER) {
			struct values *v;

			/* Convert all previous entries to float. */
			list_for_each(&line->vals, v, list)
				val_to_float(&v->vals[i]);
			line->pattern->part[i].type = FLOAT;
		} else if (p->part[i].type == INTEGER
			   && line->pattern->part[i].type == FLOAT) {
			val_to_float(&vals->vals[i]);
			p->part[i].type = FLOAT;
		}
		assert(p->part[i].type == line->pattern->part[i].type);
	}
	free(p);
	list_add_tail(&line->vals, &vals->list);
	line->count++;
}
Exemple #13
0
static si_t application_update_keybd_focus(struct widget* w)
{
    /**
     * set w lose focus first so that it will not be paint twice 
     **/
    if(w != NULL && w->input_enable)
    {
        w->keybd_focus = 0;
    }

    /**
     * set all other input_enable applications lose focus
     **/
    list_for_each(&global_application.focus_list, application_keybd_lose_focus);

    /**
     * gain focus
     **/
    if(w != NULL && w->input_enable)
    {
        w->keybd_focus = 1;
    }
    
    return 0;
}
Exemple #14
0
static void __com_val(nvlist_t *post, list_t *list)
{
	struct comment *cur;
	nvlist_t **comments;
	uint_t ncomments;
	int i;

	/* count the comments */
	ncomments = 0;
	list_for_each(list, cur)
		ncomments++;

	comments = malloc(sizeof(nvlist_t *) * ncomments);
	ASSERT(comments);

	i = 0;
	list_for_each(list, cur) {
		comments[i] = nvl_alloc();

		nvl_set_int(comments[i], "commid", cur->id);
		nvl_set_int(comments[i], "commtime", cur->time);
		nvl_set_str(comments[i], "commauthor", str_cstr(cur->author));
		nvl_set_str(comments[i], "commemail", str_cstr(cur->email));
		nvl_set_str(comments[i], "commip", str_cstr(cur->ip));
		nvl_set_str(comments[i], "commurl", str_cstr(cur->url));
		nvl_set_str(comments[i], "commbody", str_cstr(cur->body));

		i++;
	}
Exemple #15
0
static si_t spinbox_value_change(struct spinbox *s, si_t delta)
{
    if(!s) {
        return 0;
    }
    if(s->minval<=s->maxval &&
            (s->value+delta < s->minval || s->value+delta > s->maxval)) {
        return 0;
    }
    s->value += delta;
    if(delta) {
        list_for_each(&s->subscribe_info_list, do_handle_event);
    }
    if(atoi(text_line_get_buf(s->text_number)) != s->value) {
        sprintf(text_line_get_buf(s->text_number), "%ld", s->value);
        if(s->text_number->ruler_cur >
                s->text_number->buf + strlen(s->text_number->buf)) {
            s->text_number->ruler_cur =
                s->text_number->buf + strlen(s->text_number->buf);
        }
        text_line_repaint(s->text_number);
        text_line_show(s->text_number);
    }
    return 1;
}
Exemple #16
0
int print_jobs_array(job_info_t * jobs, int size, List format)
{
	int i;
	List l;

	l = list_create(NULL);
	if (!params.no_header)
		print_job_from_format(NULL, format);

	/* Filter out the jobs of interest */
	for (i = 0; i < size; i++) {
		if (_filter_job(&jobs[i]))
			continue;
		if (_merge_job_array(l, &jobs[i]))
			continue;
		list_append(l, (void *) &jobs[i]);
	}
	sort_jobs_by_start_time (l);
	sort_job_list (l);

	/* Print the jobs of interest */
	list_for_each (l, (ListForF) print_job_from_format, (void *) format);
	list_destroy (l);

	return SLURM_SUCCESS;
}
Exemple #17
0
static void* updateTimeZones (void* ptr)
{
    wList           timeZones;
    /* Interval is in milliseconds */
    unsigned int    checkInterval = 60000;

    wsem_init (&sTzSem, 0, 0);
    /* Until interrupted */
    do
    {
        /* Lock access to the list of timezones while we recheck. */
        wthread_static_mutex_lock (&sVector_mutex);

        timeZones = getTimeZones();

        list_for_each (timeZones, checkTzIter, NULL);

        wthread_static_mutex_unlock (&sVector_mutex);

        if (sScanningThreadInterval)
        {
            checkInterval = sScanningThreadInterval * 1000;
        }

    } while (0 != wsem_timedwait (&sTzSem, checkInterval) && sThreadStarted);

    /* The return value is not applicable. */
    return NULL;
}
Exemple #18
0
/*
 * _respond_with_event_names
 *
 * Return 0 on success, -1 on error
 */
static void *
_respond_with_event_names(void *arg)
{
  struct cerebrod_event_names_response_data enr;
  List responses = NULL;
  int fd;

  assert(arg);

  fd = *((int *)arg);
  
  if (!event_names)
    goto end_response;

  if (!List_count(event_names))
    goto end_response;

  if (!(responses = list_create((ListDelF)free)))
    {
      CEREBROD_ERR(("list_create: %s", strerror(errno)));
      _event_server_err_only_response(fd,
                                      CEREBRO_EVENT_SERVER_PROTOCOL_VERSION,
                                      CEREBRO_EVENT_SERVER_PROTOCOL_ERR_INTERNAL_ERROR);
      goto cleanup;
    }

  enr.fd = fd;
  enr.responses = responses;

  /* Event names is not changeable - so no need for a lock */
  if (list_for_each(event_names, _event_names_callback, &enr) < 0)
    {
      _event_server_err_only_response(fd,
                                      CEREBRO_EVENT_SERVER_PROTOCOL_VERSION,
                                      CEREBRO_EVENT_SERVER_PROTOCOL_ERR_INTERNAL_ERROR);
      goto cleanup;
    }

  if (_send_event_names(fd, responses) < 0)
    {
      _event_server_err_only_response(fd,
                                      CEREBRO_EVENT_SERVER_PROTOCOL_VERSION,
                                      CEREBRO_EVENT_SERVER_PROTOCOL_ERR_INTERNAL_ERROR);
      goto cleanup;
    }

 end_response:
  if (_send_event_names_end_response(fd) < 0)
    goto cleanup;

 cleanup:
  if (responses)
    list_destroy(responses);
  Free(arg);
  /* ignore potential error, we're done sendin */
  close(fd);
  return NULL;
}
Exemple #19
0
static void us122l_stop(struct us122l *us122l)
{
	struct list_head *p;
	list_for_each(p, &us122l->midi_list)
		snd_usbmidi_input_stop(p);

	usb_stream_stop(&us122l->sk);
	usb_stream_free(&us122l->sk);
}
Exemple #20
0
static size_t list_count(struct list_head *list)
{
        size_t count = 0;
        struct opal_msg_entry *dummy;

        list_for_each(list, dummy, link)
                count++;
        return count;
}
Exemple #21
0
void pool_shutdown(struct thread_pool *pool) {
	PRINT_DEBUG("Entered: pool=%p", pool);

	//controller_shutdown(pool->controller);

	list_for_each(pool->workers, worker_shutdown);

	//TODO reject queued jobs?
}
Exemple #22
0
static int list_count(struct list_head* list)
{
  int count = 0;
  struct list_head* pos;

  list_for_each(pos, list)
    count++;

  return count;
}
Exemple #23
0
static int num_flashes(void)
{
	struct flash *flash;
	int i = 0;

	list_for_each(&flashes, flash, list)
		i++;

	return i;
}
Exemple #24
0
static char *obj_list(const struct manifest *m)
{
	char *list = talloc_strdup(m, "");
	struct ccan_file *i;

	/* Objects from all the C files. */
	list_for_each(&m->c_files, i, list)
		list = talloc_asprintf_append(list, "%s ", i->compiled);

	return list;
}
Exemple #25
0
void entity_nodes_walk(entity_t* entity,
		       void (*callback)(layout_t* layout,
					void* node,
					void* arg),
		       void* arg)
{
	_entity_nodes_walkstruct_t real_arg;
	real_arg.callback = callback;
	real_arg.arg = arg;
	list_for_each(entity->nodes, _entity_nodes_walkfunc, &real_arg);
}
Exemple #26
0
ret_t
cherokee_list_get_len (cherokee_list_t *head, size_t *len)
{
	cherokee_list_t *i;
	cuint_t          n = 0;

	list_for_each (i, head)
		n++;

	*len = n;
	return ret_ok;
}
Exemple #27
0
void *sample2(void *arg) {
    struct list *list;

    list = (struct list *)arg;

    while(1) {
        int *a = malloc(sizeof(int));
        *a = 2;
        list_add(list, a);
        list_for_each(list, print_int);
        list_remove(list, a, int_cmp, int_free);
    }
}
Exemple #28
0
/* Fair Tree code called from the decay thread loop */
extern void fair_tree_decay(List jobs, time_t start)
{
	slurmctld_lock_t job_write_lock =
		{ NO_LOCK, WRITE_LOCK, READ_LOCK, READ_LOCK };
	assoc_mgr_lock_t locks =
		{ WRITE_LOCK, NO_LOCK, NO_LOCK, NO_LOCK, NO_LOCK };

	/* apply decayed usage */
	lock_slurmctld(job_write_lock);
	list_for_each(jobs, (ListForF) _ft_decay_apply_new_usage, &start);
	unlock_slurmctld(job_write_lock);

	/* calculate fs factor for associations */
	assoc_mgr_lock(&locks);
	_apply_priority_fs();
	assoc_mgr_unlock(&locks);

	/* assign job priorities */
	lock_slurmctld(job_write_lock);
	list_for_each(jobs, (ListForF) decay_apply_weighted_factors, &start);
	unlock_slurmctld(job_write_lock);
}
Exemple #29
0
int main()
{
  //example of using cross product
  using l1 =
      brigand::list<int, char, float, double, long, long long, unsigned int,
                    unsigned char, unsigned long, std::vector<int>,
                    std::vector<char>, std::vector<float>, std::vector<float>>;
  using l2 = brigand::list<int *, char *, float *, double *, long *>;

  using cp = cross_product<l1,l2>::type;

  list_for_each( printer{}, cp{});
  return 0;
}
mama_status
wombatThrottle_removeMessagesFromList (wombatThrottle throttle, wList list)
{
    gRemoveCount = 0;

    list_lock (self->mMsgQueue);
    list_for_each (list, removeMessagesFromListCb, self);
    mama_log (MAMA_LOG_LEVEL_FINE, "wombatThrottle_removeMessagesFromList (): "
              "%d Messages removed from queue list.",
              gRemoveCount);

    list_unlock (self->mMsgQueue);
    return MAMA_STATUS_OK;
}