On Tue, 26 Apr 2011, Gil Pedersen wrote:
> Attached patch will allow ff_network_wait_fd() to return when the fd
> encounters an error or disconnection (HUP). Once returned, the next
> read/write call on the fd will result in an error and possibly a signal,
> which should provide better feedback than the current method of waiting
> indefinitely.
> diff --git a/libavformat/network.h b/libavformat/network.h
> index 84a8f53..37ef22e 100644
> --- a/libavformat/network.h
> +++ b/libavformat/network.h
> @@ -78,7 +78,7 @@ static inline int ff_network_wait_fd(int fd, int write)
> struct pollfd p = { .fd = fd, .events = ev, .revents = 0 };
> int ret;
> ret = poll(&p, 1, 100);
> - return ret < 0 ? ff_neterrno() : p.revents & ev ? 0 : AVERROR(EAGAIN);
> + return ret < 0 ? ff_neterrno() : p.revents & (ev | POLLERR | POLLHUP) ?
> 0 : AVERROR(EAGAIN);
> }
>
> static inline void ff_network_close(void)
Looks ok to me.
Further, I thought if we perhaps should return a better error code than
just 0 for those cases? But on the other hand, when returning 0, the
caller just proceeds to do the recv()/send(), which will return a proper
error code anyway. So I guess this is ok.
Btw, to make sure your patch is attributed correctly, git format-patch is
recommended :-)
// Martin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel