int inet_sch_manage_sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void * sockpp) { static const char * whatstr[]={ "none", "IN", "OUT", "INOUT", "REMOVE"}; inet_sch_manage_t mgr; inet_sch_task_t task; mgr = (inet_sch_manage_t)cbp; assert(mgr); if (mgr->m_debug >= 2) { CPE_INFO( mgr->m_em, "%s: socket callback: e %p s %i what %s(%d)", inet_sch_manage_name(mgr), e, s, (what >= 0 && what < sizeof(whatstr) / sizeof(whatstr[0])) ? whatstr[what] : "???", what); } curl_easy_getinfo(e, CURLINFO_PRIVATE, &task); assert(task); if (what == CURL_POLL_REMOVE) { inet_sch_task_complete(task); } else { inet_sch_task_set_socket(task, s, what); } return 0; }
void inet_sch_process_multi_info(inet_sch_manage_t mgr) { CURLMsg *msg; while ((msg = curl_multi_info_read(mgr->m_multi, NULL))) { struct inet_sch_task * task; CURL * easy; CURLcode res; char * eff_url; easy = msg->easy_handle; res = msg->data.result; curl_easy_getinfo(easy, CURLINFO_PRIVATE, &task); curl_easy_getinfo(easy, CURLINFO_EFFECTIVE_URL, &eff_url); switch(msg->msg) { case CURLMSG_DONE: { if (mgr->m_debug) { CPE_INFO(mgr->m_em, "%s: DONE: %s => (%d) %s", inet_sch_manage_name(mgr), eff_url, res, ""/*connection->error*/); } inet_sch_task_complete(task); break; } default: CPE_ERROR(mgr->m_em, "%s: UNKNOWN: %s => (%d) %s", inet_sch_manage_name(mgr), eff_url, res, ""/*connection->error*/); } } }
void inet_sch_task_free(inet_sch_task_t task) { inet_sch_task_complete(task); curl_easy_cleanup(task->m_handler); mem_free(task->m_mgr->m_alloc, task); }