Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
asterisk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Voice
asterisk
Commits
4181b6f3
Commit
4181b6f3
authored
7 years ago
by
Joshua Colp
Committed by
Gerrit Code Review
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge "DEBUG_FD_LEAKS: Add missing FD creators."
parents
4dac92b9
0bda39c6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/asterisk.h
+16
-0
16 additions, 0 deletions
include/asterisk.h
main/astfd.c
+59
-0
59 additions, 0 deletions
main/astfd.c
with
75 additions
and
0 deletions
include/asterisk.h
+
16
−
0
View file @
4181b6f3
...
...
@@ -59,7 +59,9 @@
#define open(a,...) __ast_fdleak_open(__FILE__,__LINE__,__PRETTY_FUNCTION__, a, __VA_ARGS__)
#define pipe(a) __ast_fdleak_pipe(a, __FILE__,__LINE__,__PRETTY_FUNCTION__)
#define socketpair(a,b,c,d) __ast_fdleak_socketpair(a, b, c, d, __FILE__,__LINE__,__PRETTY_FUNCTION__)
#define socket(a,b,c) __ast_fdleak_socket(a, b, c, __FILE__,__LINE__,__PRETTY_FUNCTION__)
#define accept(a,b,c) __ast_fdleak_accept(a, b, c, __FILE__,__LINE__,__PRETTY_FUNCTION__)
#define close(a) __ast_fdleak_close(a)
#define fopen(a,b) __ast_fdleak_fopen(a, b, __FILE__,__LINE__,__PRETTY_FUNCTION__)
#define fclose(a) __ast_fdleak_fclose(a)
...
...
@@ -71,7 +73,21 @@ extern "C" {
#endif
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_socketpair
(
int
domain
,
int
type
,
int
protocol
,
int
sv
[
2
],
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
);
int
__ast_fdleak_accept
(
int
socket
,
struct
sockaddr
*
address
,
socklen_t
*
address_len
,
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
);
...
...
This diff is collapsed.
Click to expand it.
main/astfd.c
+
59
−
0
View file @
4181b6f3
...
...
@@ -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
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment