WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
*/
/**
* Is this a failed operation?
*/
int failed;
-
};
/**
case OP_STATE_INIT:
GNUNET_assert (0);
break;
+
case OP_STATE_WAITING:
GNUNET_CONTAINER_DLL_remove (opq->wq_head, opq->wq_tail, entry);
break;
+
case OP_STATE_READY:
GNUNET_CONTAINER_DLL_remove (opq->rq_head, opq->rq_tail, entry);
break;
+
case OP_STATE_ACTIVE:
GNUNET_CONTAINER_DLL_remove (opq->aq_head, opq->aq_tail, entry);
break;
+
case OP_STATE_INACTIVE:
GNUNET_CONTAINER_DLL_remove (opq->nq_head, opq->nq_tail, entry);
break;
case OP_STATE_INIT:
GNUNET_assert (0);
break;
+
case OP_STATE_WAITING:
GNUNET_CONTAINER_DLL_insert_tail (opq->wq_head, opq->wq_tail, entry);
break;
+
case OP_STATE_READY:
GNUNET_CONTAINER_DLL_insert_tail (opq->rq_head, opq->rq_tail, entry);
break;
+
case OP_STATE_ACTIVE:
GNUNET_CONTAINER_DLL_insert_tail (opq->aq_head, opq->aq_tail, entry);
break;
+
case OP_STATE_INACTIVE:
GNUNET_CONTAINER_DLL_insert_tail (opq->nq_head, opq->nq_tail, entry);
break;
GNUNET_CONTAINER_DLL_remove (rq_head, rq_tail, op->rq_entry);
GNUNET_free (op->rq_entry);
op->rq_entry = NULL;
- if ( (NULL == rq_head) && (NULL != process_rq_task_id) )
+ if ((NULL == rq_head) && (NULL != process_rq_task_id))
{
GNUNET_SCHEDULER_cancel (process_rq_task_id);
process_rq_task_id = NULL;
static int
is_queue_empty (struct OperationQueue *opq)
{
- if ( (NULL != opq->wq_head)
- || (NULL != opq->rq_head)
- || (NULL != opq->aq_head)
- || (NULL != opq->nq_head) )
+ if ((NULL != opq->wq_head)
+ || (NULL != opq->rq_head)
+ || (NULL != opq->aq_head)
+ || (NULL != opq->nq_head))
return GNUNET_NO;
return GNUNET_YES;
}
for (n_ops = 0; n_ops < n_evict_entries;)
{
op = evict_entries[n_ops]->op;
- GNUNET_array_append (ops, n_ops, op); /* increments n-ops */
+ GNUNET_array_append (ops, n_ops, op); /* increments n-ops */
}
- ret:
+ret:
GNUNET_free_non_null (evict_entries);
if (NULL != ops_)
*ops_ = ops;
}
-
/**
* Checks for the readiness of an operation and schedules a operation start task
*
unsigned int cnt;
cleanup_tslots (queue);
- n = GNUNET_MIN (n ,fctx->max_active_bound);
- fctx->tslots_freeptr = GNUNET_malloc (n * sizeof (struct TimeSlot));
+ n = GNUNET_MIN (n, fctx->max_active_bound);
+ fctx->tslots_freeptr = GNUNET_malloc (n * sizeof(struct TimeSlot));
fctx->nfailed = 0;
for (cnt = 0; cnt < n; cnt++)
{
tslot = &fctx->tslots_freeptr[cnt];
tslot->queue = queue;
- GNUNET_CONTAINER_DLL_insert_tail (fctx->alloc_head, fctx->alloc_tail, tslot);
+ GNUNET_CONTAINER_DLL_insert_tail (fctx->alloc_head, fctx->alloc_tail,
+ tslot);
}
GNUNET_TESTBED_operation_queue_reset_max_active_ (queue, n);
}
(unsigned int) avg.rel_value_us,
&sd))
{
- adaptive_queue_set_max_active (queue, queue->max_active); /* no change */
+ adaptive_queue_set_max_active (queue, queue->max_active); /* no change */
return;
}
if (sd < 0)
sd = 0;
GNUNET_assert (0 <= sd);
- //GNUNET_TESTBED_SD_add_data_ (fctx->sd, (unsigned int) avg.rel_value_us);
+ // GNUNET_TESTBED_SD_add_data_ (fctx->sd, (unsigned int) avg.rel_value_us);
if (0 == sd)
{
adaptive_queue_set_max_active (queue, queue->max_active * 2);
fctx->nfailed++;
for (i = 0; i < op->nqueues; i++)
if (queue == op->queues[i])
- break;
+ break;
GNUNET_assert (i != op->nqueues);
op->queues[i]->overload += op->nres[i];
}
{
if (GNUNET_YES != is_queue_empty (queue))
{
- GNUNET_assert (0 == queue->expired); /* Are you calling twice on same queue? */
+ GNUNET_assert (0 == queue->expired); /* Are you calling twice on same queue? */
queue->expired = 1;
GNUNET_array_append (expired_opqs, n_expired_opqs, queue);
return;
queue->max_active = max_active;
queue->overload = 0;
- while ( (queue->active > queue->max_active)
- && (NULL != (entry = queue->rq_head)) )
+ while ((queue->active > queue->max_active)
+ && (NULL != (entry = queue->rq_head)))
defer (entry->op);
recheck_waiting (queue);
}
GNUNET_assert (OP_STATE_ACTIVE == op->state);
change_state (op, OP_STATE_INACTIVE);
nqueues = op->nqueues;
- ms = sizeof (struct OperationQueue *) * nqueues;
+ ms = sizeof(struct OperationQueue *) * nqueues;
queues = GNUNET_malloc (ms);
/* Cloning is needed as the operation be released by waiting operations and
hence its nqueues memory ptr will be freed */
void
GNUNET_TESTBED_operation_activate_ (struct GNUNET_TESTBED_Operation *op)
{
-
GNUNET_assert (OP_STATE_INACTIVE == op->state);
change_state (op, OP_STATE_ACTIVE);
}
case OP_STATE_INACTIVE:
GNUNET_assert (0);
break;
+
case OP_STATE_WAITING:
break;
+
case OP_STATE_ACTIVE:
case OP_STATE_READY:
GNUNET_assert (0 != opq->active);
unsigned int i;
int warn = 0;
- for (i=0; i < n_expired_opqs; i++)
+ for (i = 0; i < n_expired_opqs; i++)
{
queue = expired_opqs[i];
if (GNUNET_NO == is_queue_empty (queue))
if (warn)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Be disciplined. Some operations were not marked as done.\n");
-
}
+
+
/* end of testbed_api_operations.c */