diff options
author | Sean Bright <sean.bright@gmail.com> | 2017-12-07 10:52:39 -0500 |
---|---|---|
committer | Sean Bright <sean.bright@gmail.com> | 2017-12-08 13:28:04 -0600 |
commit | 2ffe52a116ad05d060cbedda93c48cf5a4415ca3 (patch) | |
tree | 9f8d99288f532ad213b8681e7616c26e8535df24 /res/res_http_websocket.c | |
parent | b0b28446c1e5f76c54b823bc3f4e2a5423c9c79b (diff) |
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
Diffstat (limited to 'res/res_http_websocket.c')
-rw-r--r-- | res/res_http_websocket.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/res/res_http_websocket.c b/res/res_http_websocket.c index c1f9a29d6..baaa40fd9 100644 --- a/res/res_http_websocket.c +++ b/res/res_http_websocket.c @@ -951,17 +951,11 @@ static struct ast_http_uri websocketuri = { /*! \brief Simple echo implementation which echoes received text and binary frames */ static void websocket_echo_callback(struct ast_websocket *session, struct ast_variable *parameters, struct ast_variable *headers) { - int flags, res; + int res; ast_debug(1, "Entering WebSocket echo loop\n"); - if ((flags = fcntl(ast_websocket_fd(session), F_GETFL)) == -1) { - goto end; - } - - flags |= O_NONBLOCK; - - if (fcntl(ast_websocket_fd(session), F_SETFL, flags) == -1) { + if (ast_fd_set_flags(ast_websocket_fd(session), O_NONBLOCK)) { goto end; } |