Skip to content

Commit 3e3a3c8

Browse files
TELECOM-11880: rest_client refactor to use curl_multi_socket_action
1 parent 6219d8d commit 3e3a3c8

File tree

8 files changed

+1164
-51
lines changed

8 files changed

+1164
-51
lines changed

modules/rest_client/rest_cb.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,23 @@ size_t header_func(char *ptr, size_t size, size_t nmemb, void *userdata)
109109
return len;
110110
}
111111

112+
int timer_cb(CURLM *multi_handle, long timeout_ms, void *cbp)
113+
{
114+
LM_DBG("multi_handle timer called %ld\n", timeout_ms);
115+
long *p = (long*) cbp;
116+
117+
*p = timeout_ms;
118+
119+
return 0;
120+
}
121+
122+
int prereq_callback(void *cbp,
123+
char *conn_primary_ip,
124+
char *conn_local_ip,
125+
int conn_primary_port,
126+
int conn_local_port)
127+
{
128+
enum curl_status *p = (enum curl_status*) cbp;
129+
*p = CURL_REQUEST_SENT;
130+
return 0;
131+
}

modules/rest_client/rest_cb.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#ifndef _REST_CB_H_
2626
#define _REST_CB_H_
2727

28+
#include <curl/curl.h>
29+
2830
#include "rest_client.h"
2931

3032
#include "../../str.h"
@@ -39,8 +41,14 @@
3941
#define MAX_CONTENT_TYPE_LEN 64
4042
#define MAX_HEADER_FIELD_LEN 1024 /* arbitrary */
4143

44+
enum curl_status {
45+
CURL_NONE=0, CURL_CONNECTED=1, CURL_REQUEST_SENDING=2, CURL_REQUEST_SENT=4, CURL_FINISHED=8, CURL_TIMEOUT=16, CURL_ERROR=32
46+
};
47+
4248
size_t write_func(char *ptr, size_t size, size_t nmemb, void *userdata);
4349
size_t header_func(char *ptr, size_t size, size_t nmemb, void *userdata);
50+
int timer_cb(CURLM *multi_handle, long timeout_ms, void *cbp);
51+
int prereq_callback(void *cbp, char *conn_primary_ip, char *conn_local_ip, int conn_primary_port, int conn_local_port);
4452

4553
#endif /* _REST_CB_H_ */
4654

0 commit comments

Comments
 (0)