- while((pdu = rpc->waitpdu) != NULL) {
- pdu->cb(rpc, RPC_STATUS_ERROR, error, pdu->private_data);
- SLIST_REMOVE(&rpc->waitpdu, pdu);
- rpc_free_pdu(rpc, pdu);
+ rpc->outqueue.tail = NULL;
+
+ for (i = 0; i < HASHES; i++) {
+ struct rpc_queue *q = &rpc->waitpdu[i];
+
+ while((pdu = q->head) != NULL) {
+ pdu->cb(rpc, RPC_STATUS_ERROR, error, pdu->private_data);
+ q->head = pdu->next;
+ rpc_free_pdu(rpc, pdu);
+ }
+ q->tail = NULL;
+ }
+}
+
+static void rpc_free_fragment(struct rpc_fragment *fragment)
+{
+ if (fragment->data != NULL) {
+ free(fragment->data);
+ }
+ free(fragment);
+}
+
+void rpc_free_all_fragments(struct rpc_context *rpc)
+{
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
+ while (rpc->fragments != NULL) {
+ struct rpc_fragment *fragment = rpc->fragments;
+
+ rpc->fragments = fragment->next;
+ rpc_free_fragment(fragment);