[PATCH] Introduce flags for non-blocking protocols
Hi. The recent discussion about EAGAIN has shown the need for a coherent handling of blocking vs. non-blocking operations. The attached patch introduces two flags, URL_FLAG_NONBLOCK and URL_FLAG_OPEN_NONBLOCK. The flags are currently unused anywhere, I propose them to open the discussion. If the principle is accepted, I intend to try to implement them at least for TCP and UDP. (Carl Eugen: you left the date and revision as XXX in your recent commit to APIchanges.) Regards, -- Nicolas George
Le tridi 23 niv?se, an CCXIX, Nicolas George a ?crit?:
+/** + * Do not block while opening/connecting the context. + * If this flag is set, the opening operation of the context will return + * immediately instead of blocking. + * If the operation is currently being processed by the system (e.g. + * establishing a connection on a slow network), url_connect returns + * AVERROR(EINPROGRESS), and the application is supposed to call url_connect + * again to check for completion. + * If the operation is not possible for any other reason (e.g. a device + * currently in use by another process), another error is returned. + * If this flag is not set, url_open/url_connect will never return + * AVERROR(EINPROGRESS). + * This flag is cleared from the flags field in URLContext once the + * connection has been established. + * Warning: non-blocking protocols is work-in-progress; this flag may be + * silently ignored. + */ +#define URL_FLAG_OPEN_NONBLOCK 8
After further thought, I's like to withdraw that part. Doing TCP handshake in background and not blocking endlessly on /dev/dsp are two completely different things; for example in ffmpeg we want the second but not the first. Thus, I amend my proposal: - URL_FLAG_NONBLOCK as proposed. - Network connects are always blocking, just as now, until someone makes a proposal for a good API to do them in background. It would require background DNS too. Good luck. - Device opens should always return EBUSY immediately and not block forever. Regards, -- Nicolas George
On Wed, Jan 12, 2011 at 03:38:08PM +0100, Nicolas George wrote:
Hi.
The recent discussion about EAGAIN has shown the need for a coherent handling of blocking vs. non-blocking operations.
The attached patch introduces two flags, URL_FLAG_NONBLOCK and URL_FLAG_OPEN_NONBLOCK. The flags are currently unused anywhere, I propose them to open the discussion. If the principle is accepted, I intend to try to implement them at least for TCP and UDP.
i agree that the first part of the patch looks good [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If you really think that XML is the answer, then you definitly missunderstood the question -- Attila Kinali
participants (2)
-
michaelni@gmx.at -
nicolas.george@normalesup.org