Browse Source

MT#56447 add ng_buffer_auto_release

Auto-cleanup wrapper for struct ng_buffer

Change-Id: I4aab4efb9b10d6380b0ef9f3f854130cee03d792
pull/1642/head
Richard Fuchs 3 years ago
parent
commit
066ecf0901
2 changed files with 5 additions and 2 deletions
  1. +1
    -2
      daemon/control_ng.c
  2. +4
    -0
      include/control_ng.h

+ 1
- 2
daemon/control_ng.c View File

@ -142,7 +142,7 @@ struct ng_buffer *ng_buffer_new(struct obj *ref) {
int control_ng_process(str *buf, const endpoint_t *sin, char *addr,
void (*cb)(str *, str *, const endpoint_t *, void *), void *p1, struct obj *ref)
{
struct ng_buffer *ngbuf;
AUTO_CLEANUP(struct ng_buffer *ngbuf, ng_buffer_auto_release) = NULL;
bencode_item_t *dict, *resp;
str cmd = STR_NULL, cookie, data, reply, *to_send, callid;
const char *errstr, *resultstr;
@ -408,7 +408,6 @@ send_only:
goto out;
out:
ng_buffer_release(ngbuf);
release_closed_sockets();
log_info_pop_until(&callid);
return funcret;


+ 4
- 0
include/control_ng.h View File

@ -81,6 +81,10 @@ struct ng_buffer *ng_buffer_new(struct obj *ref);
INLINE void ng_buffer_release(struct ng_buffer *ngbuf) {
obj_put(ngbuf);
}
INLINE void ng_buffer_auto_release(struct ng_buffer **ngbuf) {
if (*ngbuf)
ng_buffer_release(*ngbuf);
}
extern mutex_t rtpe_cngs_lock;
extern GHashTable *rtpe_cngs_hash;


Loading…
Cancel
Save