From: Michal Sojka Date: Tue, 14 Jan 2014 10:48:17 +0000 (+0100) Subject: ugw: Use send() instead of poll() in mmap()-based TX X-Git-Tag: fix-allnoconfig~77 X-Git-Url: http://rtime.felk.cvut.cz/gitweb/can-benchmark.git/commitdiff_plain/f5d5a2c6d0d48d295be18b9f5bfdade560eec941?ds=sidebyside ugw: Use send() instead of poll() in mmap()-based TX Send should block as well and if there were no previous send request poll would deadlock. --- diff --git a/ugw/ugw.c b/ugw/ugw.c index 0aefe7e..e2c04ef 100644 --- a/ugw/ugw.c +++ b/ugw/ugw.c @@ -233,18 +233,14 @@ void init_write(struct out_ctx *ctx) int out_packet_tx(struct out_ctx *ctx, struct can_frame *cf) { volatile struct tpacket2_hdr *hdr = ctx->ptr + ctx->current*FRAME_SIZE; - int ret = -1; if (ctx->from_in == NOP) return 0; - 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)); } - (void)ret; + //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; @@ -253,7 +249,7 @@ int out_packet_tx(struct out_ctx *ctx, struct can_frame *cf) 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)); return 0; } return 0;