Skip to content

Commit

Permalink
rest_client: Fix header list management with async requests
Browse files Browse the repository at this point in the history
The list of additional headers must not be freed too early, as libcurl
may still make use of it during each async resume callback.

Credits for reporting and helping with troubleshooting and testing
go to Agalya Ramachandran.

Fixes #1072

(cherry picked from commit 29363ca)

Conflicts:
	modules/rest_client/rest_methods.c

(cherry picked from commit 4ef4885)

Conflicts:
	modules/rest_client/rest_methods.c
  • Loading branch information
liviuchircu committed Mar 23, 2017
1 parent 2751168 commit 8c2ae30
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion modules/rest_client/rest_methods.c
Expand Up @@ -319,7 +319,7 @@ int start_async_http_req(struct sip_msg *msg, enum rest_client_method method,
goto error;

success:
clean_header_list(list);
async_parm->header_list = list;
async_parm->handle = handle;
async_parm->multi_list = multi_list;
return fd;
Expand Down Expand Up @@ -388,6 +388,8 @@ enum async_ret_code resume_async_http_req(int fd, struct sip_msg *msg, void *_pa
return 1;
}

curl_slist_free_all(param->header_list);

if (del_transfer(fd) != 0) {
LM_BUG("failed to delete fd %d", fd);
abort();
Expand Down
1 change: 1 addition & 0 deletions modules/rest_client/rest_methods.h
Expand Up @@ -57,6 +57,7 @@ typedef struct rest_async_param_ {
enum rest_client_method method;
OSS_CURLM *multi_list;
CURL *handle;
struct curl_slist *header_list;
str body;
str ctype;

Expand Down

0 comments on commit 8c2ae30

Please sign in to comment.