diff options
author | Joshua Colp <jcolp@digium.com> | 2017-11-17 09:26:48 -0600 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2017-11-17 09:26:48 -0600 |
commit | 4181b6f3777655efa5f0523a8d2ab2b0e5e566fb (patch) | |
tree | 0dd58ec41c75d6d88a6ebe57bed809d20fdfd638 /main | |
parent | 4dac92b99a2becf88d493b8ae1a0cdb714766e23 (diff) | |
parent | 0bda39c668014b66ead1540b0c6699c41d3b3498 (diff) |
Merge "DEBUG_FD_LEAKS: Add missing FD creators."
Diffstat (limited to 'main')
-rw-r--r-- | main/astfd.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/main/astfd.c b/main/astfd.c index 34cf7bb6f..e29361e13 100644 --- a/main/astfd.c +++ b/main/astfd.c @@ -132,6 +132,19 @@ int __ast_fdleak_open(const char *file, int line, const char *func, const char * return res; } +#undef accept +int __ast_fdleak_accept(int socket, struct sockaddr *address, socklen_t *address_len, + const char *file, int line, const char *func) +{ + int res = accept(socket, address, address_len); + + if (res >= 0) { + STORE_COMMON(res, "accept", "{%d}", socket); + } + + return res; +} + #undef pipe int __ast_fdleak_pipe(int *fds, const char *file, int line, const char *func) { @@ -147,6 +160,52 @@ int __ast_fdleak_pipe(int *fds, const char *file, int line, const char *func) return 0; } +#undef socketpair +int __ast_fdleak_socketpair(int domain, int type, int protocol, int sv[2], + const char *file, int line, const char *func) +{ + int i, res = socketpair(domain, type, protocol, sv); + if (res) { + return res; + } + for (i = 0; i < 2; i++) { + if (sv[i] > -1 && sv[i] < ARRAY_LEN(fdleaks)) { + STORE_COMMON(sv[i], "socketpair", "{%d,%d}", sv[0], sv[1]); + } + } + return 0; +} + +#if defined(HAVE_EVENTFD) +#undef eventfd +#include <sys/eventfd.h> +int __ast_fdleak_eventfd(unsigned int initval, int flags, const char *file, int line, const char *func) +{ + int res = eventfd(initval, flags); + + if (res >= 0) { + STORE_COMMON(res, "eventfd", "{%d}", res); + } + + return res; +} +#endif + +#if defined(HAVE_TIMERFD) +#undef timerfd_create +#include <sys/timerfd.h> +int __ast_fdleak_timerfd_create(int clockid, int flags, const char *file, int line, const char *func) +{ + int res = timerfd_create(clockid, flags); + + if (res >= 0) { + STORE_COMMON(res, "timerfd_create", "{%d}", res); + } + + return res; +} +#endif + #undef socket int __ast_fdleak_socket(int domain, int type, int protocol, const char *file, int line, const char *func) { |