• Home
  • Raw
  • Download

Lines Matching +full:- +full:- +full:agree +full:- +full:tos

2  * libwebsockets - small server side websockets and web server implementation
4 * Copyright (C) 2019 - 2021 Andy Green <andy@warmcat.com>
25 #include <private-lib-core.h>
199 if (!h->policy || !(h->policy->flags & LWSSSPOLF_PERF) || !h->wsi || in lws_conmon_ss_json()
200 h->wsi->perf_done) in lws_conmon_ss_json()
203 if (h->conmon_json) in lws_conmon_ss_json()
204 lws_free_set_NULL(h->conmon_json); in lws_conmon_ss_json()
206 h->conmon_json = lws_malloc(len, __func__); in lws_conmon_ss_json()
207 if (!h->conmon_json) in lws_conmon_ss_json()
210 obuf = buf = h->conmon_json; in lws_conmon_ss_json()
211 end = buf + len - 1; in lws_conmon_ss_json()
213 lws_conmon_wsi_take(h->wsi, &cm); in lws_conmon_ss_json()
233 lws_sa46_write_numeric_address((lws_sockaddr46 *)ai->ai_addr, ads, sizeof(ads)); in lws_conmon_ss_json()
235 if (ai->ai_next && buf < end - 2) in lws_conmon_ss_json()
237 ai = ai->ai_next; in lws_conmon_ss_json()
261 h->conmon_len = (uint16_t)lws_ptr_diff(buf, obuf); in lws_conmon_ss_json()
264 if (h->proxy_onward) { in lws_conmon_ss_json()
279 if (h->info.rx) in lws_conmon_ss_json()
280 ret = h->info.rx(ss_to_userobj(h), (uint8_t *)h->conmon_json, in lws_conmon_ss_json()
281 (unsigned int)h->conmon_len, in lws_conmon_ss_json()
285 lws_free_set_NULL(h->conmon_json); in lws_conmon_ss_json()
307 lwsl_err("%s: %s: bad new state %u\n", __func__, lc->gutag, cs); in lws_ss_check_next_state()
315 lc->gutag, (unsigned int)*prevstate); in lws_ss_check_next_state()
322 lwsl_notice("%s: %s: %s -> %s\n", __func__, lc->gutag, in lws_ss_check_next_state()
332 lwsl_err("%s: %s: transition from %s -> %s is illegal\n", __func__, in lws_ss_check_next_state()
333 lc->gutag, lws_ss_state_name((int)*prevstate), in lws_ss_check_next_state()
371 lwsl_ss_notice(ss, "%s -> %s", in lws_ss_check_next_state_ss()
381 lwsl_ss_err(ss, "transition from %s -> %s is illegal", in lws_ss_check_next_state_ss()
410 if (lws_ss_check_next_state_ss(h, &h->prev_ss_state, cs)) in lws_ss_event_helper()
414 h->ss_dangling_connected = 1; in lws_ss_event_helper()
416 h->ss_dangling_connected = 0; in lws_ss_event_helper()
423 if (h->seq && cs != LWSSSCS_DESTROYING) in lws_ss_event_helper()
424 lws_seq_queue_event(h->seq, LWSSEQ_SS_STATE_BASE + cs, in lws_ss_event_helper()
428 if (h->info.state) { in lws_ss_event_helper()
429 h->h_in_svc = h; in lws_ss_event_helper()
430 r = h->info.state(ss_to_userobj(h), NULL, cs, in lws_ss_event_helper()
432 h->wsi && h->wsi->dns_reachability); in lws_ss_event_helper()
433 h->h_in_svc = NULL; in lws_ss_event_helper()
435 if ((h->info.flags & LWSSSINFLAGS_ACCEPTED) && in lws_ss_event_helper()
456 if ((*ph)->wsi) { in _lws_ss_handle_state_ret_CAN_DESTROY_HANDLE()
457 lws_set_opaque_user_data((*ph)->wsi, NULL); in _lws_ss_handle_state_ret_CAN_DESTROY_HANDLE()
458 lws_set_timeout((*ph)->wsi, 1, LWS_TO_KILL_ASYNC); in _lws_ss_handle_state_ret_CAN_DESTROY_HANDLE()
461 (*ph)->wsi = NULL; in _lws_ss_handle_state_ret_CAN_DESTROY_HANDLE()
465 return -1; /* close connection */ in _lws_ss_handle_state_ret_CAN_DESTROY_HANDLE()
476 h->seqstate = SSSEQ_DO_RETRY; in lws_ss_timeout_sul_check_cb()
489 lws_ss_metadata_t *md = lws_ss_policy_metadata(h->policy, name), in lws_ss_exp_cb_metadata()
501 replace = hmd->value__may_own_heap; in lws_ss_exp_cb_metadata()
506 total = hmd->length; in lws_ss_exp_cb_metadata()
508 budget = olen - *pos; in lws_ss_exp_cb_metadata()
509 total -= *exp_ofs; in lws_ss_exp_cb_metadata()
527 struct lws_context_per_thread *pt = &h->context->pt[h->tsi]; in lws_ss_set_timeout_us()
529 h->sul.cb = lws_ss_timeout_sul_check_cb; in lws_ss_set_timeout_us()
530 __lws_sul_insert_us(&pt->pt_sul_owner[ in lws_ss_set_timeout_us()
531 !!(h->policy->flags & LWSSSPOLF_WAKE_SUSPEND__VALIDITY)], in lws_ss_set_timeout_us()
532 &h->sul, us); in lws_ss_set_timeout_us()
543 lws_service_assert_loop_thread(h->context, h->tsi); in _lws_ss_backoff()
545 if (h->seqstate == SSSEQ_RECONNECT_WAIT) in _lws_ss_backoff()
551 ms = lws_retry_get_delay_ms(h->context, h->policy->retry_bo, in _lws_ss_backoff()
552 &h->retry, &conceal); in _lws_ss_backoff()
556 if (h->seqstate == SSSEQ_IDLE) /* been here? */ in _lws_ss_backoff()
559 h->seqstate = SSSEQ_IDLE; in _lws_ss_backoff()
569 h->seqstate = SSSEQ_RECONNECT_WAIT; in _lws_ss_backoff()
587 * Local SMD <-> SS
602 uint8_t *p = (uint8_t *)buf - LWS_SMD_SS_RX_HEADER_LEN; in lws_smd_ss_cb()
604 lws_service_assert_loop_thread(h->context, h->tsi); in lws_smd_ss_cb()
607 * When configured with SS enabled, lws over-allocates in lws_smd_ss_cb()
609 * message, for prepending serialized class and timestamp data in-band in lws_smd_ss_cb()
616 if (h->info.rx) in lws_smd_ss_cb()
617 h->info.rx((void *)&h[1], p, len + LWS_SMD_SS_RX_HEADER_LEN, in lws_smd_ss_cb()
632 lws_service_assert_loop_thread(h->context, h->tsi); in lws_ss_smd_tx_cb()
634 if (!h->info.tx) in lws_ss_smd_tx_cb()
637 n = h->info.tx(&h[1], h->txord++, buf, &len, &flags); in lws_ss_smd_tx_cb()
647 p = lws_smd_msg_alloc(h->context, _class, len - LWS_SMD_SS_RX_HEADER_LEN); in lws_ss_smd_tx_cb()
654 memcpy(p, buf + LWS_SMD_SS_RX_HEADER_LEN, len - LWS_SMD_SS_RX_HEADER_LEN); in lws_ss_smd_tx_cb()
655 if (lws_smd_msg_send(h->context, p)) { in lws_ss_smd_tx_cb()
677 lws_service_assert_loop_thread(h->context, h->tsi); in _lws_ss_client_connect()
679 if (!h->policy) { in _lws_ss_client_connect()
689 // if (h->h_sink) in _lws_ss_client_connect()
693 h->retry = 0; in _lws_ss_client_connect()
696 if (h->policy == &pol_smd) { in _lws_ss_client_connect()
698 if (h->u.smd.smd_peer) in _lws_ss_client_connect()
702 // __func__, h->info.manual_initial_tx_credit); in _lws_ss_client_connect()
704 h->u.smd.smd_peer = lws_smd_register(h->context, h, in _lws_ss_client_connect()
705 (h->info.flags & LWSSSINFLAGS_PROXIED) ? in _lws_ss_client_connect()
707 (lws_smd_class_t)h->info.manual_initial_tx_credit, in _lws_ss_client_connect()
709 if (!h->u.smd.smd_peer) in _lws_ss_client_connect()
722 * We're going to substitute ${metadata} in the endpoint at connection- in _lws_ss_client_connect()
728 if (lws_strexp_expand(&exp, h->policy->endpoint, in _lws_ss_client_connect()
729 strlen(h->policy->endpoint), in _lws_ss_client_connect()
744 _port = port = h->policy->port; in _lws_ss_client_connect()
760 i.context = h->context; in _lws_ss_client_connect()
761 tls = !!(h->policy->flags & LWSSSPOLF_TLS); in _lws_ss_client_connect()
771 if (!h->policy->trust.store) in _lws_ss_client_connect()
775 i.vhost = lws_get_vhost_by_name(h->context, in _lws_ss_client_connect()
776 h->policy->trust.store->name); in _lws_ss_client_connect()
780 h->policy->trust.store->name); in _lws_ss_client_connect()
782 return -1; in _lws_ss_client_connect()
787 if (h->policy->flags & LWSSSPOLF_WAKE_SUSPEND__VALIDITY) in _lws_ss_client_connect()
790 /* translate policy attributes to IP ToS flags */ in _lws_ss_client_connect()
792 if (h->policy->flags & LWSSSPOLF_ATTR_LOW_LATENCY) in _lws_ss_client_connect()
794 if (h->policy->flags & LWSSSPOLF_ATTR_HIGH_THROUGHPUT) in _lws_ss_client_connect()
796 if (h->policy->flags & LWSSSPOLF_ATTR_HIGH_RELIABILITY) in _lws_ss_client_connect()
798 if (h->policy->flags & LWSSSPOLF_ATTR_LOW_COST) in _lws_ss_client_connect()
800 if (h->policy->flags & LWSSSPOLF_PERF) /* collect conmon stats on this */ in _lws_ss_client_connect()
805 i.priority = h->policy->priority; in _lws_ss_client_connect()
811 h->conn_if_sspc_onw = conn_if_sspc_onw; in _lws_ss_client_connect()
820 i.seq = h->seq; in _lws_ss_client_connect()
821 i.retry_and_idle_policy = h->policy->retry_bo; in _lws_ss_client_connect()
822 i.sys_tls_client_cert = h->policy->client_cert; in _lws_ss_client_connect()
829 ssp = ss_pcols[(int)h->policy->protocol]; in _lws_ss_client_connect()
835 i.alpn = ssp->alpn; in _lws_ss_client_connect()
839 * the protocol-specific munge callback below if not http in _lws_ss_client_connect()
841 i.method = h->policy->u.http.method; in _lws_ss_client_connect()
842 i.protocol = ssp->protocol->name; /* lws protocol name */ in _lws_ss_client_connect()
845 path = lws_malloc(h->context->max_http_header_data, __func__); in _lws_ss_client_connect()
851 if (ssp->munge) /* eg, raw doesn't use; endpoint strexp already done */ in _lws_ss_client_connect()
852 ssp->munge(h, path, h->context->max_http_header_data, &i, &ct); in _lws_ss_client_connect()
854 i.pwsi = &h->wsi; in _lws_ss_client_connect()
857 if (h->policy->plugins[0] && h->policy->plugins[0]->munge) in _lws_ss_client_connect()
858 h->policy->plugins[0]->munge(h, path, h->context->max_http_header_data); in _lws_ss_client_connect()
866 if (!h->cal_txn.mt) in _lws_ss_client_connect()
867 lws_metrics_caliper_bind(h->cal_txn, h->context->mth_ss_conn); in _lws_ss_client_connect()
869 if (h->policy->streamtype) in _lws_ss_client_connect()
870 lws_metrics_tag_add(&h->cal_txn.mtags_owner, "ss", in _lws_ss_client_connect()
871 h->policy->streamtype); in _lws_ss_client_connect()
874 h->txn_ok = 0; in _lws_ss_client_connect()
881 h->inside_connect = 1; in _lws_ss_client_connect()
882 h->pending_ret = LWSSSSRET_OK; in _lws_ss_client_connect()
884 h->inside_connect = 0; in _lws_ss_client_connect()
892 if (h->pending_ret) in _lws_ss_client_connect()
893 return h->pending_ret; in _lws_ss_client_connect()
895 if (h->prev_ss_state != LWSSSCS_UNREACHABLE && in _lws_ss_client_connect()
896 h->prev_ss_state != LWSSSCS_ALL_RETRIES_FAILED) { in _lws_ss_client_connect()
921 lws_service_assert_loop_thread(h->context, h->tsi); in lws_ss_client_connect()
941 struct lws_context_per_thread *pt = &context->pt[tsi]; in lws_ss_create()
954 pol = ssi->policy; in lws_ss_create()
968 lws_xos_init(&temp_fic.xos, lws_xos(&context->fic.xos)); in lws_ss_create()
969 lws_fi_inherit_copy(&temp_fic, &context->fic, "ss", ssi->streamtype); in lws_ss_create()
974 pol = lws_ss_policy_lookup(context, ssi->streamtype); in lws_ss_create()
978 pol = lws_ss_policy_lookup(context, ssi->streamtype); in lws_ss_create()
982 ssi->streamtype); in lws_ss_create()
990 if (ssi->flags & LWSSSINFLAGS_REGISTER_SINK) { in lws_ss_create()
997 if (!(pol->flags & LWSSSPOLF_LOCAL_SINK)) { in lws_ss_create()
1000 * but the policy does not agree the streamtype should in lws_ss_create()
1004 __func__, ssi->streamtype); in lws_ss_create()
1010 if (!(pol->flags & LWSSSPOLF_LOCAL_SINK)) { in lws_ss_create()
1013 // lws_dll2_foreach_safe(&pt->ss_owner, NULL, lws_ss_destroy_dll); in lws_ss_create()
1029 size = sizeof(*h) + ssi->user_alloc + in lws_ss_create()
1030 (ssi->streamtype ? strlen(ssi->streamtype): 0) + 1; in lws_ss_create()
1032 if (pol->plugins[0]) in lws_ss_create()
1033 size += pol->plugins[0]->alloc; in lws_ss_create()
1034 if (pol->plugins[1]) in lws_ss_create()
1035 size += pol->plugins[1]->alloc; in lws_ss_create()
1037 size += pol->metadata_count * sizeof(lws_ss_metadata_t); in lws_ss_create()
1043 h->lc.log_cx = context->log_cx; in lws_ss_create()
1045 if (ssi->sss_protocol_version) in lws_ss_create()
1046 __lws_lc_tag(context, &context->lcg[LWSLCG_WSI_SS_CLIENT], in lws_ss_create()
1047 &h->lc, "%s|v%u|%u", in lws_ss_create()
1048 ssi->streamtype ? ssi->streamtype : "nostreamtype", in lws_ss_create()
1049 (unsigned int)ssi->sss_protocol_version, in lws_ss_create()
1050 (unsigned int)ssi->client_pid); in lws_ss_create()
1052 __lws_lc_tag(context, &context->lcg[LWSLCG_WSI_SS_CLIENT], in lws_ss_create()
1053 &h->lc, "%s", in lws_ss_create()
1054 ssi->streamtype ? ssi->streamtype : "nostreamtype"); in lws_ss_create()
1057 h->fic.name = "ss"; in lws_ss_create()
1058 lws_xos_init(&h->fic.xos, lws_xos(&context->fic.xos)); in lws_ss_create()
1059 if (ssi->fic.fi_owner.count) in lws_ss_create()
1060 lws_fi_import(&h->fic, &ssi->fic); in lws_ss_create()
1062 lws_fi_inherit_copy(&h->fic, &context->fic, "ss", ssi->streamtype); in lws_ss_create()
1065 h->info = *ssi; in lws_ss_create()
1066 h->policy = pol; in lws_ss_create()
1067 h->context = context; in lws_ss_create()
1068 h->tsi = (uint8_t)tsi; in lws_ss_create()
1069 h->seq = seq_owner; in lws_ss_create()
1071 if (h->info.flags & LWSSSINFLAGS_PROXIED) in lws_ss_create()
1072 h->proxy_onward = 1; in lws_ss_create()
1078 v = (void **)(p + ssi->handle_offset); in lws_ss_create()
1082 v = (void **)(p + ssi->opaque_user_data_offset); in lws_ss_create()
1085 p += ssi->user_alloc; in lws_ss_create()
1088 if (pol->plugins[0]) { in lws_ss_create()
1089 h->nauthi = p; in lws_ss_create()
1090 p += pol->plugins[0]->alloc; in lws_ss_create()
1092 if (pol->plugins[1]) { in lws_ss_create()
1093 h->sauthi = p; in lws_ss_create()
1094 p += pol->plugins[1]->alloc; in lws_ss_create()
1098 if (pol->metadata_count) { in lws_ss_create()
1099 h->metadata = (lws_ss_metadata_t *)p; in lws_ss_create()
1100 p += pol->metadata_count * sizeof(lws_ss_metadata_t); in lws_ss_create()
1103 pol->streamtype, pol->metadata_count); in lws_ss_create()
1106 smd = pol->metadata; in lws_ss_create()
1107 for (n = 0; n < pol->metadata_count; n++) { in lws_ss_create()
1108 h->metadata[n].name = smd->name; in lws_ss_create()
1109 if (n + 1 == pol->metadata_count) in lws_ss_create()
1110 h->metadata[n].next = NULL; in lws_ss_create()
1112 h->metadata[n].next = &h->metadata[n + 1]; in lws_ss_create()
1113 smd = smd->next; in lws_ss_create()
1116 if (ssi->streamtype) in lws_ss_create()
1117 memcpy(p, ssi->streamtype, strlen(ssi->streamtype) + 1); in lws_ss_create()
1119 if (ssi->flags & LWSSSINFLAGS_SERVER) in lws_ss_create()
1120 h->info.flags &= (uint8_t)~LWSSSINFLAGS_SERVER; in lws_ss_create()
1121 h->info.streamtype = p; in lws_ss_create()
1124 lws_dll2_add_head(&h->list, &pt->ss_owner); in lws_ss_create()
1131 *ppayload_fmt = pol->payload_fmt; in lws_ss_create()
1133 if (ssi->flags & LWSSSINFLAGS_SERVER) in lws_ss_create()
1143 if (!(ssi->flags & LWSSSINFLAGS_PROXIED) && in lws_ss_create()
1150 * Just for this case, ssi->manual_initial_tx_credit is used in lws_ss_create()
1154 h->u.smd.smd_peer = lws_smd_register(context, h, 0, in lws_ss_create()
1155 (lws_smd_class_t)ssi->manual_initial_tx_credit, in lws_ss_create()
1157 if (!h->u.smd.smd_peer || lws_fi(&h->fic, "ss_create_smd")) in lws_ss_create()
1164 if (h->policy->flags & LWSSSPOLF_SERVER) { in lws_ss_create()
1171 if (h->policy->endpoint && in lws_ss_create()
1172 h->policy->endpoint[0] == '!') { in lws_ss_create()
1181 &h->policy->endpoint[1]); in lws_ss_create()
1182 if (!vho || lws_fi(&h->fic, "ss_create_vhost")) { in lws_ss_create()
1184 &h->policy->endpoint[1]); in lws_ss_create()
1198 i.iface = h->policy->endpoint; in lws_ss_create()
1199 i.vhost_name = h->policy->streamtype; in lws_ss_create()
1200 i.port = h->policy->port; in lws_ss_create()
1207 if (!ss_pcols[h->policy->protocol] || in lws_ss_create()
1208 lws_fi(&h->fic, "ss_create_pcol")) { in lws_ss_create()
1213 *ppp++ = ss_pcols[h->policy->protocol]->protocol; in lws_ss_create()
1215 if (h->policy->u.http.u.ws.subprotocol) in lws_ss_create()
1218 * ss-ws protocol in this vhost in lws_ss_create()
1226 if (h->policy->flags & LWSSSPOLF_TLS) { in lws_ss_create()
1229 h->policy->trust.server.cert->ca_der; in lws_ss_create()
1231 h->policy->trust.server.cert->ca_der_len; in lws_ss_create()
1233 h->policy->trust.server.key->ca_der; in lws_ss_create()
1235 h->policy->trust.server.key->ca_der_len; in lws_ss_create()
1239 if (!lws_fi(&h->fic, "ss_srv_vh_fail")) in lws_ss_create()
1254 vho->ss_handle = h; in lws_ss_create()
1259 lws_fi(&h->fic, "ss_create_destroy_me")) in lws_ss_create()
1263 h->policy->streamtype); in lws_ss_create()
1281 if (!lws_ss_policy_ref_trust_store(context, h->policy, 1 /* do the ref */) || in lws_ss_create()
1282 lws_fi(&h->fic, "ss_create_no_ts")) { in lws_ss_create()
1288 if (!ssi->streamtype && in lws_ss_create()
1289 !lws_ss_policy_ref_trust_store(context, h->policy, 1 /* do the ref */)) { in lws_ss_create()
1299 lws_fi(&h->fic, "ss_create_destroy_me")) in lws_ss_create()
1303 if (!(ssi->flags & LWSSSINFLAGS_PROXIED) && in lws_ss_create()
1306 if (r || lws_fi(&h->fic, "ss_create_smd_1")) in lws_ss_create()
1309 if (r || lws_fi(&h->fic, "ss_create_smd_2")) in lws_ss_create()
1314 if (!(ssi->flags & LWSSSINFLAGS_REGISTER_SINK) && in lws_ss_create()
1315 ((h->policy->flags & LWSSSPOLF_NAILED_UP) in lws_ss_create()
1317 || ((h->policy == &pol_smd) //&& in lws_ss_create()
1318 //(ssi->flags & LWSSSINFLAGS_PROXIED)) in lws_ss_create()
1323 if (lws_fi(&h->fic, "ss_create_conn")) in lws_ss_create()
1369 lws_service_assert_loop_thread(h->context, h->tsi); in lws_ss_destroy()
1371 if (h == h->h_in_svc) { in lws_ss_destroy()
1378 if (h->destroying) { in lws_ss_destroy()
1382 h->destroying = 1; in lws_ss_destroy()
1385 if (h->conmon_json) in lws_ss_destroy()
1386 lws_free_set_NULL(h->conmon_json); in lws_ss_destroy()
1389 if (h->wsi) { in lws_ss_destroy()
1394 lws_set_opaque_user_data(h->wsi, NULL); in lws_ss_destroy()
1395 lws_set_timeout(h->wsi, 1, LWS_TO_KILL_SYNC); in lws_ss_destroy()
1403 if (h->policy == &pol_smd) { in lws_ss_destroy()
1404 lws_sul_cancel(&h->u.smd.sul_write); in lws_ss_destroy()
1406 if (h->u.smd.smd_peer) { in lws_ss_destroy()
1407 lws_smd_unregister(h->u.smd.smd_peer); in lws_ss_destroy()
1408 h->u.smd.smd_peer = NULL; in lws_ss_destroy()
1413 pt = &h->context->pt[h->tsi]; in lws_ss_destroy()
1417 lws_dll2_remove(&h->list); in lws_ss_destroy()
1419 lws_dll2_remove(&h->cli_list); in lws_ss_destroy()
1421 lws_dll2_remove(&h->to_list); in lws_ss_destroy()
1422 lws_sul_cancel(&h->sul_timeout); in lws_ss_destroy()
1426 * self-defined h->policy radioactive in lws_ss_destroy()
1430 if (h->policy && (h->policy->flags & LWSSSPOLF_SERVER)) in lws_ss_destroy()
1431 v = lws_get_vhost_by_name(h->context, h->policy->streamtype); in lws_ss_destroy()
1441 if (h->prev_ss_state) { in lws_ss_destroy()
1442 if (h->ss_dangling_connected) in lws_ss_destroy()
1452 pmd = h->metadata; in lws_ss_destroy()
1455 if (pmd->value_on_lws_heap) in lws_ss_destroy()
1456 lws_free_set_NULL(pmd->value__may_own_heap); in lws_ss_destroy()
1458 pmd = pmd->next; in lws_ss_destroy()
1466 pmd = h->instant_metadata; in lws_ss_destroy()
1470 pmd = pmd->next; in lws_ss_destroy()
1475 h->instant_metadata = NULL; in lws_ss_destroy()
1477 if (h->imd_ac) in lws_ss_destroy()
1478 lwsac_free(&h->imd_ac); in lws_ss_destroy()
1482 lws_sul_cancel(&h->sul); in lws_ss_destroy()
1496 if (h->policy) in lws_ss_destroy()
1497 lws_ss_policy_unref_trust_store(h->context, h->policy); in lws_ss_destroy()
1500 if (!h->info.streamtype || !*(h->info.streamtype)) in lws_ss_destroy()
1501 lws_ss_policy_unref_trust_store(h->context, h->policy); in lws_ss_destroy()
1516 lws_fi_destroy(&h->fic); in lws_ss_destroy()
1523 lws_metrics_caliper_report_hist(h->cal_txn, (struct lws *)NULL); in lws_ss_destroy()
1526 lws_sul_cancel(&h->sul_timeout); in lws_ss_destroy()
1529 lws_sul_debug_zombies(h->context, h, sizeof(*h) + h->info.user_alloc, in lws_ss_destroy()
1532 __lws_lc_untag(h->context, &h->lc); in lws_ss_destroy()
1534 lws_explicit_bzero((void *)h, sizeof(*h) + h->info.user_alloc); in lws_ss_destroy()
1543 h->txn_resp = nack; in lws_ss_server_ack()
1544 h->txn_resp_set = 1; in lws_ss_server_ack()
1551 lws_start_foreach_dll_safe(struct lws_dll2 *, d, d1, h->src_list.head) { in lws_ss_server_foreach_client()
1576 // lwsl_notice("%s: h %p, wsi %p\n", __func__, h, h->wsi); in _lws_ss_request_tx()
1578 lws_service_assert_loop_thread(h->context, h->tsi); in _lws_ss_request_tx()
1580 if (h->wsi) { in _lws_ss_request_tx()
1581 lws_callback_on_writable(h->wsi); in _lws_ss_request_tx()
1586 if (!h->policy) { in _lws_ss_request_tx()
1592 if (h->policy->flags & LWSSSPOLF_SERVER) in _lws_ss_request_tx()
1600 if (h->policy == &pol_smd) { in _lws_ss_request_tx()
1608 lws_sul_schedule(h->context, 0, &h->u.smd.sul_write, in _lws_ss_request_tx()
1615 if (h->seqstate != SSSEQ_IDLE && in _lws_ss_request_tx()
1616 h->seqstate != SSSEQ_DO_RETRY) in _lws_ss_request_tx()
1619 h->seqstate = SSSEQ_TRY_CONNECT; in _lws_ss_request_tx()
1641 lws_service_assert_loop_thread(h->context, h->tsi); in lws_ss_request_tx_len()
1643 if (h->wsi && h->policy && in lws_ss_request_tx_len()
1644 (h->policy->protocol == LWSSSP_H1 || in lws_ss_request_tx_len()
1645 h->policy->protocol == LWSSSP_H2 || in lws_ss_request_tx_len()
1646 h->policy->protocol == LWSSSP_WS)) in lws_ss_request_tx_len()
1647 h->wsi->http.writeable_len = len; in lws_ss_request_tx_len()
1649 h->writeable_len = len; in lws_ss_request_tx_len()
1684 return h->seq; in lws_ss_get_sequencer()
1690 return h->context; in lws_ss_get_context()
1696 if (!h->rideshare) in lws_ss_rideshare()
1697 return h->policy->streamtype; in lws_ss_rideshare()
1699 return h->rideshare->streamtype; in lws_ss_rideshare()
1707 lws_service_assert_loop_thread(h->context, h->tsi); in lws_ss_add_peer_tx_credit()
1709 ssp = ss_pcols[(int)h->policy->protocol]; in lws_ss_add_peer_tx_credit()
1711 if (h->wsi && ssp && ssp->tx_cr_add) in lws_ss_add_peer_tx_credit()
1712 return ssp->tx_cr_add(h, bump); in lws_ss_add_peer_tx_credit()
1722 lws_service_assert_loop_thread(h->context, h->tsi); in lws_ss_get_est_peer_tx_credit()
1724 ssp = ss_pcols[(int)h->policy->protocol]; in lws_ss_get_est_peer_tx_credit()
1726 if (h->wsi && ssp && ssp->tx_cr_add) in lws_ss_get_est_peer_tx_credit()
1727 return ssp->tx_cr_est(h); in lws_ss_get_est_peer_tx_credit()
1733 * protocol-independent handler for ss timeout
1748 if (h->wsi) in lws_ss_to_cb()
1749 lws_set_timeout(h->wsi, 1, LWS_TO_KILL_ASYNC); in lws_ss_to_cb()
1751 _lws_ss_handle_state_ret_CAN_DESTROY_HANDLE(r, h->wsi, &h); in lws_ss_to_cb()
1757 lws_service_assert_loop_thread(h->context, h->tsi); in lws_ss_start_timeout()
1759 if (!timeout_ms && !h->policy->timeout_ms) in lws_ss_start_timeout()
1762 lws_sul_schedule(h->context, 0, &h->sul_timeout, lws_ss_to_cb, in lws_ss_start_timeout()
1763 (timeout_ms ? timeout_ms : h->policy->timeout_ms) * in lws_ss_start_timeout()
1770 lws_service_assert_loop_thread(h->context, h->tsi); in lws_ss_cancel_timeout()
1771 lws_sul_cancel(&h->sul_timeout); in lws_ss_cancel_timeout()
1785 h->info.rx = rx; in lws_ss_change_handlers()
1787 h->info.tx = tx; in lws_ss_change_handlers()
1789 h->info.state = state; in lws_ss_change_handlers()
1797 return lws_lc_tag(&h->lc); in lws_ss_tag()
1806 return ss->lc.log_cx; in lwsl_ss_get_cx()
1822 struct lws_context_per_thread *pt = &cx->pt[tsi]; in lws_ss_assert_extant()
1824 lws_start_foreach_dll_safe(struct lws_dll2 *, d, d1, pt->ss_owner.head) { in lws_ss_assert_extant()