mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-22 13:25:17 +00:00
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: https://origsvn.digium.com/svn/asterisk/trunk@166282 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -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)
|
||||
*/
|
||||
|
Reference in New Issue
Block a user