diff --git a/main/utils.c b/main/utils.c index 5c08f13729e68269f67003d2d2332a682baccaa4..f930f74c6ec24a9bb60a42c36df74e11494e93aa 100644 --- a/main/utils.c +++ b/main/utils.c @@ -604,6 +604,21 @@ int ast_wait_for_input(int fd, int ms) 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