aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-12-22 17:19:05 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-12-22 17:19:05 +0000
commit00bba5642e9285bd209b83dfcea655b4910cd785 (patch)
treeb7c642fe2d86c7bfff53be5ad3e2174288ffb856 /include
parent76b42f9e4caff653e0dab5cd1a051bebf5acde93 (diff)
Merged revisions 166282 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r166282 | russell | 2008-12-22 11:09:36 -0600 (Mon, 22 Dec 2008) | 12 lines Introduce ast_careful_fwrite() and use in AMI to prevent partial writes. This patch introduces a function to do careful writes on a file stream which will handle timeouts and partial writes. It is currently used in AMI to address the issue that has been reported. However, there are probably a few other places where this could be used. (closes issue #13546) Reported by: srt Tested by: russell http://reviewboard.digium.com/r/104/ ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.1@166284 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/utils.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h
index 1c676b8ee..941b5e57a 100644
--- a/include/asterisk/utils.h
+++ b/include/asterisk/utils.h
@@ -326,6 +326,25 @@ int ast_wait_for_input(int fd, int ms);
*/
int ast_carefulwrite(int fd, char *s, int len, int timeoutms);
+/*!
+ * \brief Write data to a file stream with a timeout
+ *
+ * \param f the file stream to write to
+ * \param fd the file description to poll on to know when the file stream can
+ * be written to without blocking.
+ * \param s the buffer to write from
+ * \param len the number of bytes to write
+ * \param timeoutms The maximum amount of time to block in this function trying
+ * to write, specified in milliseconds.
+ *
+ * \note This function assumes that the associated file stream has been set up
+ * as non-blocking.
+ *
+ * \retval 0 success
+ * \retval -1 error
+ */
+int ast_careful_fwrite(FILE *f, int fd, const char *s, size_t len, int timeoutms);
+
/*
* Thread management support (should be moved to lock.h or a different header)
*/