[FFmpeg-devel] [PATCH 1/4] TCP: factor the poll() call
Måns Rullgård
mans
Wed Feb 2 19:11:56 CET 2011
Nicolas George <nicolas.george at normalesup.org> writes:
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
> libavformat/tcp.c | 28 ++++++++++++++++++----------
> 1 files changed, 18 insertions(+), 10 deletions(-)
>
> diff --git a/libavformat/tcp.c b/libavformat/tcp.c
> index ac4e4b0..564d69f 100644
> --- a/libavformat/tcp.c
> +++ b/libavformat/tcp.c
> @@ -129,17 +129,26 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
> return ret;
> }
>
> +static int tcp_wait_fd(int fd, int write)
> +{
> + int ev = write ? POLLOUT : POLLIN;
Is there a reason you don't let the caller simply pass POLLIN or
POLLOUT directly?
> + struct pollfd p = { .fd = fd, .events = ev, .revents = 0 };
Just FYI, there is no need to initialise .revents explicitly. If any
member is initialised, the rest are implicitly initialised to zero.
There is no harm in doing it explicitly, of course.
> + int ret;
> +
> + ret = poll(&p, 1, 100);
> + return ret < 0 ? ff_neterrno() : !!(p.revents & ev);
> +}
> +
No further comments.
--
M?ns Rullg?rd
mans at mansr.com
More information about the ffmpeg-devel
mailing list