Mercurial > libavformat.hg
comparison udp.c @ 4035:8c161751e4c7 libavformat
Get rid of MSG_DONTWAIT using a more standard way to use a socket
in a non blocked mode.
Patch by Jindrich Makovicka: makovick gmail
author | benoit |
---|---|
date | Mon, 17 Nov 2008 07:50:25 +0000 |
parents | 459dd8d5ad86 |
children | 7f9fb963926c |
comparison
equal
deleted
inserted
replaced
4034:608286f429a5 | 4035:8c161751e4c7 |
---|---|
435 * avoid losing data on OSes that set this too low by default. */ | 435 * avoid losing data on OSes that set this too low by default. */ |
436 tmp = s->buffer_size; | 436 tmp = s->buffer_size; |
437 if (setsockopt(udp_fd, SOL_SOCKET, SO_RCVBUF, &tmp, sizeof(tmp)) < 0) { | 437 if (setsockopt(udp_fd, SOL_SOCKET, SO_RCVBUF, &tmp, sizeof(tmp)) < 0) { |
438 av_log(NULL, AV_LOG_WARNING, "setsockopt(SO_RECVBUF): %s\n", strerror(errno)); | 438 av_log(NULL, AV_LOG_WARNING, "setsockopt(SO_RECVBUF): %s\n", strerror(errno)); |
439 } | 439 } |
440 /* make the socket non-blocking */ | |
441 ff_socket_nonblock(udp_fd, 1); | |
440 } | 442 } |
441 | 443 |
442 s->udp_fd = udp_fd; | 444 s->udp_fd = udp_fd; |
443 return 0; | 445 return 0; |
444 fail: | 446 fail: |
466 ret = select(s->udp_fd + 1, &rfds, NULL, NULL, &tv); | 468 ret = select(s->udp_fd + 1, &rfds, NULL, NULL, &tv); |
467 if (ret < 0) | 469 if (ret < 0) |
468 return AVERROR(EIO); | 470 return AVERROR(EIO); |
469 if (!(ret > 0 && FD_ISSET(s->udp_fd, &rfds))) | 471 if (!(ret > 0 && FD_ISSET(s->udp_fd, &rfds))) |
470 continue; | 472 continue; |
471 len = recv(s->udp_fd, buf, size, MSG_DONTWAIT); | 473 len = recv(s->udp_fd, buf, size, 0); |
472 if (len < 0) { | 474 if (len < 0) { |
473 if (ff_neterrno() != FF_NETERROR(EAGAIN) && | 475 if (ff_neterrno() != FF_NETERROR(EAGAIN) && |
474 ff_neterrno() != FF_NETERROR(EINTR)) | 476 ff_neterrno() != FF_NETERROR(EINTR)) |
475 return AVERROR(EIO); | 477 return AVERROR(EIO); |
476 } else { | 478 } else { |