Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
puzza007 committed Sep 20, 2019
1 parent 5fe43cb commit a157b49
Show file tree
Hide file tree
Showing 3 changed files with 187 additions and 131 deletions.
4 changes: 2 additions & 2 deletions c_src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ else ifeq ($(UNAME_SYS), Linux)
LDLIBS += -L /usr/local/lib
endif

CFLAGS += -fPIC -I $(ERTS_INCLUDE_DIR) -I $(ERL_INTERFACE_INCLUDE_DIR)
CFLAGS += -fPIC -I $(ERTS_INCLUDE_DIR) -I $(ERL_INTERFACE_INCLUDE_DIR) -I /tmp/curl/include
CXXFLAGS += -fPIC -I $(ERTS_INCLUDE_DIR) -I $(ERL_INTERFACE_INCLUDE_DIR)

LDLIBS += -L $(ERL_INTERFACE_LIB_DIR) -lerl_interface -lei -lcurl -lssl -lcrypto -levent
LDLIBS += -L /tmp/curl/lib -L $(ERL_INTERFACE_LIB_DIR) -lerl_interface -lei -lcurl -lssl -lcrypto -levent

c_verbose_0 = @echo " C " $(?F);
c_verbose = $(c_verbose_$(V))
Expand Down
6 changes: 6 additions & 0 deletions c_src/katipo.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ static void check_multi_info(GlobalInfo *global) {
CURLcode res;

while ((msg = curl_multi_info_read(global->multi, &msgs_left))) {
fprintf(stderr, "ZZZZ curl_multi_info_read\n");
if (msg->msg == CURLMSG_DONE) {
easy = msg->easy_handle;
res = msg->data.result;
Expand All @@ -550,6 +551,7 @@ static void check_multi_info(GlobalInfo *global) {
send_error_to_erlang(res, conn);
}

fprintf(stderr, "ZZZZ curl_multi_remove_handle\n");
curl_multi_remove_handle(global->multi, easy);
free(conn->url);
free(conn->pid);
Expand Down Expand Up @@ -657,6 +659,7 @@ static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *data) {
size_t realsize = size * nmemb;
ConnInfo *conn = (ConnInfo *)data;

fprintf(stderr, "ZZZZ write_cb\n");
conn->memory = (char *)realloc(conn->memory, conn->size + realsize);
memcpy(&(conn->memory[conn->size]), ptr, realsize);
conn->size += realsize;
Expand All @@ -670,6 +673,7 @@ static size_t header_cb(void *ptr, size_t size, size_t nmemb, void *data) {
ConnInfo *conn = (ConnInfo *)data;
char *header;

fprintf(stderr, "ZZZZ header_cb\n");
// the last two chars of headers are \r\n except for http3...
if (realsize > 2) {
if (conn->resp_headers && is_status_line(ptr)) {
Expand Down Expand Up @@ -848,6 +852,7 @@ static void new_conn(long method, char *url, struct curl_slist *req_headers,

set_method(method, conn);
rc = curl_multi_add_handle(global->multi, conn->easy);
fprintf(stderr, "ZZZZ curl_multi_add_handle\n");
mcode_or_die("new_conn: curl_multi_add_handle", rc);
}

Expand Down Expand Up @@ -1112,6 +1117,7 @@ static void erl_input(struct bufferevent *ev, void *arg) {
errx(2, "Couldn't skip empty eopt list");
}

fprintf(stderr, "ZZZZ new_conn\n");
new_conn(method, url, req_headers, req_cookies, post_data,
post_data_size, eopts, pid, ref, arg);

Expand Down
Loading

0 comments on commit a157b49

Please sign in to comment.