Skip to content
GitLab
Explore
Sign in
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
3b33ac7a
Commit
3b33ac7a
authored
9 years ago
by
Richard Mudgett
Browse files
Options
Downloads
Patches
Plain Diff
taskprocessor.c: Sort CLI "core show taskprocessors" output.
Change-Id: I71e7bf57c7b908c8b8c71f1816348ed7c5a5d51e
parent
d8bc3e0c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
main/taskprocessor.c
+59
-10
59 additions, 10 deletions
main/taskprocessor.c
with
59 additions
and
10 deletions
main/taskprocessor.c
+
59
−
10
View file @
3b33ac7a
...
@@ -413,6 +413,44 @@ static char *cli_tps_ping(struct ast_cli_entry *e, int cmd, struct ast_cli_args
...
@@ -413,6 +413,44 @@ static char *cli_tps_ping(struct ast_cli_entry *e, int cmd, struct ast_cli_args
return
CLI_SUCCESS
;
return
CLI_SUCCESS
;
}
}
/*!
* \internal
* \brief Taskprocessor ao2 container sort function.
* \since 13.8.0
*
* \param obj_left pointer to the (user-defined part) of an object.
* \param obj_right pointer to the (user-defined part) of an object.
* \param flags flags from ao2_callback()
* OBJ_SEARCH_OBJECT - if set, 'obj_right', is an object.
* OBJ_SEARCH_KEY - if set, 'obj_right', is a search key item that is not an object.
* OBJ_SEARCH_PARTIAL_KEY - if set, 'obj_right', is a partial search key item that is not an object.
*
* \retval <0 if obj_left < obj_right
* \retval =0 if obj_left == obj_right
* \retval >0 if obj_left > obj_right
*/
static
int
tps_sort_cb
(
const
void
*
obj_left
,
const
void
*
obj_right
,
int
flags
)
{
const
struct
ast_taskprocessor
*
tps_left
=
obj_left
;
const
struct
ast_taskprocessor
*
tps_right
=
obj_right
;
const
char
*
right_key
=
obj_right
;
int
cmp
;
switch
(
flags
&
OBJ_SEARCH_MASK
)
{
default:
case
OBJ_SEARCH_OBJECT
:
right_key
=
tps_right
->
name
;
/* Fall through */
case
OBJ_SEARCH_KEY
:
cmp
=
strcasecmp
(
tps_left
->
name
,
right_key
);
break
;
case
OBJ_SEARCH_PARTIAL_KEY
:
cmp
=
strncasecmp
(
tps_left
->
name
,
right_key
,
strlen
(
right_key
));
break
;
}
return
cmp
;
}
static
char
*
cli_tps_report
(
struct
ast_cli_entry
*
e
,
int
cmd
,
struct
ast_cli_args
*
a
)
static
char
*
cli_tps_report
(
struct
ast_cli_entry
*
e
,
int
cmd
,
struct
ast_cli_args
*
a
)
{
{
char
name
[
256
];
char
name
[
256
];
...
@@ -420,7 +458,8 @@ static char *cli_tps_report(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
...
@@ -420,7 +458,8 @@ static char *cli_tps_report(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
unsigned
long
qsize
;
unsigned
long
qsize
;
unsigned
long
maxqsize
;
unsigned
long
maxqsize
;
unsigned
long
processed
;
unsigned
long
processed
;
struct
ast_taskprocessor
*
p
;
struct
ao2_container
*
sorted_tps
;
struct
ast_taskprocessor
*
tps
;
struct
ao2_iterator
iter
;
struct
ao2_iterator
iter
;
#define FMT_HEADERS "%-45s %10s %10s %10s\n"
#define FMT_HEADERS "%-45s %10s %10s %10s\n"
#define FMT_FIELDS "%-45s %10lu %10lu %10lu\n"
#define FMT_FIELDS "%-45s %10lu %10lu %10lu\n"
...
@@ -436,28 +475,38 @@ static char *cli_tps_report(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
...
@@ -436,28 +475,38 @@ static char *cli_tps_report(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
return
NULL
;
return
NULL
;
}
}
if
(
a
->
argc
!=
e
->
args
)
if
(
a
->
argc
!=
e
->
args
)
{
return
CLI_SHOWUSAGE
;
return
CLI_SHOWUSAGE
;
}
sorted_tps
=
ao2_container_alloc_rbtree
(
AO2_ALLOC_OPT_LOCK_NOLOCK
,
0
,
tps_sort_cb
,
NULL
);
if
(
!
sorted_tps
||
ao2_container_dup
(
sorted_tps
,
tps_singletons
,
0
))
{
ao2_cleanup
(
sorted_tps
);
return
CLI_FAILURE
;
}
ast_cli
(
a
->
fd
,
"
\n
"
FMT_HEADERS
,
"Processor"
,
"Processed"
,
"In Queue"
,
"Max Depth"
);
ast_cli
(
a
->
fd
,
"
\n
"
FMT_HEADERS
,
"Processor"
,
"Processed"
,
"In Queue"
,
"Max Depth"
);
tcount
=
0
;
tcount
=
0
;
iter
=
ao2_iterator_init
(
tps_singletons
,
0
);
iter
=
ao2_iterator_init
(
sorted_tps
,
AO2_ITERATOR_UNLINK
);
while
((
p
=
ao2_iterator_next
(
&
iter
)))
{
while
((
tps
=
ao2_iterator_next
(
&
iter
)))
{
ast_copy_string
(
name
,
p
->
name
,
sizeof
(
name
));
ast_copy_string
(
name
,
tps
->
name
,
sizeof
(
name
));
qsize
=
p
->
tps_queue_size
;
qsize
=
tps
->
tps_queue_size
;
if
(
p
->
stats
)
{
if
(
tps
->
stats
)
{
maxqsize
=
p
->
stats
->
max_qsize
;
maxqsize
=
tps
->
stats
->
max_qsize
;
processed
=
p
->
stats
->
_tasks_processed_count
;
processed
=
tps
->
stats
->
_tasks_processed_count
;
}
else
{
}
else
{
maxqsize
=
0
;
maxqsize
=
0
;
processed
=
0
;
processed
=
0
;
}
}
ast_cli
(
a
->
fd
,
FMT_FIELDS
,
name
,
processed
,
qsize
,
maxqsize
);
ast_cli
(
a
->
fd
,
FMT_FIELDS
,
name
,
processed
,
qsize
,
maxqsize
);
ast_taskprocessor_unreference
(
p
);
ast_taskprocessor_unreference
(
tps
);
++
tcount
;
++
tcount
;
}
}
ao2_iterator_destroy
(
&
iter
);
ao2_iterator_destroy
(
&
iter
);
ast_cli
(
a
->
fd
,
"
\n
%d taskprocessors
\n\n
"
,
tcount
);
ast_cli
(
a
->
fd
,
"
\n
%d taskprocessors
\n\n
"
,
tcount
);
ao2_ref
(
sorted_tps
,
-
1
);
return
CLI_SUCCESS
;
return
CLI_SUCCESS
;
}
}
...
...
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