[asterisk-commits] rizzo: trunk r47242 - /trunk/main/utils.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Nov 7 01:34:27 MST 2006


Author: rizzo
Date: Tue Nov  7 02:34:26 2006
New Revision: 47242

URL: http://svn.digium.com/view/asterisk?rev=47242&view=rev
Log:
explain why ast_carefulwrite is written the way it is,
and also that it doesn't really work as claimed.


Modified:
    trunk/main/utils.c

Modified: trunk/main/utils.c
URL: http://svn.digium.com/view/asterisk/trunk/main/utils.c?rev=47242&r1=47241&r2=47242&view=diff
==============================================================================
--- trunk/main/utils.c (original)
+++ trunk/main/utils.c Tue Nov  7 02:34:26 2006
@@ -604,6 +604,21 @@
 	return poll(pfd, 1, ms);
 }
 
+/*!
+ * Try to write string, but wait no more than ms milliseconds before timing out.
+ *
+ * \note The code assumes that the file descriptor has NONBLOCK set,
+ * so there is only one system call made to do a write, unless we actually
+ * have a need to wait.  This way, we get better performance.
+ * If the descriptor is blocking, all assumptions on the guaranteed
+ * detail do not apply anymore.
+ * Also note that in the current implementation, the delay is per-write,
+ * so you still have no guarantees, anyways.
+ * Fortunately the routine is only used in a few places (cli.c, manager.c,
+ * res_agi.c) so it is reasonably easy to check how it behaves there.
+ *
+ * XXX We either need to fix the code, or fix the documentation.
+ */
 int ast_carefulwrite(int fd, char *s, int len, int timeoutms) 
 {
 	/* Try to write string, but wait no more than ms milliseconds



More information about the asterisk-commits mailing list