diff options
Diffstat (limited to 'main/utils.c')
-rw-r--r-- | main/utils.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/main/utils.c b/main/utils.c index 034203046..b4ecffd7e 100644 --- a/main/utils.c +++ b/main/utils.c @@ -2664,7 +2664,7 @@ void ast_set_default_eid(struct ast_eid *eid) unsigned char full_mac[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; s = socket(AF_INET, SOCK_STREAM, 0); - if (s <= 0) { + if (s < 0) { ast_log(LOG_WARNING, "Unable to open socket for seeding global EID. " "You will have to set it manually.\n"); return; @@ -2798,3 +2798,37 @@ int ast_compare_versions(const char *version1, const char *version2) } return extra[0] - extra[1]; } + +int __ast_fd_set_flags(int fd, int flags, enum ast_fd_flag_operation op, + const char *file, int lineno, const char *function) +{ + int f; + + f = fcntl(fd, F_GETFL); + if (f == -1) { + ast_log(__LOG_ERROR, file, lineno, function, + "Failed to get fcntl() flags for file descriptor: %s\n", strerror(errno)); + return -1; + } + + switch (op) { + case AST_FD_FLAG_SET: + f |= flags; + break; + case AST_FD_FLAG_CLEAR: + f &= ~flags; + break; + default: + ast_assert(0); + break; + } + + f = fcntl(fd, F_SETFL, f); + if (f == -1) { + ast_log(__LOG_ERROR, file, lineno, function, + "Failed to set fcntl() flags for file descriptor: %s\n", strerror(errno)); + return -1; + } + + return 0; +} |