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
f94c56d3
Commit
f94c56d3
authored
7 years ago
by
Jenkins2
Committed by
Gerrit Code Review
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge "stasis_endpoints: Remove silly usage of RAII_VAR."
parents
a13578e7
175a9ef8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
main/stasis_endpoints.c
+25
-16
25 additions, 16 deletions
main/stasis_endpoints.c
with
25 additions
and
16 deletions
main/stasis_endpoints.c
+
25
−
16
View file @
f94c56d3
...
@@ -305,8 +305,8 @@ static void endpoint_blob_dtor(void *obj)
...
@@ -305,8 +305,8 @@ static void endpoint_blob_dtor(void *obj)
struct
stasis_message
*
ast_endpoint_blob_create
(
struct
ast_endpoint
*
endpoint
,
struct
stasis_message
*
ast_endpoint_blob_create
(
struct
ast_endpoint
*
endpoint
,
struct
stasis_message_type
*
type
,
struct
ast_json
*
blob
)
struct
stasis_message_type
*
type
,
struct
ast_json
*
blob
)
{
{
RAII_VAR
(
struct
ast_endpoint_blob
*
,
obj
,
NULL
,
ao2_cleanup
)
;
struct
ast_endpoint_blob
*
obj
;
RAII_VAR
(
struct
stasis_message
*
,
msg
,
NULL
,
ao2_cleanup
)
;
struct
stasis_message
*
msg
;
if
(
!
type
)
{
if
(
!
type
)
{
return
NULL
;
return
NULL
;
...
@@ -321,37 +321,40 @@ struct stasis_message *ast_endpoint_blob_create(struct ast_endpoint *endpoint,
...
@@ -321,37 +321,40 @@ struct stasis_message *ast_endpoint_blob_create(struct ast_endpoint *endpoint,
if
(
endpoint
)
{
if
(
endpoint
)
{
if
(
!
(
obj
->
snapshot
=
ast_endpoint_snapshot_create
(
endpoint
)))
{
if
(
!
(
obj
->
snapshot
=
ast_endpoint_snapshot_create
(
endpoint
)))
{
ao2_ref
(
obj
,
-
1
);
return
NULL
;
return
NULL
;
}
}
}
}
obj
->
blob
=
ast_json_ref
(
blob
);
obj
->
blob
=
ast_json_ref
(
blob
);
msg
=
stasis_message_create
(
type
,
obj
);
ao2_ref
(
obj
,
-
1
);
if
(
!
(
msg
=
stasis_message_create
(
type
,
obj
)))
{
return
NULL
;
}
ao2_ref
(
msg
,
+
1
);
return
msg
;
return
msg
;
}
}
void
ast_endpoint_blob_publish
(
struct
ast_endpoint
*
endpoint
,
struct
stasis_message_type
*
type
,
void
ast_endpoint_blob_publish
(
struct
ast_endpoint
*
endpoint
,
struct
stasis_message_type
*
type
,
struct
ast_json
*
blob
)
struct
ast_json
*
blob
)
{
{
RAII_VAR
(
struct
stasis_message
*
,
message
,
NULL
,
ao2_cleanup
);
struct
stasis_message
*
message
;
if
(
blob
)
{
message
=
ast_endpoint_blob_create
(
endpoint
,
type
,
blob
);
if
(
!
blob
)
{
return
;
}
}
message
=
ast_endpoint_blob_create
(
endpoint
,
type
,
blob
);
if
(
message
)
{
if
(
message
)
{
stasis_publish
(
ast_endpoint_topic
(
endpoint
),
message
);
stasis_publish
(
ast_endpoint_topic
(
endpoint
),
message
);
ao2_ref
(
message
,
-
1
);
}
}
}
}
struct
ast_endpoint_snapshot
*
ast_endpoint_latest_snapshot
(
const
char
*
tech
,
struct
ast_endpoint_snapshot
*
ast_endpoint_latest_snapshot
(
const
char
*
tech
,
const
char
*
name
)
const
char
*
name
)
{
{
RAII_VAR
(
char
*
,
id
,
NULL
,
ast_free
)
;
char
*
id
=
NULL
;
RAII_VAR
(
struct
stasis_message
*
,
msg
,
NULL
,
ao2_cleanup
)
;
struct
stasis_message
*
msg
;
struct
ast_endpoint_snapshot
*
snapshot
;
struct
ast_endpoint_snapshot
*
snapshot
;
if
(
ast_strlen_zero
(
name
))
{
if
(
ast_strlen_zero
(
name
))
{
...
@@ -364,8 +367,8 @@ struct ast_endpoint_snapshot *ast_endpoint_latest_snapshot(const char *tech,
...
@@ -364,8 +367,8 @@ struct ast_endpoint_snapshot *ast_endpoint_latest_snapshot(const char *tech,
}
}
ast_tech_to_upper
(
id
);
ast_tech_to_upper
(
id
);
msg
=
stasis_cache_get
(
ast_endpoint_cache
(),
msg
=
stasis_cache_get
(
ast_endpoint_cache
(),
ast_endpoint_snapshot_type
(),
id
);
ast_
endpoint_snapshot_type
(),
id
);
ast_
free
(
id
);
if
(
!
msg
)
{
if
(
!
msg
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -374,6 +377,8 @@ struct ast_endpoint_snapshot *ast_endpoint_latest_snapshot(const char *tech,
...
@@ -374,6 +377,8 @@ struct ast_endpoint_snapshot *ast_endpoint_latest_snapshot(const char *tech,
ast_assert
(
snapshot
!=
NULL
);
ast_assert
(
snapshot
!=
NULL
);
ao2_ref
(
snapshot
,
+
1
);
ao2_ref
(
snapshot
,
+
1
);
ao2_ref
(
msg
,
-
1
);
return
snapshot
;
return
snapshot
;
}
}
...
@@ -406,7 +411,7 @@ struct ast_json *ast_endpoint_snapshot_to_json(
...
@@ -406,7 +411,7 @@ struct ast_json *ast_endpoint_snapshot_to_json(
const
struct
ast_endpoint_snapshot
*
snapshot
,
const
struct
ast_endpoint_snapshot
*
snapshot
,
const
struct
stasis_message_sanitizer
*
sanitize
)
const
struct
stasis_message_sanitizer
*
sanitize
)
{
{
RAII_VAR
(
struct
ast_json
*
,
json
,
NULL
,
ast_json_unref
)
;
struct
ast_json
*
json
;
struct
ast_json
*
channel_array
;
struct
ast_json
*
channel_array
;
int
i
;
int
i
;
...
@@ -424,6 +429,8 @@ struct ast_json *ast_endpoint_snapshot_to_json(
...
@@ -424,6 +429,8 @@ struct ast_json *ast_endpoint_snapshot_to_json(
int
res
=
ast_json_object_set
(
json
,
"max_channels"
,
int
res
=
ast_json_object_set
(
json
,
"max_channels"
,
ast_json_integer_create
(
snapshot
->
max_channels
));
ast_json_integer_create
(
snapshot
->
max_channels
));
if
(
res
!=
0
)
{
if
(
res
!=
0
)
{
ast_json_unref
(
json
);
return
NULL
;
return
NULL
;
}
}
}
}
...
@@ -441,11 +448,13 @@ struct ast_json *ast_endpoint_snapshot_to_json(
...
@@ -441,11 +448,13 @@ struct ast_json *ast_endpoint_snapshot_to_json(
res
=
ast_json_array_append
(
channel_array
,
res
=
ast_json_array_append
(
channel_array
,
ast_json_string_create
(
snapshot
->
channel_ids
[
i
]));
ast_json_string_create
(
snapshot
->
channel_ids
[
i
]));
if
(
res
!=
0
)
{
if
(
res
!=
0
)
{
ast_json_unref
(
json
);
return
NULL
;
return
NULL
;
}
}
}
}
return
ast_json_ref
(
json
)
;
return
json
;
}
}
static
void
endpoints_stasis_cleanup
(
void
)
static
void
endpoints_stasis_cleanup
(
void
)
...
...
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