fc5da29b59945151b76357dba61337623cf5fc0c
[oweals/gnunet.git] / src / testbed / testbed_api_operations.c
1 /*
2       This file is part of GNUnet
3       (C) 2008--2012 Christian Grothoff (and other contributing authors)
4
5       GNUnet is free software; you can redistribute it and/or modify
6       it under the terms of the GNU General Public License as published
7       by the Free Software Foundation; either version 3, or (at your
8       option) any later version.
9
10       GNUnet is distributed in the hope that it will be useful, but
11       WITHOUT ANY WARRANTY; without even the implied warranty of
12       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13       General Public License for more details.
14
15       You should have received a copy of the GNU General Public License
16       along with GNUnet; see the file COPYING.  If not, write to the
17       Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18       Boston, MA 02111-1307, USA.
19  */
20
21 /**
22  * @file testbed/testbed_api_operations.c
23  * @brief functions to manage operation queues
24  * @author Christian Grothoff
25  */
26 #include "platform.h"
27 #include "testbed_api_operations.h"
28
29
30 /**
31  * An entry in the operation queue
32  */
33 struct QueueEntry
34 {
35   /**
36    * The next DLL pointer
37    */
38   struct QueueEntry *next;
39
40   /**
41    * The prev DLL pointer
42    */
43   struct QueueEntry *prev;
44
45   /**
46    * The operation this entry holds
47    */
48   struct GNUNET_TESTBED_Operation *op;
49
50   /**
51    * How many units of resources does the operation need
52    */
53   unsigned int nres;
54 };
55
56
57 /**
58  * Queue of operations where we can only support a certain
59  * number of concurrent operations of a particular type.
60  */
61 struct OperationQueue
62 {
63   /**
64    * DLL head for the wait queue.  Operations which are waiting for this
65    * operation queue are put here
66    */
67   struct QueueEntry *wq_head;
68
69   /**
70    * DLL tail for the wait queue.
71    */
72   struct QueueEntry *wq_tail;
73
74   /**
75    * DLL head for the ready queue.  Operations which are in this operation queue
76    * and are in ready state are put here
77    */
78   struct QueueEntry *rq_head;
79
80   /**
81    * DLL tail for the ready queue
82    */
83   struct QueueEntry *rq_tail;
84
85   /**
86    * DLL head for the active queue.  Operations which are in this operation
87    * queue and are currently active are put here
88    */
89   struct QueueEntry *aq_head;
90
91   /**
92    * DLL tail for the active queue.
93    */
94   struct QueueEntry *aq_tail;
95
96   /**
97    * DLL head for the inactive queue.  Operations which are inactive and can be
98    * evicted if the queues it holds are maxed out and another operation begins
99    * to wait on them.
100    */
101   struct QueueEntry *nq_head;
102
103   /**
104    * DLL tail for the inactive queue.
105    */
106   struct QueueEntry *nq_tail;
107
108   /**
109    * Number of operations that are currently active in this queue.
110    */
111   unsigned int active;
112
113   /**
114    * Max number of operations which can be active at any time in this queue
115    */
116   unsigned int max_active;
117
118 };
119
120
121 /**
122  * Operation state
123  */
124 enum OperationState
125 {
126   /**
127    * The operation is just created and is in initial state
128    */
129   OP_STATE_INIT,
130
131   /**
132    * The operation is currently waiting for resources
133    */
134   OP_STATE_WAITING,
135
136   /**
137    * The operation is ready to be started
138    */
139   OP_STATE_READY,
140
141   /**
142    * The operation has started
143    */
144   OP_STATE_STARTED,
145
146   /**
147    * The operation is inactive.  It still holds resources on the operation
148    * queues.  However, this operation will be evicted when another operation
149    * requires resources from the maxed out queues this operation is holding
150    * resources from.
151    */
152   OP_STATE_INACTIVE
153 };
154
155
156 /**
157  * An entry in the ready queue (implemented as DLL)
158  */
159 struct ReadyQueueEntry
160 {
161   /**
162    * next ptr for DLL
163    */
164   struct ReadyQueueEntry *next;
165   
166   /**
167    * prev ptr for DLL
168    */
169   struct ReadyQueueEntry *prev;
170
171   /**
172    * The operation associated with this entry
173    */
174   struct GNUNET_TESTBED_Operation *op;
175 };
176
177
178 /**
179  * Opaque handle to an abstract operation to be executed by the testing framework.
180  */
181 struct GNUNET_TESTBED_Operation
182 {
183   /**
184    * Function to call when we have the resources to begin the operation.
185    */
186   OperationStart start;
187
188   /**
189    * Function to call to clean up after the operation (which may or may
190    * not have been started yet).
191    */
192   OperationRelease release;
193
194   /**
195    * Closure for callbacks.
196    */
197   void *cb_cls;
198
199   /**
200    * Array of operation queues this Operation belongs to.
201    */
202   struct OperationQueue **queues;
203
204   /**
205    * Array of operation queue entries corresponding to this operation in
206    * operation queues for this operation
207    */
208   struct QueueEntry **qentries;
209
210   /**
211    * Array of number of resources an operation need from each queue. The numbers
212    * in this array should correspond to the queues array
213    */
214   unsigned int *nres;
215
216   /**
217    * Entry corresponding to this operation in ready queue.  Will be NULL if the
218    * operation is not marked as READY
219    */
220   struct ReadyQueueEntry *rq_entry;
221
222   /**
223    * Number of queues in the operation queues array
224    */
225   unsigned int nqueues;
226
227   /**
228    * The state of the operation
229    */
230   enum OperationState state;
231
232 };
233
234 /**
235  * DLL head for the ready queue
236  */
237 struct ReadyQueueEntry *rq_head;
238
239 /**
240  * DLL tail for the ready queue
241  */
242 struct ReadyQueueEntry *rq_tail;
243
244 /**
245  * The id of the task to process the ready queue
246  */
247 GNUNET_SCHEDULER_TaskIdentifier process_rq_task_id;
248
249 void
250 remove_queue_entry (struct GNUNET_TESTBED_Operation *op, unsigned int index)
251 {
252   struct OperationQueue *opq;
253   struct QueueEntry *entry;
254   
255   opq = op->queues[index];
256   entry = op->qentries[index];
257   switch (op->state)
258   {
259   case OP_STATE_INIT:
260     GNUNET_assert (0);
261     break;
262   case OP_STATE_WAITING:
263     GNUNET_CONTAINER_DLL_remove (opq->wq_head, opq->wq_tail, entry);
264     break;
265   case OP_STATE_READY:
266     GNUNET_CONTAINER_DLL_remove (opq->rq_head, opq->rq_tail, entry);
267     break;
268   case OP_STATE_STARTED:
269     GNUNET_CONTAINER_DLL_remove (opq->aq_head, opq->aq_tail, entry);
270     break;
271   case OP_STATE_INACTIVE:
272     GNUNET_CONTAINER_DLL_remove (opq->nq_head, opq->nq_tail, entry);
273     break;
274   }
275 }
276
277 void
278 change_state (struct GNUNET_TESTBED_Operation *op, enum OperationState state)
279 {
280   struct QueueEntry *entry;
281   struct OperationQueue *opq;
282   unsigned int cnt;
283   unsigned int s;
284   
285   GNUNET_assert (OP_STATE_INIT != state);
286   GNUNET_assert (NULL != op->queues);
287   GNUNET_assert (NULL != op->nres);
288   GNUNET_assert ((OP_STATE_INIT == op->state) || (NULL != op->qentries));
289   GNUNET_assert (op->state != state);
290   for (cnt = 0; cnt < op->nqueues; cnt++)
291   {
292     if (OP_STATE_INIT == op->state)
293     {
294       entry = GNUNET_malloc (sizeof (struct QueueEntry));
295       entry->op = op;
296       entry->nres = op->nres[cnt];
297       s = cnt;
298       GNUNET_array_append (op->qentries, s, entry);      
299     }
300     else
301     {
302       entry = op->qentries[cnt];
303       remove_queue_entry (op, cnt);
304     }
305     opq = op->queues[cnt];
306     switch (state)
307     {
308     case OP_STATE_INIT:
309       GNUNET_assert (0);
310       break;
311     case OP_STATE_WAITING:
312       GNUNET_CONTAINER_DLL_insert_tail (opq->wq_head, opq->wq_tail, entry);
313       break;
314     case OP_STATE_READY:
315       GNUNET_CONTAINER_DLL_insert_tail (opq->rq_head, opq->rq_tail, entry);
316       break;
317     case OP_STATE_STARTED:
318       GNUNET_CONTAINER_DLL_insert_tail (opq->aq_head, opq->aq_tail, entry);
319       break;
320     case OP_STATE_INACTIVE:
321       GNUNET_CONTAINER_DLL_insert_tail (opq->nq_head, opq->nq_tail, entry);
322       break;
323     }
324   }
325   op->state = state;
326 }
327
328
329 /**
330  * Removes an operation from the ready queue.  Also stops the 'process_rq_task'
331  * if the given operation is the last one in the queue.
332  *
333  * @param op the operation to be removed
334  */
335 static void
336 rq_remove (struct GNUNET_TESTBED_Operation *op)
337 {  
338   GNUNET_assert (NULL != op->rq_entry);
339   GNUNET_CONTAINER_DLL_remove (rq_head, rq_tail, op->rq_entry);
340   GNUNET_free (op->rq_entry);
341   op->rq_entry = NULL;
342   if ( (NULL == rq_head) && (GNUNET_SCHEDULER_NO_TASK != process_rq_task_id) )
343   {
344     GNUNET_SCHEDULER_cancel (process_rq_task_id);
345     process_rq_task_id = GNUNET_SCHEDULER_NO_TASK;
346   }
347 }
348
349
350 /**
351  * Processes the ready queue by calling the operation start callback of the
352  * operation at the head.  The operation is then removed from the queue.  The
353  * task is scheduled to run again immediately until no more operations are in
354  * the ready queue.
355  *
356  * @param cls NULL
357  * @param tc scheduler task context.  Not used.
358  */
359 static void
360 process_rq_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
361 {
362   struct GNUNET_TESTBED_Operation *op;
363
364   process_rq_task_id = GNUNET_SCHEDULER_NO_TASK;
365   GNUNET_assert (NULL != rq_head);
366   GNUNET_assert (NULL != (op = rq_head->op));
367   rq_remove (op);
368   if (NULL != rq_head)
369     process_rq_task_id = GNUNET_SCHEDULER_add_now (&process_rq_task, NULL);
370   change_state (op, OP_STATE_STARTED);
371   if (NULL != op->start)
372     op->start (op->cb_cls);  
373 }
374
375
376 /**
377  * Adds the operation to the ready queue and starts the 'process_rq_task'
378  *
379  * @param op the operation to be queued
380  */
381 static void
382 rq_add (struct GNUNET_TESTBED_Operation *op)
383 {
384   struct ReadyQueueEntry *rq_entry;
385
386   GNUNET_assert (NULL == op->rq_entry);
387   rq_entry = GNUNET_malloc (sizeof (struct ReadyQueueEntry));
388   rq_entry->op = op;
389   GNUNET_CONTAINER_DLL_insert_tail (rq_head, rq_tail, rq_entry);
390   op->rq_entry = rq_entry;
391   if (GNUNET_SCHEDULER_NO_TASK == process_rq_task_id)
392     process_rq_task_id = GNUNET_SCHEDULER_add_now (&process_rq_task, NULL);
393 }
394
395
396 static int
397 is_queue_empty (struct OperationQueue *opq)
398 {
399   if ( (NULL != opq->wq_head)
400        || (NULL != opq->rq_head)
401        || (NULL != opq->aq_head)
402        || (NULL != opq->nq_head) )
403     return GNUNET_NO;
404   return GNUNET_YES;
405 }
406
407
408 int
409 decide_capacity (struct OperationQueue *opq,
410                  struct QueueEntry *entry,
411                  struct GNUNET_TESTBED_Operation ***ops_,
412                  unsigned int *n_ops_)
413 {
414   struct QueueEntry **evict_entries;
415   struct GNUNET_TESTBED_Operation **ops;
416   struct GNUNET_TESTBED_Operation *op;
417   unsigned int n_ops;
418   unsigned int n_evict_entries;
419   unsigned int need;
420   int deficit;
421   int rval;
422
423   GNUNET_assert (NULL != (op = entry->op));
424   GNUNET_assert (0 < (need = entry->nres));
425   GNUNET_assert (opq->active <= opq->max_active);
426   ops = NULL;
427   n_ops = 0;
428   evict_entries = NULL;
429   n_evict_entries = 0;
430   rval = GNUNET_OK;
431   if ((opq->active + need) <= opq->max_active)
432     goto ret;
433   deficit = need - (opq->max_active - opq->active);
434   for (entry = opq->nq_head;
435        (0 < deficit) && (NULL != entry);
436        entry = entry->next)
437   {
438     GNUNET_array_append (evict_entries, n_evict_entries, entry);
439     deficit -= entry->nres;
440   }
441   if (0 < deficit)
442   {
443     rval = GNUNET_NO;
444     goto ret;
445   }
446   for (n_ops = 0; n_ops < n_evict_entries;)
447   {
448     op = evict_entries[n_ops]->op;
449     GNUNET_array_append (ops, n_ops, op); /* increments n-ops */
450   }
451
452  ret:
453   GNUNET_free_non_null (evict_entries);  
454   if (NULL != ops_) *ops_ = ops;
455   if (NULL != n_ops_) *n_ops_ = n_ops;
456   return rval;
457 }
458
459 /* FIXME: improve.. */
460 void
461 merge_ops (struct GNUNET_TESTBED_Operation ***old,
462            unsigned int *n_old,
463            struct GNUNET_TESTBED_Operation **new,
464            unsigned int n_new)
465 {
466   struct GNUNET_TESTBED_Operation **cur;
467   unsigned int i;
468   unsigned int j;
469   unsigned int n_cur;
470  
471   GNUNET_assert (NULL != old);
472   n_cur = *n_old;
473   cur = *old;
474   for (i = 0; i < n_new; i++)
475   {    
476     for (j = 0; j < *n_old; j++)
477     {
478       if (new[i] == cur[j])
479         break;
480     }
481     if (j < *n_old)
482       continue;
483     GNUNET_array_append (cur, n_cur, new[j]);
484   }
485   *old = cur;
486   *n_old = n_cur;
487 }
488            
489
490
491 /**
492  * Checks for the readiness of an operation and schedules a operation start task
493  *
494  * @param op the operation
495  */
496 static void
497 check_readiness (struct GNUNET_TESTBED_Operation *op)
498 {
499   struct GNUNET_TESTBED_Operation **evict_ops;
500   struct GNUNET_TESTBED_Operation **ops;
501   unsigned int n_ops;
502   unsigned int n_evict_ops;
503   unsigned int i;
504
505   GNUNET_assert (NULL == op->rq_entry);
506   GNUNET_assert (OP_STATE_WAITING == op->state);
507   evict_ops = NULL;
508   n_evict_ops = 0;
509   for (i = 0; i < op->nqueues; i++)
510   {
511     ops = NULL;
512     n_ops = 0;
513     if (GNUNET_NO == decide_capacity (op->queues[i], op->qentries[i],
514                                       &ops, &n_ops))
515     {
516       GNUNET_free_non_null (evict_ops);
517       return;
518     }
519     if (NULL == ops)
520       continue;
521     merge_ops (&evict_ops, &n_evict_ops, ops, n_ops);
522     GNUNET_free (ops);    
523   }
524   if (NULL != evict_ops)
525   {
526     for (i = 0; i < n_evict_ops; i++)
527       GNUNET_TESTBED_operation_release_ (evict_ops[i]);
528     GNUNET_free (evict_ops);
529     evict_ops = NULL;
530     /* Evicting the operations should schedule this operation */
531     GNUNET_assert (OP_STATE_READY == op->state);
532     return;
533   }
534   for (i = 0; i < op->nqueues; i++)
535     op->queues[i]->active += op->nres[i];
536   change_state (op, OP_STATE_READY);
537   rq_add (op);
538 }
539
540
541 /**
542  * Defers a ready to be executed operation back to waiting
543  *
544  * @param op the operation to defer
545  */
546 static void
547 defer (struct GNUNET_TESTBED_Operation *op)
548 {
549   unsigned int i;
550
551   GNUNET_assert (OP_STATE_READY == op->state);
552   rq_remove (op);
553   for (i = 0; i < op->nqueues; i++)
554     op->queues[i]->active--;
555   change_state (op, OP_STATE_WAITING);
556 }
557
558
559 /**
560  * Create an 'operation' to be performed.
561  *
562  * @param cls closure for the callbacks
563  * @param start function to call to start the operation
564  * @param release function to call to close down the operation
565  * @return handle to the operation
566  */
567 struct GNUNET_TESTBED_Operation *
568 GNUNET_TESTBED_operation_create_ (void *cls, OperationStart start,
569                                   OperationRelease release)
570 {
571   struct GNUNET_TESTBED_Operation *op;
572
573   op = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Operation));
574   op->start = start;
575   op->state = OP_STATE_INIT;
576   op->release = release;
577   op->cb_cls = cls;
578   return op;
579 }
580
581
582 /**
583  * Create an operation queue.
584  *
585  * @param max_active maximum number of operations in this
586  *        queue that can be active in parallel at the same time
587  * @return handle to the queue
588  */
589 struct OperationQueue *
590 GNUNET_TESTBED_operation_queue_create_ (unsigned int max_active)
591 {
592   struct OperationQueue *queue;
593
594   queue = GNUNET_malloc (sizeof (struct OperationQueue));
595   queue->max_active = max_active;
596   return queue;
597 }
598
599
600 /**
601  * Destroy an operation queue.  The queue MUST be empty
602  * at this time.
603  *
604  * @param queue queue to destroy
605  */
606 void
607 GNUNET_TESTBED_operation_queue_destroy_ (struct OperationQueue *queue)
608 {
609   GNUNET_break (GNUNET_YES == is_queue_empty (queue));
610   GNUNET_free (queue);
611 }
612
613
614 /**
615  * Destroys the operation queue if it is empty.  If not empty return GNUNET_NO.
616  *
617  * @param queue the queue to destroy if empty
618  * @return GNUNET_YES if the queue is destroyed.  GNUNET_NO if not (because it
619  *           is not empty)
620  */
621 int
622 GNUNET_TESTBED_operation_queue_destroy_empty_ (struct OperationQueue *queue)
623 {
624   if (GNUNET_NO == is_queue_empty (queue))
625     return GNUNET_NO;
626   GNUNET_TESTBED_operation_queue_destroy_ (queue);
627   return GNUNET_YES;
628 }
629
630
631 void
632 recheck_waiting (struct OperationQueue *opq)
633 {
634   struct QueueEntry *entry;
635   struct QueueEntry *entry2;
636
637   entry = opq->wq_head;
638   while ( (NULL != entry) && (opq->active < opq->max_active) )
639   {
640     entry2 = entry->next;
641     check_readiness (entry->op);
642     entry = entry2;
643   }
644 }
645
646
647 /**
648  * Function to reset the maximum number of operations in the given queue. If
649  * max_active is lesser than the number of currently active operations, the
650  * active operations are not stopped immediately.
651  *
652  * @param queue the operation queue which has to be modified
653  * @param max_active the new maximum number of active operations
654  */
655 void
656 GNUNET_TESTBED_operation_queue_reset_max_active_ (struct OperationQueue *queue,
657                                                   unsigned int max_active)
658 {
659   struct QueueEntry *entry;
660
661   queue->max_active = max_active;
662   while ( (queue->active > queue->max_active)
663           && (NULL != (entry = queue->rq_head)) )
664     defer (entry->op);
665   recheck_waiting (queue);
666 }
667
668
669 /**
670  * Add an operation to a queue.  An operation can be in multiple queues at
671  * once. Once the operation is inserted into all the queues
672  * GNUNET_TESTBED_operation_begin_wait_() has to be called to actually start
673  * waiting for the operation to become active.
674  *
675  * @param queue queue to add the operation to
676  * @param op operation to add to the queue
677  * @param nres the number of units of the resources of queue needed by the
678  *          operation. Should be greater than 0.
679  */
680 void
681 GNUNET_TESTBED_operation_queue_insert2_ (struct OperationQueue *queue,
682                                          struct GNUNET_TESTBED_Operation *op,
683                                          unsigned int nres)
684 {
685   unsigned int qsize;
686
687   GNUNET_assert (0 < nres);
688   qsize = op->nqueues;
689   GNUNET_array_append (op->queues, op->nqueues, queue);
690   GNUNET_array_append (op->nres, qsize, nres);
691   GNUNET_assert (qsize == op->nqueues);
692 }
693
694
695 /**
696  * Add an operation to a queue.  An operation can be in multiple queues at
697  * once. Once the operation is inserted into all the queues
698  * GNUNET_TESTBED_operation_begin_wait_() has to be called to actually start
699  * waiting for the operation to become active. The operation is assumed to take
700  * 1 queue resource. Use GNUNET_TESTBED_operation_queue_insert2_() if it
701  * requires more than 1
702  *
703  * @param queue queue to add the operation to
704  * @param op operation to add to the queue
705  */
706 void
707 GNUNET_TESTBED_operation_queue_insert_ (struct OperationQueue *queue,
708                                         struct GNUNET_TESTBED_Operation *op)
709 {
710   return GNUNET_TESTBED_operation_queue_insert2_ (queue, op, 1);
711 }
712
713
714 /**
715  * Marks the given operation as waiting on the queues.  Once all queues permit
716  * the operation to become active, the operation will be activated.  The actual
717  * activation will occur in a separate task (thus allowing multiple queue
718  * insertions to be made without having the first one instantly trigger the
719  * operation if the first queue has sufficient resources).
720  *
721  * @param op the operation to marks as waiting
722  */
723 void
724 GNUNET_TESTBED_operation_begin_wait_ (struct GNUNET_TESTBED_Operation *op)
725 {
726   GNUNET_assert (NULL == op->rq_entry);
727   change_state (op, OP_STATE_WAITING);
728   check_readiness (op);
729 }
730
731
732 /**
733  * Marks an active operation as inactive - the operation will be kept in a
734  * ready-to-be-released state and continues to hold resources until another
735  * operation contents for them.
736  *
737  * @param op the operation to be marked as inactive.  The operation start
738  *          callback should have been called before for this operation to mark
739  *          it as inactive.
740  */
741 void
742 GNUNET_TESTBED_operation_inactivate_ (struct GNUNET_TESTBED_Operation *op)
743 {
744   GNUNET_assert (OP_STATE_STARTED == op->state);
745   change_state (op, OP_STATE_INACTIVE);
746 }
747
748
749 /**
750  * Marks and inactive operation as active.  This fuction should be called to
751  * ensure that the oprelease callback will not be called until it is either
752  * marked as inactive or released.
753  *
754  * @param op the operation to be marked as active
755  */
756 void
757 GNUNET_TESTBED_operation_activate_ (struct GNUNET_TESTBED_Operation *op)
758 {
759   GNUNET_assert (OP_STATE_INACTIVE == op->state);
760   change_state (op, OP_STATE_STARTED);
761 }
762
763
764 /**
765  * An operation is 'done' (was cancelled or finished); remove
766  * it from the queues and release associated resources.
767  *
768  * @param op operation that finished
769  */
770 void
771 GNUNET_TESTBED_operation_release_ (struct GNUNET_TESTBED_Operation *op)
772 {
773   struct QueueEntry *entry;  
774   struct OperationQueue *opq;
775   unsigned int i;
776
777   if (OP_STATE_INIT == op->state)
778   {
779     GNUNET_free (op);
780     return;
781   }
782   if (OP_STATE_READY == op->state)
783     rq_remove (op);
784   if (OP_STATE_INACTIVE == op->state) /* Activate the operation if inactive */
785     GNUNET_TESTBED_operation_activate_ (op);
786   GNUNET_assert (NULL != op->queues);
787   GNUNET_assert (NULL != op->qentries);
788   for (i = 0; i < op->nqueues; i++)
789   {
790     entry = op->qentries[i];
791     remove_queue_entry (op, i);
792     opq = op->queues[i];
793     switch (op->state)
794     {      
795     case OP_STATE_INIT:
796     case OP_STATE_INACTIVE:
797       GNUNET_assert (0);
798       break;
799     case OP_STATE_WAITING:      
800       break;
801     case OP_STATE_READY:
802     case OP_STATE_STARTED:
803       GNUNET_assert (0 != opq->active);
804       GNUNET_assert (opq->active >= entry->nres);
805       opq->active -= entry->nres;
806       recheck_waiting (opq);
807       break;
808     }    
809     GNUNET_free (entry);
810   }
811   GNUNET_free_non_null (op->qentries);
812   GNUNET_free (op->queues);
813   GNUNET_free (op->nres);
814   if (NULL != op->release)
815     op->release (op->cb_cls);
816   GNUNET_free (op);
817 }
818
819
820 /* end of testbed_api_operations.c */