/* for all pending requests */
list_for_every_entry_safe(&hwrng_req_list, ctx, temp, struct hwrng_chan_ctx,
node) { if (ctx->send_blocked) continue; /* cant service it rignt now */
size_t len = ctx->req_size;
if (len > MAX_HWRNG_MSG_SIZE)
len = MAX_HWRNG_MSG_SIZE;
/* get rng data */
hwrng_dev_get_rng_data(rng_data, len);
/* send reply */ int rc = tipc_send_single_buf(ctx->chan, rng_data, len); if (rc < 0) { if (rc == ERR_NOT_ENOUGH_BUFFER) { /* mark it as send_blocked */
ctx->send_blocked = true;
} else { /* just close HWRNG request channel */
TLOGE("failed (%d) to send_reply\n", rc);
hwrng_close_chan(ctx);
} continue;
}
ctx->req_size -= len;
if (ctx->req_size == 0) { /* remove it from pending list */
list_delete(&ctx->node);
} else {
need_more = true;
}
}
/* read request */
rc = tipc_recv_single_buf(ctx->chan, &req, sizeof(req)); if (rc != sizeof(req)) {
TLOGE("failed (%d) to receive msg for chan %d\n", rc, ctx->chan); return rc;
}
/* check if we already have request in progress */ if (list_in_list(&ctx->node)) { /* extend it */
ctx->req_size += req.len;
} else { /* queue it */
ctx->req_size = req.len;
list_add_tail(&hwrng_req_list, &ctx->node);
}
if (ev->event & IPC_HANDLE_POLL_READY) {
handle_t chan;
/* incoming connection: accept it */ int rc = accept(ev->handle, &peer_uuid); if (rc < 0) {
TLOGE("failed (%d) to accept on port %d\n", rc, ev->handle); return;
}
chan = (handle_t)rc;
/* allocate state */ struct hwrng_chan_ctx* ctx = calloc(1, sizeof(*ctx)); if (!ctx) {
TLOGE("failed to alloc state for chan %d\n", chan);
close(chan); return;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.