Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
promise
OpenXG-RAN
Commits
185e6a4e
Commit
185e6a4e
authored
May 04, 2016
by
Cedric Roux
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
warn when memory usage of local tracer grows too much
parent
d4f5ab77
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
common/utils/T/tracer/forward.c
common/utils/T/tracer/forward.c
+21
-0
No files found.
common/utils/T/tracer/forward.c
View file @
185e6a4e
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
#include <unistd.h>
#include <unistd.h>
#include <pthread.h>
#include <pthread.h>
#include <string.h>
#include <string.h>
#include <stdint.h>
#include <inttypes.h>
typedef
struct
databuf
{
typedef
struct
databuf
{
char
*
d
;
char
*
d
;
...
@@ -20,6 +22,8 @@ typedef struct {
...
@@ -20,6 +22,8 @@ typedef struct {
pthread_mutex_t
datalock
;
pthread_mutex_t
datalock
;
pthread_cond_t
datacond
;
pthread_cond_t
datacond
;
databuf
*
volatile
head
,
*
tail
;
databuf
*
volatile
head
,
*
tail
;
uint64_t
memusage
;
uint64_t
last_warning_memusage
;
}
forward_data
;
}
forward_data
;
static
void
*
data_sender
(
void
*
_f
)
static
void
*
data_sender
(
void
*
_f
)
...
@@ -37,6 +41,7 @@ wait:
...
@@ -37,6 +41,7 @@ wait:
buf
=
cur
->
d
;
buf
=
cur
->
d
;
size
=
cur
->
l
;
size
=
cur
->
l
;
f
->
head
=
cur
->
next
;
f
->
head
=
cur
->
next
;
f
->
memusage
-=
size
;
if
(
f
->
head
==
NULL
)
f
->
tail
=
NULL
;
if
(
f
->
head
==
NULL
)
f
->
tail
=
NULL
;
if
(
pthread_mutex_unlock
(
&
f
->
datalock
))
abort
();
if
(
pthread_mutex_unlock
(
&
f
->
datalock
))
abort
();
free
(
cur
);
free
(
cur
);
...
@@ -122,6 +127,9 @@ void *forwarder(char *ip, int port)
...
@@ -122,6 +127,9 @@ void *forwarder(char *ip, int port)
f
->
sc
=
-
1
;
f
->
sc
=
-
1
;
f
->
head
=
f
->
tail
=
NULL
;
f
->
head
=
f
->
tail
=
NULL
;
f
->
memusage
=
0
;
f
->
last_warning_memusage
=
0
;
printf
(
"connecting to remote tracer %s:%d
\n
"
,
ip
,
port
);
printf
(
"connecting to remote tracer %s:%d
\n
"
,
ip
,
port
);
again:
again:
...
@@ -167,6 +175,19 @@ void forward(void *_forwarder, char *buf, int size)
...
@@ -167,6 +175,19 @@ void forward(void *_forwarder, char *buf, int size)
if
(
f
->
tail
!=
NULL
)
f
->
tail
->
next
=
new
;
if
(
f
->
tail
!=
NULL
)
f
->
tail
->
next
=
new
;
f
->
tail
=
new
;
f
->
tail
=
new
;
f
->
memusage
+=
size
+
4
;
/* warn every 100MB */
if
(
f
->
memusage
>
f
->
last_warning_memusage
&&
f
->
memusage
-
f
->
last_warning_memusage
>
100000000
)
{
f
->
last_warning_memusage
+=
100000000
;
printf
(
"WARNING: memory usage is over %"
PRIu64
"MB
\n
"
,
f
->
last_warning_memusage
/
1000000
);
}
else
if
(
f
->
memusage
<
f
->
last_warning_memusage
&&
f
->
last_warning_memusage
-
f
->
memusage
>
100000000
)
{
f
->
last_warning_memusage
=
(
f
->
memusage
/
100000000
)
*
100000000
;
}
if
(
pthread_cond_signal
(
&
f
->
datacond
))
abort
();
if
(
pthread_cond_signal
(
&
f
->
datacond
))
abort
();
if
(
pthread_mutex_unlock
(
&
f
->
datalock
))
abort
();
if
(
pthread_mutex_unlock
(
&
f
->
datalock
))
abort
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment