Packet pointer references unowned packet(0)
- 错误实例1:
Packet* data;
data = op_subq_pk_access (0, 0);
op_pk_send(data,OUT_STRM);
printf("send 1\n");
op_pk_send(data,OUT_STRM);
printf("send 2\n");
- 错误实例2:
Packet* data1;
Packet* data2;
data1 = op_subq_pk_access (0, 0);
op_pk_send(data1,OUT_STRM);
printf("send 1\n");
data2 = op_subq_pk_access (0, 0);
op_pk_send(data2,OUT_STRM);
printf("send 2\n");
A packet is an object that can be owned by one entity at any given time. A module gains ownership of a packet when it creates the packet (e.g., op_pk_create ()) or gets a packet (e.g., op_pk_get ()). When a packet is sent (e.g., op_pk_send ()) or destroyed (e.g., op_pk_destroy()), the module no longer owns the packet. If you attempt to manipulate a packet pointer that has already been sent or destroyed, you will obtain this error message.
Verify the following if you get this error:
- Are you attempting to manipulate a packet pointer for a packet that has already been sent, or already destroyed?
- Are you trying to use a packet pointer for a packet that has never been created or obtained using op_pk_get(), etc.?
For a full discussion on packet ownership, please refer to the help section Modeling Concepts -> Communication Mechanisms -> Packet-Based Communications -> General Properties of Packets.
lmz:
- 每一个包都有一个ID,尽管可以同时为一个包获取多个包指针,但是指向的都是同一个包。
- 对于已经不再拥有的包,不可以执行send和destroy操作,但是仍然可以执行acess和remove操作。
Packet* data1;
Packet* data2;
data1 = op_subq_pk_access (0, 0);
op_pk_send(data1,OUT_STRM);
printf("send 1\n");
data2 = op_subq_pk_access (0, 0);
printf("access ok\n");
op_subq_pk_remove (0, 0);
printf("remove ok\n");
op_pk_send(data2,OUT_STRM);
printf("send 2\n");