Lines Matching refs:baller

391   struct eyeballer *baller[2];  member
410 struct eyeballer *baller; in eyeballer_new() local
413 baller = calloc(1, sizeof(*baller)); in eyeballer_new()
414 if(!baller) in eyeballer_new()
417 baller->name = ((ai_family == AF_INET) ? "ipv4" : ( in eyeballer_new()
422 baller->cf_create = cf_create; in eyeballer_new()
423 baller->first = baller->addr = addr; in eyeballer_new()
424 baller->ai_family = ai_family; in eyeballer_new()
425 baller->primary = primary; in eyeballer_new()
426 baller->delay_ms = delay_ms; in eyeballer_new()
427 baller->timeoutms = addr_next_match(baller->addr, baller->ai_family) ? in eyeballer_new()
429 baller->timeout_id = timeout_id; in eyeballer_new()
430 baller->result = CURLE_COULDNT_CONNECT; in eyeballer_new()
432 *pballer = baller; in eyeballer_new()
436 static void baller_close(struct eyeballer *baller, in baller_close() argument
439 if(baller && baller->cf) { in baller_close()
440 Curl_conn_cf_discard_chain(&baller->cf, data); in baller_close()
444 static void baller_free(struct eyeballer *baller, in baller_free() argument
447 if(baller) { in baller_free()
448 baller_close(baller, data); in baller_free()
449 free(baller); in baller_free()
453 static void baller_rewind(struct eyeballer *baller) in baller_rewind() argument
455 baller->rewinded = TRUE; in baller_rewind()
456 baller->addr = baller->first; in baller_rewind()
457 baller->inconclusive = FALSE; in baller_rewind()
460 static void baller_next_addr(struct eyeballer *baller) in baller_next_addr() argument
462 baller->addr = addr_next_match(baller->addr, baller->ai_family); in baller_next_addr()
473 struct eyeballer *baller) in baller_initiate() argument
476 struct Curl_cfilter *cf_prev = baller->cf; in baller_initiate()
485 result = baller->cf_create(&baller->cf, data, cf->conn, baller->addr, in baller_initiate()
491 for(wcf = baller->cf; wcf; wcf = wcf->next) { in baller_initiate()
496 if(addr_next_match(baller->addr, baller->ai_family)) { in baller_initiate()
497 Curl_expire(data, baller->timeoutms, baller->timeout_id); in baller_initiate()
502 CURL_TRC_CF(data, cf, "%s failed", baller->name); in baller_initiate()
503 baller_close(baller, data); in baller_initiate()
507 baller->result = result; in baller_initiate()
518 struct eyeballer *baller, in baller_start() argument
521 baller->error = 0; in baller_start()
522 baller->connected = FALSE; in baller_start()
523 baller->has_started = TRUE; in baller_start()
525 while(baller->addr) { in baller_start()
526 baller->started = Curl_now(); in baller_start()
527 baller->timeoutms = addr_next_match(baller->addr, baller->ai_family) ? in baller_start()
529 baller_initiate(cf, data, baller); in baller_start()
530 if(!baller->result) in baller_start()
532 baller_next_addr(baller); in baller_start()
534 if(!baller->addr) { in baller_start()
535 baller->is_done = TRUE; in baller_start()
537 return baller->result; in baller_start()
545 struct eyeballer *baller, in baller_start_next() argument
549 baller_next_addr(baller); in baller_start_next()
554 if(!baller->addr && baller->inconclusive) in baller_start_next()
555 baller_rewind(baller); in baller_start_next()
556 baller_start(cf, data, baller, timeoutms); in baller_start_next()
559 baller->error = 0; in baller_start_next()
560 baller->connected = FALSE; in baller_start_next()
561 baller->has_started = TRUE; in baller_start_next()
562 baller->is_done = TRUE; in baller_start_next()
563 baller->result = CURLE_COULDNT_CONNECT; in baller_start_next()
565 return baller->result; in baller_start_next()
570 struct eyeballer *baller, in baller_connect() argument
575 *connected = baller->connected; in baller_connect()
576 if(!baller->result && !*connected) { in baller_connect()
578 baller->result = Curl_conn_cf_connect(baller->cf, data, 0, connected); in baller_connect()
580 if(!baller->result) { in baller_connect()
582 baller->connected = TRUE; in baller_connect()
583 baller->is_done = TRUE; in baller_connect()
585 else if(Curl_timediff(*now, baller->started) >= baller->timeoutms) { in baller_connect()
587 "ms, move on!", baller->name, baller->timeoutms); in baller_connect()
589 baller->error = ETIMEDOUT; in baller_connect()
591 baller->result = CURLE_OPERATION_TIMEDOUT; in baller_connect()
594 else if(baller->result == CURLE_WEIRD_SERVER_REPLY) in baller_connect()
595 baller->inconclusive = TRUE; in baller_connect()
597 return baller->result; in baller_connect()
625 for(i = 0; i < ARRAYSIZE(ctx->baller); i++) { in is_connected()
626 struct eyeballer *baller = ctx->baller[i]; in is_connected() local
628 if(!baller || baller->is_done) in is_connected()
631 if(!baller->has_started) { in is_connected()
635 baller->result = baller_connect(cf, data, baller, &now, connected); in is_connected()
637 baller->name, baller->result, *connected); in is_connected()
639 if(!baller->result) { in is_connected()
642 ctx->winner = baller; in is_connected()
643 ctx->baller[i] = NULL; in is_connected()
650 else if(!baller->is_done) { in is_connected()
652 if(baller->error) { in is_connected()
653 data->state.os_errno = baller->error; in is_connected()
654 SET_SOCKERRNO(baller->error); in is_connected()
656 baller_start_next(cf, data, baller, Curl_timeleft(data, &now, TRUE)); in is_connected()
657 if(baller->is_done) { in is_connected()
658 CURL_TRC_CF(data, cf, "%s done", baller->name); in is_connected()
662 CURL_TRC_CF(data, cf, "%s trying next", baller->name); in is_connected()
686 for(i = 0; i < ARRAYSIZE(ctx->baller); i++) { in is_connected()
687 struct eyeballer *baller = ctx->baller[i]; in is_connected() local
689 if(!baller || baller->has_started) in is_connected()
693 if((baller->primary && baller->primary->is_done) || in is_connected()
694 Curl_timediff(now, ctx->started) >= baller->delay_ms) { in is_connected()
695 baller_start(cf, data, baller, Curl_timeleft(data, &now, TRUE)); in is_connected()
696 if(baller->is_done) { in is_connected()
697 CURL_TRC_CF(data, cf, "%s done", baller->name); in is_connected()
701 baller->name, baller->timeoutms); in is_connected()
720 for(i = 0; i < ARRAYSIZE(ctx->baller); i++) { in is_connected()
721 struct eyeballer *baller = ctx->baller[i]; in is_connected() local
722 if(!baller) in is_connected()
725 baller->name, baller->has_started, baller->result); in is_connected()
726 if(baller->has_started && baller->result) { in is_connected()
727 result = baller->result; in is_connected()
832 memset(ctx->baller, 0, sizeof(ctx->baller)); in start_connect()
833 result = eyeballer_new(&ctx->baller[0], ctx->cf_create, addr0, ai_family0, in start_connect()
839 ctx->baller[0]->name, ctx->baller[0]->timeoutms); in start_connect()
842 result = eyeballer_new(&ctx->baller[1], ctx->cf_create, addr1, ai_family1, in start_connect()
843 ctx->baller[0], /* wait on that to fail */ in start_connect()
850 ctx->baller[1]->name, ctx->baller[1]->timeoutms); in start_connect()
865 for(i = 0; i < ARRAYSIZE(ctx->baller); i++) { in cf_he_ctx_clear()
866 baller_free(ctx->baller[i], data); in cf_he_ctx_clear()
867 ctx->baller[i] = NULL; in cf_he_ctx_clear()
888 for(i = 0; i < ARRAYSIZE(ctx->baller); i++) { in cf_he_shutdown()
889 struct eyeballer *baller = ctx->baller[i]; in cf_he_shutdown() local
891 if(!baller || !baller->cf || baller->shutdown) in cf_he_shutdown()
893 baller->result = baller->cf->cft->do_shutdown(baller->cf, data, &bdone); in cf_he_shutdown()
894 if(baller->result || bdone) in cf_he_shutdown()
895 baller->shutdown = TRUE; /* treat a failed shutdown as done */ in cf_he_shutdown()
899 for(i = 0; i < ARRAYSIZE(ctx->baller); i++) { in cf_he_shutdown()
900 if(ctx->baller[i] && !ctx->baller[i]->shutdown) in cf_he_shutdown()
904 for(i = 0; i < ARRAYSIZE(ctx->baller); i++) { in cf_he_shutdown()
905 if(ctx->baller[i] && ctx->baller[i]->result) in cf_he_shutdown()
906 result = ctx->baller[i]->result; in cf_he_shutdown()
921 for(i = 0; i < ARRAYSIZE(ctx->baller); i++) { in cf_he_adjust_pollset()
922 struct eyeballer *baller = ctx->baller[i]; in cf_he_adjust_pollset() local
923 if(!baller || !baller->cf) in cf_he_adjust_pollset()
925 Curl_conn_cf_adjust_pollset(baller->cf, data, ps); in cf_he_adjust_pollset()
1018 for(i = 0; i < ARRAYSIZE(ctx->baller); i++) { in cf_he_data_pending()
1019 struct eyeballer *baller = ctx->baller[i]; in cf_he_data_pending() local
1020 if(!baller || !baller->cf) in cf_he_data_pending()
1022 if(baller->cf->cft->has_data_pending(baller->cf, data)) in cf_he_data_pending()
1037 for(i = 0; i < ARRAYSIZE(ctx->baller); i++) { in get_max_baller_time()
1038 struct eyeballer *baller = ctx->baller[i]; in get_max_baller_time() local
1041 if(baller && baller->cf && in get_max_baller_time()
1042 !baller->cf->cft->query(baller->cf, data, query, NULL, &t)) { in get_max_baller_time()
1062 for(i = 0; i < ARRAYSIZE(ctx->baller); i++) { in cf_he_query()
1063 struct eyeballer *baller = ctx->baller[i]; in cf_he_query() local
1066 if(baller && baller->cf && in cf_he_query()
1067 !baller->cf->cft->query(baller->cf, data, query, in cf_he_query()