[Asterisk-code-review] DEBUG FD LEAKS: Add support for eventfd and timerfd create. (asterisk[master])
Corey Farrell
asteriskteam at digium.com
Wed Nov 8 01:47:21 CST 2017
Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/7115
Change subject: DEBUG_FD_LEAKS: Add support for eventfd and timerfd_create.
......................................................................
DEBUG_FD_LEAKS: Add support for eventfd and timerfd_create.
This causes eventfd and timerfd to be recognized by DEBUG_FD_LEAKS.
ASTERISK-27404
Change-Id: Id6848fe904ade2d34eb39d2a20bd6b223e1111fc
---
M include/asterisk.h
M main/astfd.c
2 files changed, 40 insertions(+), 0 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/15/7115/1
diff --git a/include/asterisk.h b/include/asterisk.h
index 899438b..a608c09 100644
--- a/include/asterisk.h
+++ b/include/asterisk.h
@@ -72,6 +72,16 @@
int __ast_fdleak_open(const char *file, int line, const char *func, const char *path, int flags, ...);
int __ast_fdleak_pipe(int *fds, const char *file, int line, const char *func);
int __ast_fdleak_socket(int domain, int type, int protocol, const char *file, int line, const char *func);
+#if defined(HAVE_EVENTFD)
+#include <sys/eventfd.h>
+#define eventfd(a,b) __ast_fdleak_eventfd(a,b, __FILE__,__LINE__,__PRETTY_FUNCTION__)
+int __ast_fdleak_eventfd(unsigned int initval, int flags, const char *file, int line, const char *func);
+#endif
+#if defined(HAVE_TIMERFD)
+#include <sys/timerfd.h>
+#define timerfd_create(a,b) __ast_fdleak_timerfd_create(a,b, __FILE__,__LINE__,__PRETTY_FUNCTION__)
+int __ast_fdleak_timerfd_create(int clockid, int flags, const char *file, int line, const char *func);
+#endif
int __ast_fdleak_close(int fd);
FILE *__ast_fdleak_fopen(const char *path, const char *mode, const char *file, int line, const char *func);
int __ast_fdleak_fclose(FILE *ptr);
diff --git a/main/astfd.c b/main/astfd.c
index 34cf7bb..cabaebb 100644
--- a/main/astfd.c
+++ b/main/astfd.c
@@ -147,6 +147,36 @@
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)
{
--
To view, visit https://gerrit.asterisk.org/7115
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id6848fe904ade2d34eb39d2a20bd6b223e1111fc
Gerrit-Change-Number: 7115
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171108/e6cc98de/attachment.html>
More information about the asterisk-code-review
mailing list