op_q_flush()

Abstract

Removes all packets from the surrounding queue.

Syntax

op_q_flush ()
Argument Type Description
no arguments

Return Type

void

No return value.

Example

/* determine the type of the interrupt */
if (op_intrpt_type () == OPC_INTRPT_REMOTE)
	{
	/* cold reboot: total loss of queued packets */
	if (op_intrpt_code () == COLD_REBOOT)
		{
		/* record the number of packets lost */
		num_lost_packets += op_q_stat (OPC_QSTAT_PKSIZE);

		/* flush the queue of its contents */
		op_q_flush ();
		}

	/* prioritize: loop through and sort all subqueues */
	else if (op_intrpt_code () == PRIORITIZE)
		{
		num_subqs = op_topo_child_count (op_id_self (), OPC_OBJTYPE_SUBQ);
		for (i = 0; i < num_subqs; i++)
			op_subq_sort (i);
		}
	}

Details

Flushing a queue is a performed by flushing each of its subqueues. A queue is initially empty, since all of its subqueues are empty. Packets are added to one or more subqueues within a queue via the KP op_subq_pk_insert(), and they are removed from subqueues via the KPs op_subq_pk_remove(), and op_subq_flush(), or from the queue as a whole via the KP op_q_flush().

Q package KPs must only be invoked within the context of a process running on a queue module (or from a function which is directly or indirectly invoked by a queue process); invoking them from a process running on a processor or from a pipeline stage model will cause an error.

Purpose

Provides a mechanism to remove all the packets in the surrounding queue. The packets are destroyed in the process, so this operation is only used when the packets in the queue can be dropped due to some dynamic condition. Typical applications for flushing a queue include node crashes or reboots, links or link interfaces going down, routing or other network management updates which invalidate currently buffered data, and the closing of a virtual circuit or session with no requirement to deliver currently buffered messages.

Errors

  • Program Abort: KP requires queue context.
  • Program Abort: Segmentation violation. (due to malformed packets or malformed structure fields residing within the packets of the queue)

Reference

  • Use the KP op_subq_flush() to flush a subqueue
  • Use the KP op_q_empty() to determine if the surrounding queue is empty of packets
  • Use the KP op_subq_empty() to determine if a subqueue is empty of packets
  • Use the KP op_subq_stat(), with the OPC_QSTAT_PKSIZE symbolic constant as an argument, to determine the number of packets contained in a subqueue
  • Use the KP op_subq_pk_remove() to remove a single packet from a subqueue, and obtain a pointer to it

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · Documentation compiled and provided by Beijing ZNetLink Technology Co., Ltd.

交流群 · QQ Group:OPNET/智网妙算网络仿真交流群(群号 486383494)

原文档 © 2017 Riverbed Technology · 本站为公益翻译,由 AI 辅助完成,请仔细甄别

Original documentation © 2017 Riverbed Technology. Community translation, AI-assisted. Contact: jiazequn@znetlink.com