Send should block as well and if there were no previous send request
poll would deadlock.
int out_packet_tx(struct out_ctx *ctx, struct can_frame *cf)
{
volatile struct tpacket2_hdr *hdr = ctx->ptr + ctx->current*FRAME_SIZE;
int out_packet_tx(struct out_ctx *ctx, struct can_frame *cf)
{
volatile struct tpacket2_hdr *hdr = ctx->ptr + ctx->current*FRAME_SIZE;
if (ctx->from_in == NOP)
return 0;
if (ctx->from_in == NOP)
return 0;
while (hdr->tp_status != TP_STATUS_AVAILABLE) {
while (hdr->tp_status != TP_STATUS_AVAILABLE) {
- struct pollfd pfd = {.fd = ctx->s, .revents = 0,
- .events = POLLIN|POLLRDNORM|POLLERR };
- ret = CHECK(poll(&pfd, 1, -1));
+ CHECK(send(ctx->s, NULL, 0, 0));
//struct sockaddr_ll *addr = (void*)hdr + TPACKET_HDRLEN - sizeof(struct sockaddr_ll);
struct can_frame *cf_mmap = (void*)hdr + TPACKET_HDRLEN - sizeof(struct sockaddr_ll);
*cf_mmap = *cf;
//struct sockaddr_ll *addr = (void*)hdr + TPACKET_HDRLEN - sizeof(struct sockaddr_ll);
struct can_frame *cf_mmap = (void*)hdr + TPACKET_HDRLEN - sizeof(struct sockaddr_ll);
*cf_mmap = *cf;
ctx->current = (ctx->current + 1) % FRAME_NR;
if (ctx->from_in == SEND){
ctx->current = (ctx->current + 1) % FRAME_NR;
if (ctx->from_in == SEND){
- ret = CHECK(send(ctx->s, NULL, 0, 0));
+ CHECK(send(ctx->s, NULL, 0, 0));