mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-22 12:52:33 +00:00
utils: Add convenience function for setting fd flags
There are many places in the code base where we ignore the return value of fcntl() when getting/setting file descriptior flags. This patch introduces a convenience function that allows setting or clearing file descriptor flags and will also log an error on failure for later analysis. Change-Id: I8b81901e1b1bd537ca632567cdb408931c6eded7
This commit is contained in:
@@ -922,7 +922,6 @@ static struct mohclass *_get_mohbyname(const char *name, int warn, int flags, co
|
||||
static struct mohdata *mohalloc(struct mohclass *cl)
|
||||
{
|
||||
struct mohdata *moh;
|
||||
long flags;
|
||||
|
||||
if (!(moh = ast_calloc(1, sizeof(*moh))))
|
||||
return NULL;
|
||||
@@ -934,10 +933,8 @@ static struct mohdata *mohalloc(struct mohclass *cl)
|
||||
}
|
||||
|
||||
/* Make entirely non-blocking */
|
||||
flags = fcntl(moh->pipe[0], F_GETFL);
|
||||
fcntl(moh->pipe[0], F_SETFL, flags | O_NONBLOCK);
|
||||
flags = fcntl(moh->pipe[1], F_GETFL);
|
||||
fcntl(moh->pipe[1], F_SETFL, flags | O_NONBLOCK);
|
||||
ast_fd_set_flags(moh->pipe[0], O_NONBLOCK);
|
||||
ast_fd_set_flags(moh->pipe[1], O_NONBLOCK);
|
||||
|
||||
moh->f.frametype = AST_FRAME_VOICE;
|
||||
moh->f.subclass.format = cl->format;
|
||||
|
Reference in New Issue
Block a user