Esempio n. 1
0
File: locks.c Progetto: BIRD/bird
static void
olock_free(resource *r)
{
  struct object_lock *q, *l = (struct object_lock *) r;
  node *n;

  DBG("olock: Freeing %p\n", l);
  switch (l->state)
    {
    case OLOCK_STATE_FREE:
      break;
    case OLOCK_STATE_LOCKED:
    case OLOCK_STATE_EVENT:
      rem_node(&l->n);
      n = HEAD(l->waiters);
      if (n->next)
	{
	  DBG("olock: -> %p becomes locked\n", n);
	  q = SKIP_BACK(struct object_lock, n, n);
	  rem_node(n);
	  add_tail_list(&q->waiters, &l->waiters);
	  q->state = OLOCK_STATE_EVENT;
	  add_head(&olock_list, n);
	  ev_schedule(olock_event);
	}
      break;
    case OLOCK_STATE_WAITING:
      rem_node(&l->n);
      break;
    default:
      ASSERT(0);
    }
Esempio n. 2
0
static void
proto_relink(struct proto *p)
{
  list *l = NULL;

  if (p->debug & D_STATES)
    {
      char *name = proto_state_name(p);
      if (name != p->last_state_name_announced)
	{
	  p->last_state_name_announced = name;
	  PD(p, "State changed to %s", proto_state_name(p));
	}
    }
  else
    p->last_state_name_announced = NULL;
  rem_node(&p->n);
  switch (p->core_state)
    {
    case FS_HUNGRY:
      l = &inactive_proto_list;
      break;
    case FS_FEEDING:
    case FS_HAPPY:
      l = &active_proto_list;
      break;
    case FS_FLUSHING:
      l = &flush_proto_list;
      break;
    default:
      ASSERT(0);
    }
  proto_enqueue(l, p);
}
Esempio n. 3
0
File: slab.c Progetto: yubo/bird
void sl_free(struct slab * s, void *oo)
{
    struct sl_obj *o = SKIP_BACK(struct sl_obj, data, oo);

    rem_node(&o->n);
    xfree(o);
}
Esempio n. 4
0
static void
proto_unlink_ahooks(struct proto *p)
{
  struct announce_hook *h;

  if (p->rt_notify)
    for(h=p->ahooks; h; h=h->next)
      rem_node(&h->n);
}
Esempio n. 5
0
inline void
ev_postpone(event *e)
{
  if (ev_active(e))
    {
      rem_node(&e->n);
      e->n.next = NULL;
    }
}
Esempio n. 6
0
int main(void)
{
  /* Declare YOUR variables here ! */
  BiTree mytree;
  int menu_choice;

  srand((unsigned int)time(NULL));

  if ((mytree = BITREEinit(my_destroy)) == NULL)
    {
      printf("\nFatal error - bailing out...\n!");
      BITREEdestroy(mytree);
      exit(-1);
    }
  
  /* Don't forget to set the compare callback..! */
  BITREEsetcompare(mytree, my_cmp);

  /* Initialize - and add nodes to the table... */
  create_nodes(mytree, NR_OF_ITEMS);
  
  do
    {
      menu_choice = menu(MAIN_MENU_ROW, 0, 4);

      switch (menu_choice)
        {
        case 1:
          ins_node(mytree);
          break;
        case 2:
          rem_node(mytree);
          break;
        case 3:
          search_node(mytree);
          break;
        case 4:
          my_clearscrn();
          printf("--- PRINT TREE ---\n");
          print_tree(mytree);
          prompt_and_pause("\n\n");
          break;
        default:
          final_status(mytree);
          break;
        }
    }
  while (menu_choice); 

  prompt_and_pause("\n\nLet's tidy up and destroy the tree..- Bye!");
  BITREEdestroy(mytree);
  
  return 0;
}
Esempio n. 7
0
File: io.c Progetto: yubo/bird
void
ev2_schedule(struct event *e)
{
  struct birdloop *loop = birdloop_current();

  if (loop->poll_active && EMPTY_LIST(loop->event_list))
    wakeup_kick(loop);

  if (e->n.next)
    rem_node(&e->n);

  add_tail(&loop->event_list, &e->n);
}
Esempio n. 8
0
_public_
int knot_request_free(mm_ctx_t *mm, struct knot_request *request)
{
	if (request->fd >= 0) {
		close(request->fd);
	}
	knot_pkt_free(&request->query);
	knot_pkt_free(&request->resp);

	rem_node(&request->node);
	mm_free(mm, request);

	return KNOT_EOK;
}
Esempio n. 9
0
void _close_wndo(Wndo *w)
{
Wscreen *ws;
int screen_wndo;
Boolean was_mouse;

	if(w == NULL)
		return;

	was_mouse = hide_mouse();
	ws = w->W_screen;
	screen_wndo = (&ws->wndo == w);
	/* restore screen behind window if not the screen window and its attached
	 * to the screen */

	if(!screen_wndo && w->W_node.next)
	{
		if(!(w->flags & WNDO_HIDDEN))
		{
			if(w->flags & WNDO_BACKDROP)
				pj_set_rast((Raster *)w, 0); /* clear the area left behind */
			else
				blit_behind(w,pj_blitrect); /* blit back and
										  * restore window behind */
		}

		if(w == icb.iowndo)
		{
			set_cursor(ws->cursor);
			set_procmouse(NULL);
			icb.iowndo = NULL;
		}
		rem_node(&(w->W_node));

		if(!(w->flags & WNDO_BACKDROP)) /* backdrops don't affect clips */
		{
			ws->wndo.rasts[w->W_rastid] = NULL; /* clear pointer for id */
			build_all_clips(ws,1);
			--ws->num_wins;
		}
	}
	pj_close_raster(&w->behind);
	pj_gentle_free(w->ydots);
	pj_gentle_free(w->vchanges);
	if(!screen_wndo)
		pj_free(w);
	if(was_mouse)
		show_mouse();
}
Esempio n. 10
0
int xfr_process_list(knot_pkt_t *pkt, xfr_put_cb process_item,
                     struct query_data *qdata)
{
	if (pkt == NULL || qdata == NULL || qdata->ext == NULL) {
		return KNOT_EINVAL;
	}

	int ret = KNOT_EOK;
	mm_ctx_t *mm = qdata->mm;
	struct xfr_proc *xfer = qdata->ext;

	zone_contents_t *zone = qdata->zone->contents;
	knot_rrset_t soa_rr = node_rrset(zone->apex, KNOT_RRTYPE_SOA);

	/* Prepend SOA on first packet. */
	if (xfer->npkts == 0) {
		ret = knot_pkt_put(pkt, 0, &soa_rr, KNOT_PF_NOTRUNC);
		if (ret != KNOT_EOK) {
			return ret;
		}
	}

	/* Process all items in the list. */
	while (!EMPTY_LIST(xfer->nodes)) {
		ptrnode_t *head = HEAD(xfer->nodes);
		ret = process_item(pkt, head->d, xfer);
		if (ret == KNOT_EOK) { /* Finished. */
			/* Complete change set. */
			rem_node((node_t *)head);
			mm_free(mm, head);
		} else { /* Packet full or other error. */
			break;
		}
	}

	/* Append SOA on last packet. */
	if (ret == KNOT_EOK) {
		ret = knot_pkt_put(pkt, 0, &soa_rr, KNOT_PF_NOTRUNC);
	}

	/* Update counters. */
	xfer->npkts  += 1;
	xfer->nbytes += pkt->size;

	return ret;
}
Esempio n. 11
0
File: cli.c Progetto: yubo/bird
void
cli_set_log_echo(struct cli *c, uint mask, uint size)
{
  if (c->ring_buf)
    {
      mb_free(c->ring_buf);
      c->ring_buf = c->ring_end = c->ring_read = c->ring_write = NULL;
      rem_node(&c->n);
    }
  c->log_mask = mask;
  if (mask && size)
    {
      c->ring_buf = mb_alloc(c->pool, size);
      c->ring_end = c->ring_buf + size;
      c->ring_read = c->ring_write = c->ring_buf;
      add_tail(&cli_log_hooks, &c->n);
      c->log_threshold = size / 8;
    }
  c->ring_overflow = 0;
}
Esempio n. 12
0
File: proto.c Progetto: tohojo/bird
static void
proto_relink(struct proto *p)
{
  list *l = NULL;

  switch (p->core_state)
    {
    case FS_HUNGRY:
      l = &inactive_proto_list;
      break;
    case FS_HAPPY:
      l = &active_proto_list;
      break;
    case FS_FLUSHING:
      l = &flush_proto_list;
      break;
    default:
      ASSERT(0);
    }

  rem_node(&p->n);
  add_tail(l, &p->n);
}
Esempio n. 13
0
File: lsack.c Progetto: nabeken/bird
void
ospf_lsack_send(struct ospf_neighbor *n, int queue)
{
  struct ospf_packet *op;
  struct ospf_lsack_packet *pk;
  u16 len, i = 0;
  struct ospf_lsa_header *h;
  struct lsah_n *no;
  struct ospf_iface *ifa = n->ifa;
  struct proto *p = &n->ifa->oa->po->proto;

  if (EMPTY_LIST(n->ackl[queue]))
    return;

  pk = (struct ospf_lsack_packet *) ifa->sk->tbuf;
  op = (struct ospf_packet *) ifa->sk->tbuf;

  ospf_pkt_fill_hdr(n->ifa, pk, LSACK_P);
  h = pk->lsh;

  while (!EMPTY_LIST(n->ackl[queue]))
  {
    no = (struct lsah_n *) HEAD(n->ackl[queue]);
    memcpy(h + i, &no->lsa, sizeof(struct ospf_lsa_header));
    DBG("Iter %u ID: %R, RT: %R, Type: %04x\n", i, ntohl((h + i)->id),
	ntohl((h + i)->rt), (h + i)->type);
    i++;
    rem_node(NODE no);
    mb_free(no);
    if ((i * sizeof(struct ospf_lsa_header) +
	 sizeof(struct ospf_lsack_packet)) > ospf_pkt_maxsize(n->ifa))
    {
      if (!EMPTY_LIST(n->ackl[queue]))
      {
	len =
	  sizeof(struct ospf_lsack_packet) +
	  i * sizeof(struct ospf_lsa_header);
	op->length = htons(len);
	DBG("Sending and continuing! Len=%u\n", len);

	OSPF_PACKET(ospf_dump_lsack, (struct ospf_lsack_packet *) ifa->sk->tbuf,
		    "LSACK packet sent via %s", ifa->iface->name);

	if (ifa->type == OSPF_IT_BCAST)
	{
	  if ((ifa->state == OSPF_IS_DR) || (ifa->state == OSPF_IS_BACKUP))
	    ospf_send_to(ifa, AllSPFRouters);
	  else
	    ospf_send_to(ifa, AllDRouters);
	}
	else
	{
	  if ((ifa->state == OSPF_IS_DR) || (ifa->state == OSPF_IS_BACKUP))
	    ospf_send_to_agt(ifa, NEIGHBOR_EXCHANGE);
	  else
	    ospf_send_to_bdr(ifa);
	}

	ospf_pkt_fill_hdr(n->ifa, pk, LSACK_P);
	i = 0;
      }
    }
  }

  len = sizeof(struct ospf_lsack_packet) + i * sizeof(struct ospf_lsa_header);
  op->length = htons(len);
  DBG("Sending! Len=%u\n", len);

  OSPF_PACKET(ospf_dump_lsack, (struct ospf_lsack_packet *) ifa->sk->tbuf,
	      "LSACK packet sent via %s", ifa->iface->name);

  if (ifa->type == OSPF_IT_BCAST)
  {
    if ((ifa->state == OSPF_IS_DR) || (ifa->state == OSPF_IS_BACKUP))
      ospf_send_to(ifa, AllSPFRouters);
    else
      ospf_send_to(ifa, AllDRouters);
  }
  else
    ospf_send_to_agt(ifa, NEIGHBOR_EXCHANGE);
}
Esempio n. 14
0
void rtb_del(struct mesh_rte* rte){
	
	rem_node(NODE rte);
}