checkin (refcounts)

Eddie Kohler eddietwo at cag.lcs.mit.edu
Tue Mar 2 10:40:02 EST 1999


I've checked in the packet refcounting story.

  /* REFCOUNTS: Factions do not need to refcount most packets. They must
     refcount packets that they squirrel away. So if a faction stores a copy
     of packet `p', it must call `p->use()' when storing the packet, and
     `p->unuse()' when releasing the packet. Furthermore, if it does not
     return the packet to the driver after releasing it, it should delete the
     packet if it is unused.

     Code examples:
     // storing a packet
     p->use();
     _stored_packet = p;

     // releasing a stored packet & returning it to the driver
     packet *p = _stored_packet;
     _stored_packet = 0;
     p->unuse();
     set_continuation(..., p);

     // releasing a stored packet & NOT returning it to the driver
     _stored_packet->unuse();
     if (!_stored_packet->used()) delete _stored_packet;
     _stored_packet = 0;
  */

Packet data, length, and the dst annotation are now methods:

class packet { // ...
	unsigned char *data() const;
	unsigned length() const;
	address *dst_anno() const;
	packet *set_dst_anno(address *); // may copy packet
};

Should `data' be immutable?

love,
ed



More information about the click mailing list