• Home
  • Raw
  • Download

Lines Matching full:multi

72 static CURLMcode singlesocket(struct Curl_multi *multi,
75 struct Curl_multi *multi,
77 static CURLMcode multi_timeout(struct Curl_multi *multi,
79 static void process_pending_handles(struct Curl_multi *multi);
172 data->multi->num_alive--; in mstate()
334 * the list kept in the multi handle.
336 static CURLMcode multi_addmsg(struct Curl_multi *multi, in multi_addmsg() argument
339 Curl_llist_insert_next(&multi->msglist, multi->msglist.tail, msg, in multi_addmsg()
347 struct Curl_multi *multi = calloc(1, sizeof(struct Curl_multi)); in Curl_multi_handle() local
349 if(!multi) in Curl_multi_handle()
352 multi->type = CURL_MULTI_HANDLE; in Curl_multi_handle()
354 if(Curl_mk_dnscache(&multi->hostcache)) in Curl_multi_handle()
357 if(sh_init(&multi->sockhash, hashsize)) in Curl_multi_handle()
360 if(Curl_conncache_init(&multi->conn_cache, chashsize)) in Curl_multi_handle()
363 Curl_llist_init(&multi->msglist, NULL); in Curl_multi_handle()
364 Curl_llist_init(&multi->pending, NULL); in Curl_multi_handle()
366 multi->multiplexing = TRUE; in Curl_multi_handle()
369 multi->maxconnects = -1; in Curl_multi_handle()
370 return multi; in Curl_multi_handle()
374 Curl_hash_destroy(&multi->sockhash); in Curl_multi_handle()
375 Curl_hash_destroy(&multi->hostcache); in Curl_multi_handle()
376 Curl_conncache_destroy(&multi->conn_cache); in Curl_multi_handle()
377 Curl_llist_destroy(&multi->msglist, NULL); in Curl_multi_handle()
378 Curl_llist_destroy(&multi->pending, NULL); in Curl_multi_handle()
380 free(multi); in Curl_multi_handle()
390 CURLMcode curl_multi_add_handle(struct Curl_multi *multi, in curl_multi_add_handle() argument
394 if(!GOOD_MULTI_HANDLE(multi)) in curl_multi_add_handle()
402 adding to more than one multi stack */ in curl_multi_add_handle()
403 if(data->multi) in curl_multi_add_handle()
406 if(multi->in_callback) in curl_multi_add_handle()
414 * modification of easy nor multi handle allowed before this except for in curl_multi_add_handle()
415 * potential multi's connection cache growing which won't be undone in this in curl_multi_add_handle()
424 /* for multi interface connections, we share DNS cache automatically if the in curl_multi_add_handle()
428 data->dns.hostcache = &multi->hostcache; in curl_multi_add_handle()
432 /* Point to the shared or multi handle connection cache */ in curl_multi_add_handle()
436 data->state.conn_cache = &multi->conn_cache; in curl_multi_add_handle()
443 data->psl = &multi->psl; in curl_multi_add_handle()
448 if(multi->easyp) { in curl_multi_add_handle()
449 struct Curl_easy *last = multi->easylp; in curl_multi_add_handle()
452 multi->easylp = data; /* the new last node */ in curl_multi_add_handle()
457 multi->easylp = multi->easyp = data; /* both first and last */ in curl_multi_add_handle()
460 /* make the Curl_easy refer back to this multi handle */ in curl_multi_add_handle()
461 data->multi = multi; in curl_multi_add_handle()
472 multi->num_easy++; in curl_multi_add_handle()
475 multi->num_alive++; in curl_multi_add_handle()
487 memset(&multi->timer_lastcall, 0, sizeof(multi->timer_lastcall)); in curl_multi_add_handle()
499 Curl_update_timer(multi); in curl_multi_add_handle()
506 * Curl_hash_print(multi->sockhash, debug_print_sock_hash);
568 process_pending_handles(data->multi); /* connection / multiplex */ in multi_done()
653 CURLMcode curl_multi_remove_handle(struct Curl_multi *multi, in curl_multi_remove_handle() argument
662 if(!GOOD_MULTI_HANDLE(multi)) in curl_multi_remove_handle()
670 if(!data->multi) in curl_multi_remove_handle()
673 if(multi->in_callback) in curl_multi_remove_handle()
685 multi->num_alive--; in curl_multi_remove_handle()
698 /* The timer must be shut down before data->multi is set to NULL, in curl_multi_remove_handle()
721 Curl_llist_remove(&multi->pending, &data->connect_queue, NULL); in curl_multi_remove_handle()
724 /* stop using the multi handle's DNS cache, *after* the possible in curl_multi_remove_handle()
737 since we're not part of that multi handle anymore */ in curl_multi_remove_handle()
743 singlesocket(multi, easy); /* to let the application know what sockets that in curl_multi_remove_handle()
754 if(data->psl == &multi->psl) in curl_multi_remove_handle()
758 data->multi = NULL; /* clear the association to this multi handle */ in curl_multi_remove_handle()
763 for(e = multi->msglist.head; e; e = e->next) { in curl_multi_remove_handle()
767 Curl_llist_remove(&multi->msglist, e, NULL); in curl_multi_remove_handle()
777 multi->easyp = data->next; /* point to first node */ in curl_multi_remove_handle()
783 multi->easylp = data->prev; /* point to last node */ in curl_multi_remove_handle()
787 multi->num_easy--; /* one less to care about now */ in curl_multi_remove_handle()
789 Curl_update_timer(multi); in curl_multi_remove_handle()
794 bool Curl_multiplex_wanted(const struct Curl_multi *multi) in Curl_multiplex_wanted() argument
796 return (multi && (multi->multiplexing)); in Curl_multiplex_wanted()
952 CURLMcode curl_multi_fdset(struct Curl_multi *multi, in curl_multi_fdset() argument
965 if(!GOOD_MULTI_HANDLE(multi)) in curl_multi_fdset()
968 if(multi->in_callback) in curl_multi_fdset()
971 data = multi->easyp; in curl_multi_fdset()
1003 static CURLMcode Curl_multi_wait(struct Curl_multi *multi, in Curl_multi_wait() argument
1022 if(!GOOD_MULTI_HANDLE(multi)) in Curl_multi_wait()
1025 if(multi->in_callback) in Curl_multi_wait()
1028 /* Count up how many fds we have from the multi handle */ in Curl_multi_wait()
1029 data = multi->easyp; in Curl_multi_wait()
1055 (void)multi_timeout(multi, &timeout_internal); in Curl_multi_wait()
1079 data = multi->easyp; in Curl_multi_wait()
1157 if(!curl_multi_timeout(multi, &sleep_ms) && sleep_ms) { in Curl_multi_wait()
1167 CURLMcode curl_multi_wait(struct Curl_multi *multi, in curl_multi_wait() argument
1173 return Curl_multi_wait(multi, extra_fds, extra_nfds, timeout_ms, ret, FALSE); in curl_multi_wait()
1176 CURLMcode curl_multi_poll(struct Curl_multi *multi, in curl_multi_poll() argument
1182 return Curl_multi_wait(multi, extra_fds, extra_nfds, timeout_ms, ret, TRUE); in curl_multi_poll()
1193 static bool multi_ischanged(struct Curl_multi *multi, bool clear) in multi_ischanged() argument
1195 bool retval = multi->recheckstate; in multi_ischanged()
1197 multi->recheckstate = FALSE; in multi_ischanged()
1201 CURLMcode Curl_multi_add_perform(struct Curl_multi *multi, in Curl_multi_add_perform() argument
1207 if(multi->in_callback) in Curl_multi_add_perform()
1210 rc = curl_multi_add_handle(multi, data); in Curl_multi_add_perform()
1258 * multi_do_more() is called during the DO_MORE multi state. It is basically a
1284 * over from the multi interface until the connection phase is done on
1304 * We are DOING this is being called over and over from the multi interface
1385 static CURLMcode multi_runsingle(struct Curl_multi *multi, in multi_runsingle() argument
1424 if(multi_ischanged(multi, TRUE)) { in multi_runsingle()
1425 DEBUGF(infof(data, "multi changed, check CONNECT_PEND queue!\n")); in multi_runsingle()
1426 process_pending_handles(multi); /* multiplexed */ in multi_runsingle()
1518 Curl_llist_insert_next(&multi->pending, multi->pending.tail, data, in multi_runsingle()
1526 process_pending_handles(data->multi); in multi_runsingle()
1589 singlesocket(multi, data); in multi_runsingle()
1871 process_pending_handles(multi); /* multiplexed */ in multi_runsingle()
2086 process_pending_handles(multi); /* multiplexing */ in multi_runsingle()
2143 process_pending_handles(multi); /* connection */ in multi_runsingle()
2195 rc = multi_addmsg(multi, msg); in multi_runsingle()
2200 } while((rc == CURLM_CALL_MULTI_PERFORM) || multi_ischanged(multi, FALSE)); in multi_runsingle()
2207 CURLMcode curl_multi_perform(struct Curl_multi *multi, int *running_handles) in curl_multi_perform() argument
2214 if(!GOOD_MULTI_HANDLE(multi)) in curl_multi_perform()
2217 if(multi->in_callback) in curl_multi_perform()
2220 data = multi->easyp; in curl_multi_perform()
2226 result = multi_runsingle(multi, now, data); in curl_multi_perform()
2246 multi->timetree = Curl_splaygetbest(now, multi->timetree, &t); in curl_multi_perform()
2249 (void)add_next_timeout(now, multi, t->payload); in curl_multi_perform()
2253 *running_handles = multi->num_alive; in curl_multi_perform()
2256 Curl_update_timer(multi); in curl_multi_perform()
2261 CURLMcode curl_multi_cleanup(struct Curl_multi *multi) in curl_multi_cleanup() argument
2266 if(GOOD_MULTI_HANDLE(multi)) { in curl_multi_cleanup()
2267 if(multi->in_callback) in curl_multi_cleanup()
2270 multi->type = 0; /* not good anymore */ in curl_multi_cleanup()
2273 data = multi->easyp; in curl_multi_cleanup()
2288 data->multi = NULL; /* clear the association */ in curl_multi_cleanup()
2291 if(data->psl == &multi->psl) in curl_multi_cleanup()
2299 Curl_conncache_close_all_connections(&multi->conn_cache); in curl_multi_cleanup()
2301 Curl_hash_destroy(&multi->sockhash); in curl_multi_cleanup()
2302 Curl_conncache_destroy(&multi->conn_cache); in curl_multi_cleanup()
2303 Curl_llist_destroy(&multi->msglist, NULL); in curl_multi_cleanup()
2304 Curl_llist_destroy(&multi->pending, NULL); in curl_multi_cleanup()
2306 Curl_hash_destroy(&multi->hostcache); in curl_multi_cleanup()
2307 Curl_psl_destroy(&multi->psl); in curl_multi_cleanup()
2308 free(multi); in curl_multi_cleanup()
2318 * This function is the primary way for a multi/multi_socket application to
2325 CURLMsg *curl_multi_info_read(struct Curl_multi *multi, int *msgs_in_queue) in curl_multi_info_read() argument
2331 if(GOOD_MULTI_HANDLE(multi) && in curl_multi_info_read()
2332 !multi->in_callback && in curl_multi_info_read()
2333 Curl_llist_count(&multi->msglist)) { in curl_multi_info_read()
2338 e = multi->msglist.head; in curl_multi_info_read()
2343 Curl_llist_remove(&multi->msglist, e, NULL); in curl_multi_info_read()
2345 *msgs_in_queue = curlx_uztosi(Curl_llist_count(&multi->msglist)); in curl_multi_info_read()
2357 static CURLMcode singlesocket(struct Curl_multi *multi, in singlesocket() argument
2391 entry = sh_getentry(&multi->sockhash, s); in singlesocket()
2412 entry = sh_addentry(&multi->sockhash, s); in singlesocket()
2450 if(multi->socket_cb) in singlesocket()
2451 multi->socket_cb(data, s, comboaction, multi->socket_userp, in singlesocket()
2475 entry = sh_getentry(&multi->sockhash, s); in singlesocket()
2487 if(multi->socket_cb) in singlesocket()
2488 multi->socket_cb(data, s, CURL_POLL_REMOVE, in singlesocket()
2489 multi->socket_userp, in singlesocket()
2491 sh_delentry(entry, &multi->sockhash, s); in singlesocket()
2511 singlesocket(data->multi, data); in Curl_updatesocket()
2529 struct Curl_multi *multi = data->multi; in Curl_multi_closed() local
2530 if(multi) { in Curl_multi_closed()
2532 a multi handle, and only then this is necessary */ in Curl_multi_closed()
2533 struct Curl_sh_entry *entry = sh_getentry(&multi->sockhash, s); in Curl_multi_closed()
2536 if(multi->socket_cb) in Curl_multi_closed()
2537 multi->socket_cb(data, s, CURL_POLL_REMOVE, in Curl_multi_closed()
2538 multi->socket_userp, in Curl_multi_closed()
2542 sh_delentry(entry, &multi->sockhash, s); in Curl_multi_closed()
2561 struct Curl_multi *multi, in add_next_timeout() argument
2598 multi->timetree = Curl_splayinsert(*tv, multi->timetree, in add_next_timeout()
2604 static CURLMcode multi_socket(struct Curl_multi *multi, in multi_socket() argument
2617 result = curl_multi_perform(multi, running_handles); in multi_socket()
2622 data = multi->easyp; in multi_socket()
2624 result = singlesocket(multi, data); in multi_socket()
2633 struct Curl_sh_entry *entry = sh_getentry(&multi->sockhash, s); in multi_socket()
2677 memset(&multi->timer_lastcall, 0, sizeof(multi->timer_lastcall)); in multi_socket()
2691 result = multi_runsingle(multi, now, data); in multi_socket()
2697 result = singlesocket(multi, data); in multi_socket()
2706 multi->timetree = Curl_splaygetbest(now, multi->timetree, &t); in multi_socket()
2709 (void)add_next_timeout(now, multi, t->payload); in multi_socket()
2714 *running_handles = multi->num_alive; in multi_socket()
2719 CURLMcode curl_multi_setopt(struct Curl_multi *multi, in curl_multi_setopt() argument
2725 if(!GOOD_MULTI_HANDLE(multi)) in curl_multi_setopt()
2728 if(multi->in_callback) in curl_multi_setopt()
2735 multi->socket_cb = va_arg(param, curl_socket_callback); in curl_multi_setopt()
2738 multi->socket_userp = va_arg(param, void *); in curl_multi_setopt()
2741 multi->push_cb = va_arg(param, curl_push_callback); in curl_multi_setopt()
2744 multi->push_userp = va_arg(param, void *); in curl_multi_setopt()
2747 multi->multiplexing = va_arg(param, long) & CURLPIPE_MULTIPLEX; in curl_multi_setopt()
2750 multi->timer_cb = va_arg(param, curl_multi_timer_callback); in curl_multi_setopt()
2753 multi->timer_userp = va_arg(param, void *); in curl_multi_setopt()
2756 multi->maxconnects = va_arg(param, long); in curl_multi_setopt()
2759 multi->max_host_connections = va_arg(param, long); in curl_multi_setopt()
2762 multi->max_total_connections = va_arg(param, long); in curl_multi_setopt()
2780 multi->max_concurrent_streams = in curl_multi_setopt()
2793 /* we define curl_multi_socket() in the public multi.h header */
2796 CURLMcode curl_multi_socket(struct Curl_multi *multi, curl_socket_t s, in curl_multi_socket() argument
2800 if(multi->in_callback) in curl_multi_socket()
2802 result = multi_socket(multi, FALSE, s, 0, running_handles); in curl_multi_socket()
2804 Curl_update_timer(multi); in curl_multi_socket()
2808 CURLMcode curl_multi_socket_action(struct Curl_multi *multi, curl_socket_t s, in curl_multi_socket_action() argument
2812 if(multi->in_callback) in curl_multi_socket_action()
2814 result = multi_socket(multi, FALSE, s, ev_bitmask, running_handles); in curl_multi_socket_action()
2816 Curl_update_timer(multi); in curl_multi_socket_action()
2820 CURLMcode curl_multi_socket_all(struct Curl_multi *multi, int *running_handles) in curl_multi_socket_all() argument
2824 if(multi->in_callback) in curl_multi_socket_all()
2826 result = multi_socket(multi, TRUE, CURL_SOCKET_BAD, 0, running_handles); in curl_multi_socket_all()
2828 Curl_update_timer(multi); in curl_multi_socket_all()
2832 static CURLMcode multi_timeout(struct Curl_multi *multi, in multi_timeout() argument
2837 if(multi->timetree) { in multi_timeout()
2842 multi->timetree = Curl_splay(tv_zero, multi->timetree); in multi_timeout()
2844 if(Curl_splaycomparekeys(multi->timetree->key, now) > 0) { in multi_timeout()
2846 timediff_t diff = Curl_timediff(multi->timetree->key, now); in multi_timeout()
2871 CURLMcode curl_multi_timeout(struct Curl_multi *multi, in curl_multi_timeout() argument
2875 if(!GOOD_MULTI_HANDLE(multi)) in curl_multi_timeout()
2878 if(multi->in_callback) in curl_multi_timeout()
2881 return multi_timeout(multi, timeout_ms); in curl_multi_timeout()
2888 void Curl_update_timer(struct Curl_multi *multi) in Curl_update_timer() argument
2892 if(!multi->timer_cb) in Curl_update_timer()
2894 if(multi_timeout(multi, &timeout_ms)) { in Curl_update_timer()
2899 if(Curl_splaycomparekeys(none, multi->timer_lastcall)) { in Curl_update_timer()
2900 multi->timer_lastcall = none; in Curl_update_timer()
2903 multi->timer_cb(multi, -1, multi->timer_userp); in Curl_update_timer()
2909 /* When multi_timeout() is done, multi->timetree points to the node with the in Curl_update_timer()
2913 if(Curl_splaycomparekeys(multi->timetree->key, multi->timer_lastcall) == 0) in Curl_update_timer()
2916 multi->timer_lastcall = multi->timetree->key; in Curl_update_timer()
2918 multi->timer_cb(multi, timeout_ms, multi->timer_userp); in Curl_update_timer()
2997 struct Curl_multi *multi = data->multi; in Curl_expire() local
3001 /* this is only interesting while there is still an associated multi struct in Curl_expire()
3003 if(!multi) in Curl_expire()
3039 rc = Curl_splayremovebyaddr(multi->timetree, in Curl_expire()
3041 &multi->timetree); in Curl_expire()
3050 multi->timetree = Curl_splayinsert(*nowp, multi->timetree, in Curl_expire()
3073 struct Curl_multi *multi = data->multi; in Curl_expire_clear() local
3076 /* this is only interesting while there is still an associated multi struct in Curl_expire_clear()
3078 if(!multi) in Curl_expire_clear()
3087 rc = Curl_splayremovebyaddr(multi->timetree, in Curl_expire_clear()
3089 &multi->timetree); in Curl_expire_clear()
3109 CURLMcode curl_multi_assign(struct Curl_multi *multi, curl_socket_t s, in curl_multi_assign() argument
3114 if(multi->in_callback) in curl_multi_assign()
3117 there = sh_getentry(&multi->sockhash, s); in curl_multi_assign()
3127 size_t Curl_multi_max_host_connections(struct Curl_multi *multi) in Curl_multi_max_host_connections() argument
3129 return multi ? multi->max_host_connections : 0; in Curl_multi_max_host_connections()
3132 size_t Curl_multi_max_total_connections(struct Curl_multi *multi) in Curl_multi_max_total_connections() argument
3134 return multi ? multi->max_total_connections : 0; in Curl_multi_max_total_connections()
3147 DEBUGASSERT(conn->data->multi); in Curl_multiuse_state()
3150 process_pending_handles(conn->data->multi); in Curl_multiuse_state()
3153 static void process_pending_handles(struct Curl_multi *multi) in process_pending_handles() argument
3155 struct curl_llist_element *e = multi->pending.head; in process_pending_handles()
3164 Curl_llist_remove(&multi->pending, e, NULL); in process_pending_handles()
3180 else if(data->multi) in Curl_set_in_callback()
3181 data->multi->in_callback = value; in Curl_set_in_callback()
3187 return ((easy->multi && easy->multi->in_callback) || in Curl_is_in_callback()
3192 void Curl_multi_dump(struct Curl_multi *multi) in Curl_multi_dump() argument
3196 fprintf(stderr, "* Multi status: %d handles, %d alive\n", in Curl_multi_dump()
3197 multi->num_easy, multi->num_alive); in Curl_multi_dump()
3198 for(data = multi->easyp; data; data = data->next) { in Curl_multi_dump()
3206 struct Curl_sh_entry *entry = sh_getentry(&multi->sockhash, s); in Curl_multi_dump()
3224 size_t Curl_multi_max_concurrent_streams(struct Curl_multi *multi) in Curl_multi_max_concurrent_streams() argument
3226 return multi ? ((size_t)multi->max_concurrent_streams ? in Curl_multi_max_concurrent_streams()
3227 (size_t)multi->max_concurrent_streams : 100) : 0; in Curl_multi_max_concurrent_streams()