[FFmpeg-devel] [PATCH] avio: Check for FF_NETERROR(EAGAIN) in retry_transfer_wrapper
Martin Storsjö
martin
Tue Feb 22 18:42:30 CET 2011
On Tue, 22 Feb 2011, Reimar D?ffinger wrote:
> On Tue, Feb 22, 2011 at 03:41:20PM +0200, Martin Storsj? wrote:
> > On Tue, 22 Feb 2011, M?ns Rullg?rd wrote:
> >
> > > > diff --git a/libavformat/network.h b/libavformat/network.h
> > > > index d6aee93..c575975 100644
> > > > --- a/libavformat/network.h
> > > > +++ b/libavformat/network.h
> > > > @@ -27,9 +27,21 @@
> > > > #include <winsock2.h>
> > > > #include <ws2tcpip.h>
> > > >
> > > > -#define ff_neterrno() (-WSAGetLastError())
> > > > -#define FF_NETERROR(err) (-WSA##err)
> > > > -#define WSAEAGAIN WSAEWOULDBLOCK
> > > > +static inline int ff_neterrno() {
> > > > + int err = WSAGetLastError();
> > > > + switch (err) {
> > > > + case WSAEWOULDBLOCK:
> > > > + return AVERROR(EAGAIN);
> > > > + case WSAEINTR:
> > > > + return AVERROR(EINTR);
> > > > + }
> > > > + return -err;
> > > > +}
> > > > +
> > > > +#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
> > > > +#define ETIMEDOUT WSAETIMEDOUT
> > > > +#define ECONNREFUSED WSAECONNREFUSED
> > > > +#define EINPROGRESS WSAEINPROGRESS
> > >
> > > Are we certain these are never defined on Windows, or should they have
> > > some ifdefs? Also, a little vertical alignment wouldn't hurt.
> >
> > I guess you never can be certain, but they don't exist in neither mingw32
> > nor in Visual Studio. (mingw64 seems to have them defined, mapping to the
> > WSAE* codes just as we do, but within #if 0.) If they later turn out to be
> > defined in some platform update, we can always add ifdefs around them and
> > add mapping in ff_neterrno() for them.
>
> Hm, what about e.g. cross-compiling to MinGW on Cygwin?
> I guess someone wanting to compile on Cygwin but using winsock probably
> isn't much of a concern (and I have some doubts that's even possible
> without a lot of effort).
I'd guess if building for mingw from within cygwin, you won't get the
cygwin headers (containing all the unix errno.h stuff). I don't think it
would work otherwise, since the cygwin unix emulation and mingw32/windows
in itself have different versions of lots of headers.
Someone with more cygwin experience probably can comment on that.
// Martin
More information about the ffmpeg-devel
mailing list