• Home
  • Raw
  • Download

Lines Matching refs:context

92 	struct lws_context *context = lws_container_of(mgr, struct lws_context,  in lws_state_notify_protocol_init()  local
105 for (n = 0; n < context->count_threads; n++) in lws_state_notify_protocol_init()
106 lws_system_do_attach(&context->pt[n]); in lws_state_notify_protocol_init()
115 if (!lws_dhcpc_status(context, NULL)) in lws_state_notify_protocol_init()
123 lws_ntpc_trigger(context); in lws_state_notify_protocol_init()
139 context->netlink && in lws_state_notify_protocol_init()
140 !context->nl_initial_done) { in lws_state_notify_protocol_init()
141 lwsl_cx_info(context, "waiting for netlink coldplug"); in lws_state_notify_protocol_init()
155 ab0 = lws_system_get_blob(context, LWS_SYSBLOB_TYPE_AUTH, 0); in lws_state_notify_protocol_init()
156 ab1 = lws_system_get_blob(context, LWS_SYSBLOB_TYPE_AUTH, 1); in lws_state_notify_protocol_init()
159 context->pss_policies && ab0 && ab1 && in lws_state_notify_protocol_init()
162 lwsl_cx_info(context, in lws_state_notify_protocol_init()
168 if (!lws_ss_sys_auth_api_amazon_com(context)) in lws_state_notify_protocol_init()
179 if (lws_system_cpd_state_get(context) == LWS_CPD_INTERNET_OK) in lws_state_notify_protocol_init()
196 context->pss_policies && !context->policy_updated) { in lws_state_notify_protocol_init()
198 if (context->hss_fetch_policy) in lws_state_notify_protocol_init()
201 lwsl_cx_debug(context, "starting policy fetch"); in lws_state_notify_protocol_init()
206 if (!lws_ss_sys_fetch_policy(context)) in lws_state_notify_protocol_init()
219 if (context->protocol_init_done) in lws_state_notify_protocol_init()
225 lwsl_cx_info(context, "doing protocol init on POLICY_VALID\n"); in lws_state_notify_protocol_init()
227 return lws_protocol_init(context); in lws_state_notify_protocol_init()
233 struct lws_context *context = lws_container_of(sul, struct lws_context, in lws_context_creation_completion_cb() local
237 lws_state_transition_steps(&context->mgr_system, in lws_context_creation_completion_cb()
375 struct lws_context *context = NULL; in lws_create_context() local
603 context = lws_zalloc(size, "context"); in lws_create_context()
604 if (!context || lws_fi(&info->fic, "ctx_createfail_oom_ctx")) { in lws_create_context()
606 lws_free(context); in lws_create_context()
613 context->event_loop_ops = plev->ops; in lws_create_context()
614 context->us_wait_resolution = us_wait_resolution; in lws_create_context()
620 ci.cx = context; in lws_create_context()
624 context->trust_cache = lws_cache_create(&ci); in lws_create_context()
630 context->evlib_ctx = (uint8_t *)context + size - in lws_create_context()
634 context->evlib_plugin_list = evlib_plugin_list; in lws_create_context()
638 context->uid = info->uid; in lws_create_context()
639 context->gid = info->gid; in lws_create_context()
640 context->username = info->username; in lws_create_context()
641 context->groupname = info->groupname; in lws_create_context()
643 context->name = info->vhost_name; in lws_create_context()
645 context->log_cx = info->log_cx; in lws_create_context()
647 context->log_cx = &log_cx; in lws_create_context()
648 lwsl_refcount_cx(context->log_cx, 1); in lws_create_context()
650 context->system_ops = info->system_ops; in lws_create_context()
651 context->pt_serv_buf_size = (unsigned int)s1; in lws_create_context()
652 context->protocols_copy = info->protocols; in lws_create_context()
654 context->vh_idle_grace_ms = info->vh_idle_grace_ms ? in lws_create_context()
659 context->fic.name = "ctx"; in lws_create_context()
665 lws_fi_import(&context->fic, &info->fic); in lws_create_context()
670 context->smd_ttl_us = info->smd_ttl_us ? info->smd_ttl_us : in lws_create_context()
676 context->smd_queue_depth = (uint16_t)(info->smd_queue_depth ? in lws_create_context()
686 context->lcg[LWSLCG_WSI].tag_prefix = "wsi"; in lws_create_context()
687 context->lcg[LWSLCG_VHOST].tag_prefix = "vh"; in lws_create_context()
688 context->lcg[LWSLCG_WSI_SERVER].tag_prefix = "wsisrv"; /* adopted */ in lws_create_context()
691 context->lcg[LWSLCG_WSI_MUX].tag_prefix = "mux"; /* a mux child wsi */ in lws_create_context()
695 context->lcg[LWSLCG_WSI_CLIENT].tag_prefix = "wsicli"; in lws_create_context()
700 context->lcg[LWSLCG_SS_CLIENT].tag_prefix = "SScli"; in lws_create_context()
703 context->lcg[LWSLCG_SS_SERVER].tag_prefix = "SSsrv"; in lws_create_context()
706 context->lcg[LWSLCG_WSI_SS_CLIENT].tag_prefix = "wsiSScli"; in lws_create_context()
709 context->lcg[LWSLCG_WSI_SS_SERVER].tag_prefix = "wsiSSsrv"; in lws_create_context()
719 context->metrics_policies = info->metrics_policies; in lws_create_context()
720 context->metrics_prefix = info->metrics_prefix; in lws_create_context()
722 context->mt_service = lws_metric_create(context, in lws_create_context()
728 context->mt_conn_dns = lws_metric_create(context, in lws_create_context()
732 context->mt_conn_tcp = lws_metric_create(context, in lws_create_context()
736 context->mt_conn_tls = lws_metric_create(context, in lws_create_context()
741 context->mt_http_txn = lws_metric_create(context, in lws_create_context()
747 context->mth_conn_failures = lws_metric_create(context, in lws_create_context()
751 context->mt_adns_cache = lws_metric_create(context, in lws_create_context()
757 context->mth_ss_conn = lws_metric_create(context, LWSMTFL_REPORT_HIST, in lws_create_context()
761 context->mt_ss_cliprox_conn = lws_metric_create(context, in lws_create_context()
764 context->mt_ss_cliprox_paylat = lws_metric_create(context, in lws_create_context()
768 context->mt_ss_proxcli_paylat = lws_metric_create(context, in lws_create_context()
777 context->mth_srv = lws_metric_create(context, in lws_create_context()
785 lwsl_cx_notice(context, "LWS: %s, %s%s", library_version, opts_str, s); in lws_create_context()
787 lwsl_cx_info(context, "Event loop: %s", plev->ops->name); in lws_create_context()
796 context->lcg[LWSLCG_SSP_CLIENT].tag_prefix = "SSPcli"; in lws_create_context()
799 context->lcg[LWSLCG_SSP_ONWARD].tag_prefix = "SSPonw"; in lws_create_context()
802 context->lcg[LWSLCG_WSI_SSP_CLIENT].tag_prefix = "wsiSSPcli"; in lws_create_context()
805 context->lcg[LWSLCG_WSI_SSP_ONWARD].tag_prefix = "wsiSSPonw"; in lws_create_context()
812 context->pss_policies = info->pss_policies; in lws_create_context()
816 context->ss_proxy_bind = info->ss_proxy_bind; in lws_create_context()
817 context->ss_proxy_port = info->ss_proxy_port; in lws_create_context()
818 context->ss_proxy_address = info->ss_proxy_address; in lws_create_context()
819 if (context->ss_proxy_bind && context->ss_proxy_address) in lws_create_context()
820 lwsl_cx_notice(context, "ss proxy bind '%s', port %d, ads '%s'", in lws_create_context()
821 context->ss_proxy_bind, context->ss_proxy_port, in lws_create_context()
822 context->ss_proxy_address); in lws_create_context()
826 context->undestroyed_threads = count_threads; in lws_create_context()
827 context->count_threads = count_threads; in lws_create_context()
831 lwsl_cx_warn(context, "WITHOUT_EXTENSIONS but exts ptr set"); in lws_create_context()
837 context->pss_policies_json = info->pss_policies_json; in lws_create_context()
840 context->pss_plugins = info->pss_plugins; in lws_create_context()
845 if (lws_plat_drop_app_privileges(context, 0) || in lws_create_context()
846 lws_fi(&context->fic, "ctx_createfail_privdrop")) in lws_create_context()
851 context->tls_ops = &tls_ops_mbedtls; in lws_create_context()
855 context->tls_ops = &tls_ops_openssl; in lws_create_context()
860 lws_mutex_refcount_init(&context->mr); in lws_create_context()
865 context->last_free_heap = xPortGetFreeHeapSize(); in lws_create_context()
867 context->last_free_heap = esp_get_free_heap_size(); in lws_create_context()
874 context->fops_platform.LWS_FOP_OPEN = _lws_plat_file_open; in lws_create_context()
875 context->fops_platform.LWS_FOP_CLOSE = _lws_plat_file_close; in lws_create_context()
876 context->fops_platform.LWS_FOP_SEEK_CUR = _lws_plat_file_seek_cur; in lws_create_context()
877 context->fops_platform.LWS_FOP_READ = _lws_plat_file_read; in lws_create_context()
878 context->fops_platform.LWS_FOP_WRITE = _lws_plat_file_write; in lws_create_context()
879 context->fops_platform.fi[0].sig = NULL; in lws_create_context()
889 context->fops = &context->fops_platform; in lws_create_context()
890 prev = (struct lws_plat_file_ops *)context->fops; in lws_create_context()
894 context->fops_zip = fops_zip; in lws_create_context()
895 prev->next = &context->fops_zip; in lws_create_context()
905 context->reject_service_keywords = info->reject_service_keywords; in lws_create_context()
908 context->external_baggage_free_on_destroy = in lws_create_context()
911 context->time_up = lws_now_usecs(); in lws_create_context()
913 context->pcontext_finalize = info->pcontext; in lws_create_context()
916 context->simultaneous_ssl_restriction = in lws_create_context()
918 context->simultaneous_ssl_handshake_restriction = in lws_create_context()
922 context->options = info->options; in lws_create_context()
941 context->started_with_parent = pid_daemon; in lws_create_context()
942 lwsl_cx_info(context, " Started with daemon pid %u", in lws_create_context()
949 lwsl_cx_err(context, "Get RLIMIT_NOFILE failed!"); in lws_create_context()
953 context->max_fds = (unsigned int)rt.rlim_cur; in lws_create_context()
956 context->max_fds = getdtablesize(); in lws_create_context()
961 context->max_fds = 2560; in lws_create_context()
964 lwsl_cx_warn(context, "unreasonable ulimit -n workaround"); in lws_create_context()
967 context->max_fds = (unsigned int)l; in lws_create_context()
970 if ((int)context->max_fds < 0 || in lws_create_context()
971 lws_fi(&context->fic, "ctx_createfail_maxfds")) { in lws_create_context()
972 lwsl_cx_err(context, "problem getting process max files"); in lws_create_context()
984 unsigned int mf = lpf * context->count_threads; in lws_create_context()
986 if (mf < context->max_fds) { in lws_create_context()
987 context->max_fds_unrelated_to_ulimit = 1; in lws_create_context()
988 context->max_fds = mf; in lws_create_context()
993 context->token_limits = info->token_limits; in lws_create_context()
998 time(&context->tls.last_cert_check_s); in lws_create_context()
1000 context->tls.alpn_default = info->alpn; in lws_create_context()
1002 char *p = context->tls.alpn_discovered, first = 1; in lws_create_context()
1009 (context->tls.alpn_discovered + in lws_create_context()
1010 sizeof(context->tls.alpn_discovered) - in lws_create_context()
1016 context->tls.alpn_default = context->tls.alpn_discovered; in lws_create_context()
1022 context->timeout_secs = info->timeout_secs; in lws_create_context()
1025 context->timeout_secs = 15; in lws_create_context()
1029 context->max_http_header_data = info->max_http_header_data; in lws_create_context()
1032 context->max_http_header_data = in lws_create_context()
1035 context->max_http_header_data = LWS_DEF_HEADER_LEN; in lws_create_context()
1038 context->max_http_header_pool = info->max_http_header_pool; in lws_create_context()
1041 context->max_http_header_pool = in lws_create_context()
1044 context->max_http_header_pool = context->max_fds; in lws_create_context()
1048 context->fd_limit_per_thread = lpf; in lws_create_context()
1050 if (context->count_threads) in lws_create_context()
1051 context->fd_limit_per_thread = context->max_fds / in lws_create_context()
1052 context->count_threads; in lws_create_context()
1055 lws_mutex_init(context->smd.lock_messages); in lws_create_context()
1056 lws_mutex_init(context->smd.lock_peers); in lws_create_context()
1060 if (!lws_smd_register(context, context, 0, LWSSMDCL_NETWORK, in lws_create_context()
1062 lwsl_cx_err(context, "early smd register failed"); in lws_create_context()
1068 !lws_smd_register(context, info->early_smd_opaque, 0, in lws_create_context()
1071 lwsl_cx_err(context, "early smd register failed"); in lws_create_context()
1078 context->default_retry.retry_ms_table = default_backoff_table; in lws_create_context()
1079 context->default_retry.conceal_count = in lws_create_context()
1080 context->default_retry.retry_ms_table_count = in lws_create_context()
1082 context->default_retry.jitter_percent = 20; in lws_create_context()
1083 context->default_retry.secs_since_valid_ping = 300; in lws_create_context()
1084 context->default_retry.secs_since_valid_hangup = 310; in lws_create_context()
1088 context->default_retry.secs_since_valid_ping = in lws_create_context()
1090 context->default_retry.secs_since_valid_hangup = in lws_create_context()
1098 u = (uint8_t *)&context[1]; in lws_create_context()
1099 for (n = 0; n < context->count_threads; n++) { in lws_create_context()
1100 context->pt[n].serv_buf = u; in lws_create_context()
1101 u += context->pt_serv_buf_size; in lws_create_context()
1103 context->pt[n].context = context; in lws_create_context()
1104 context->pt[n].tid = (uint8_t)n; in lws_create_context()
1114 context->pt[n].fake_wsi = (struct lws *)u; in lws_create_context()
1117 memset(context->pt[n].fake_wsi, 0, sizeof(struct lws)); in lws_create_context()
1120 context->pt[n].evlib_pt = u; in lws_create_context()
1124 context->pt[n].http.ah_list = NULL; in lws_create_context()
1125 context->pt[n].http.ah_pool_length = 0; in lws_create_context()
1127 lws_pt_mutex_init(&context->pt[n]); in lws_create_context()
1129 lws_seq_pt_init(&context->pt[n]); in lws_create_context()
1135 pt_init_destroy(context, info, in lws_create_context()
1136 &context->pt[n], 0); in lws_create_context()
1141 lwsl_cx_err(context, "info->ka_interval can't be 0 if ka_time used"); in lws_create_context()
1151 context->pl_hash_elements = in lws_create_context()
1152 (context->count_threads * context->fd_limit_per_thread) / 16; in lws_create_context()
1153 context->pl_hash_table = lws_zalloc(sizeof(struct lws_peer *) * in lws_create_context()
1154 context->pl_hash_elements, "peer limits hash table"); in lws_create_context()
1156 context->ip_limit_ah = info->ip_limit_ah; in lws_create_context()
1157 context->ip_limit_wsi = info->ip_limit_wsi; in lws_create_context()
1158 context->pl_notify_cb = info->pl_notify_cb; in lws_create_context()
1165 n = (int)(sizeof(struct lws_pollfd) * context->count_threads * in lws_create_context()
1166 context->fd_limit_per_thread); in lws_create_context()
1167 context->pt[0].fds = lws_zalloc((unsigned int)n, "fds table"); in lws_create_context()
1168 if (context->pt[0].fds == NULL || in lws_create_context()
1169 lws_fi(&context->fic, "ctx_createfail_oom_fds")) { in lws_create_context()
1171 lws_free(context->pt[0].fds); in lws_create_context()
1173 lwsl_cx_err(context, "OOM allocating %d fds\n", context->max_fds); in lws_create_context()
1178 lwsl_cx_info(context, "ctx: %5luB (%ld ctx + pt(%ld thr x %d)), " in lws_create_context()
1181 (context->count_threads * context->pt_serv_buf_size), in lws_create_context()
1183 (long)context->count_threads, in lws_create_context()
1184 context->pt_serv_buf_size, in lws_create_context()
1185 context->fd_limit_per_thread, n); in lws_create_context()
1188 lwsl_cx_info(context, " http: ah_data: %u, ah: %lu, max count %u", in lws_create_context()
1189 context->max_http_header_data, in lws_create_context()
1191 context->max_http_header_pool); in lws_create_context()
1196 context->server_string = info->server_string; in lws_create_context()
1197 context->server_string_len = (short) in lws_create_context()
1198 strlen(context->server_string); in lws_create_context()
1204 for (n = 1; n < (int)context->count_threads; n++) in lws_create_context()
1205 context->pt[n].fds = context->pt[n - 1].fds + in lws_create_context()
1206 context->fd_limit_per_thread; in lws_create_context()
1215 if (lws_plat_init(context, info) || in lws_create_context()
1216 lws_fi(&context->fic, "ctx_createfail_plat_init")) in lws_create_context()
1221 if (lws_fi(&context->fic, "ctx_createfail_evlib_init")) in lws_create_context()
1224 if (context->event_loop_ops->init_context) in lws_create_context()
1225 if (context->event_loop_ops->init_context(context, info)) in lws_create_context()
1228 if (lws_fi(&context->fic, "ctx_createfail_evlib_pt")) in lws_create_context()
1231 if (context->event_loop_ops->init_pt) in lws_create_context()
1232 for (n = 0; n < context->count_threads; n++) { in lws_create_context()
1238 if (context->event_loop_ops->init_pt(context, lp, n)) in lws_create_context()
1242 lws_context_lock(context, __func__); in lws_create_context()
1243 n = __lws_create_event_pipes(context); in lws_create_context()
1244 lws_context_unlock(context); in lws_create_context()
1248 for (n = 0; n < context->count_threads; n++) { in lws_create_context()
1252 pt_init_destroy(context, info, in lws_create_context()
1253 &context->pt[n], 0); in lws_create_context()
1258 lws_context_init_ssl_library(context, info); in lws_create_context()
1260 context->user_space = info->user; in lws_create_context()
1263 strcpy(context->canonical_hostname, "unknown"); in lws_create_context()
1265 lws_server_get_canonical_hostname(context, info); in lws_create_context()
1270 memcpy(context->caps, info->caps, sizeof(context->caps)); in lws_create_context()
1271 context->count_caps = info->count_caps; in lws_create_context()
1314 if (lws_fi(&context->fic, "ctx_createfail_sys_vh")) in lws_create_context()
1317 vh = lws_create_vhost(context, &ii); in lws_create_context()
1319 lwsl_cx_err(context, "failed to create system vhost"); in lws_create_context()
1323 context->vhost_system = vh; in lws_create_context()
1326 lws_fi(&context->fic, "ctx_createfail_sys_vh_init")) { in lws_create_context()
1327 lwsl_cx_err(context, "failed to init system vhost"); in lws_create_context()
1331 lws_async_dns_init(context); in lws_create_context()
1343 context->mgr_system.state_names = system_state_names; in lws_create_context()
1344 context->mgr_system.name = "system"; in lws_create_context()
1345 context->mgr_system.state = LWS_SYSTATE_CONTEXT_CREATED; in lws_create_context()
1346 context->mgr_system.parent = context; in lws_create_context()
1347 context->mgr_system.context = context; in lws_create_context()
1349 context->mgr_system.smd_class = LWSSMDCL_SYSTEM_STATE; in lws_create_context()
1352 context->protocols_notify.name = "prot_init"; in lws_create_context()
1353 context->protocols_notify.notify_cb = lws_state_notify_protocol_init; in lws_create_context()
1355 lws_state_reg_notifier(&context->mgr_system, &context->protocols_notify); in lws_create_context()
1363 lws_state_reg_notifier_list(&context->mgr_system, in lws_create_context()
1372 if (!lws_create_vhost(context, info) || in lws_create_context()
1373 lws_fi(&context->fic, "ctx_createfail_def_vh")) { in lws_create_context()
1374 lwsl_cx_err(context, "Failed to create default vhost"); in lws_create_context()
1377 lws_free_set_NULL(context->pl_hash_table); in lws_create_context()
1387 ci.cx = context; in lws_create_context()
1392 context->nsc = lws_cache_create(&ci); in lws_create_context()
1393 if (!context->nsc) in lws_create_context()
1398 ci.parent = context->nsc; in lws_create_context()
1403 context->l1 = lws_cache_create(&ci); in lws_create_context()
1404 if (!context->l1) { in lws_create_context()
1405 lwsl_cx_err(context, "Failed to init cookiejar"); in lws_create_context()
1414 if (context->pss_policies_json) { in lws_create_context()
1422 if (lws_ss_policy_parse_begin(context, 0) || in lws_create_context()
1423 lws_fi(&context->fic, "ctx_createfail_ss_pol1")) { in lws_create_context()
1425 lws_ss_policy_parse_abandon(context); in lws_create_context()
1430 n = lws_ss_policy_parse(context, in lws_create_context()
1431 (uint8_t *)context->pss_policies_json, in lws_create_context()
1432 strlen(context->pss_policies_json)); in lws_create_context()
1434 lws_fi(&context->fic, "ctx_createfail_ss_pol2")) { in lws_create_context()
1435 lws_ss_policy_parse_abandon(context); in lws_create_context()
1439 if (lws_ss_policy_set(context, "hardcoded") || in lws_create_context()
1440 lws_fi(&context->fic, "ctx_createfail_ss_pol3")) { in lws_create_context()
1441 lwsl_cx_err(context, "policy set failed"); in lws_create_context()
1446 if (context->pss_policies) { in lws_create_context()
1449 if (lws_ss_policy_set(context, "hardcoded") || in lws_create_context()
1450 lws_fi(&context->fic, "ctx_createfail_ss_pol3")) { in lws_create_context()
1451 lwsl_cx_err(context, "policy set failed"); in lws_create_context()
1458 lws_context_init_extensions(info, context); in lws_create_context()
1460 lwsl_cx_info(context, " mem: per-conn: %5lu bytes + protocol rx buf", in lws_create_context()
1469 if (lws_plat_drop_app_privileges(context, 1) || in lws_create_context()
1470 lws_fi(&context->fic, "ctx_createfail_privdrop")) in lws_create_context()
1483 lws_sul_schedule(context, 0, &context->sul_system_state, in lws_create_context()
1488 lws_cancel_service(context); in lws_create_context()
1491 return context; in lws_create_context()
1501 lws_context_destroy(context); in lws_create_context()
1507 lws_context_destroy(context); in lws_create_context()
1509 return fatal_exit_defer ? context : NULL; in lws_create_context()
1516 if (context) in lws_create_context()
1517 lwsl_cx_err(context, "Requested event library support not configured"); in lws_create_context()
1522 if (context) { in lws_create_context()
1524 _lws_smd_destroy(context); in lws_create_context()
1529 if (context) { in lws_create_context()
1531 lws_metrics_destroy(context); in lws_create_context()
1533 lws_fi_destroy(&context->fic); in lws_create_context()
1536 if (context) { in lws_create_context()
1537 lwsl_refcount_cx(context->log_cx, -1); in lws_create_context()
1538 lws_free(context); in lws_create_context()
1657 lws_ctx_t ctx = pt->context; in lws_pt_destroy()
1687 wsi.a.context = pt->context; in lws_pt_destroy()
1754 lws_context_destroy(struct lws_context *context) in lws_context_destroy() argument
1767 if (!context || context->inside_context_destroy) in lws_context_destroy()
1770 pcontext_finalize = context->pcontext_finalize; in lws_context_destroy()
1772 lws_context_lock(context, __func__); in lws_context_destroy()
1773 context->inside_context_destroy = 1; in lws_context_destroy()
1775 lwsl_cx_info(context, "destroy_state %d", context->destroy_state); in lws_context_destroy()
1777 switch (context->destroy_state) { in lws_context_destroy()
1783 lwsl_cx_info(context, "starting context destroy flow"); in lws_context_destroy()
1784 context->being_destroyed = 1; in lws_context_destroy()
1797 if (context->protocol_init_done) in lws_context_destroy()
1798 vh = context->vhost_list; in lws_context_destroy()
1808 lws_plat_context_early_destroy(context); in lws_context_destroy()
1810 context->service_no_longer_possible = 1; in lws_context_destroy()
1811 context->requested_stop_internal_loops = 1; in lws_context_destroy()
1829 pt = context->pt; in lws_context_destroy()
1830 for (n = 0; n < context->count_threads; n++) { in lws_context_destroy()
1847 struct lws *wsi = wsi_from_fd(context, in lws_context_destroy()
1852 lwsl_cx_debug(context, in lws_context_destroy()
1869 pt_init_destroy(context, NULL, in lws_context_destroy()
1878 if (context->event_loop_ops->destroy_pt) { in lws_context_destroy()
1879 lwsl_cx_info(context, in lws_context_destroy()
1881 context->event_loop_ops->destroy_pt(context, n); in lws_context_destroy()
1891 context->destroy_state = LWSCD_PT_WAS_DEFERRED; in lws_context_destroy()
1892 lwsl_cx_notice(context, "destroy from inside service"); in lws_context_destroy()
1893 lws_cancel_service(context); in lws_context_destroy()
1897 context->destroy_state = LWSCD_PT_WAIT_ALL_DESTROYED; in lws_context_destroy()
1919 if (context->event_loop_ops->destroy_context1) { in lws_context_destroy()
1920 lwsl_cx_info(context, "do evlib destroy_context1 and wait"); in lws_context_destroy()
1921 context->event_loop_ops->destroy_context1(context); in lws_context_destroy()
1931 lwsl_cx_info(context, "manually destroying pts"); in lws_context_destroy()
1933 pt = context->pt; in lws_context_destroy()
1934 for (n = 0; n < context->count_threads; n++, pt++) { in lws_context_destroy()
1945 for (n = 0; n < context->count_threads; n++) in lws_context_destroy()
1946 if (!context->pt[n].is_destroyed && in lws_context_destroy()
1947 !context->pt[n].event_loop_pt_unused) in lws_context_destroy()
1950 lwsl_cx_info(context, "PT_WAIT_ALL_DESTROYED: %d alive", alive); in lws_context_destroy()
1967 if (context->event_loop_ops->destroy_context2) in lws_context_destroy()
1973 context->event_loop_ops->destroy_context2(context); in lws_context_destroy()
1974 context->requested_stop_internal_loops = 1; in lws_context_destroy()
1983 lws_state_transition(&context->mgr_system, LWS_SYSTATE_POLICY_INVALID); in lws_context_destroy()
1991 vh = context->vhost_list; in lws_context_destroy()
2001 while (context->vhost_pending_destruction_list) in lws_context_destroy()
2003 __lws_vhost_destroy2(context->vhost_pending_destruction_list); in lws_context_destroy()
2007 lws_ssl_context_destroy(context); in lws_context_destroy()
2009 lws_plat_context_late_destroy(context); in lws_context_destroy()
2012 for (nu = 0; nu < context->pl_hash_elements; nu++) { in lws_context_destroy()
2014 context->pl_hash_table[nu]) { in lws_context_destroy()
2021 lws_free(context->pl_hash_table); in lws_context_destroy()
2026 for (n = 0; n < context->count_threads; n++) { in lws_context_destroy()
2027 struct lws_context_per_thread *pt = &context->pt[n]; in lws_context_destroy()
2036 pt_init_destroy(context, NULL, pt, 1); in lws_context_destroy()
2042 pt_init_destroy(context, NULL, in lws_context_destroy()
2050 lwsl_cx_info(context, "pt destroy %d", n); in lws_context_destroy()
2055 context->destroy_state = LWSCD_FINALIZATION; in lws_context_destroy()
2059 if (context->pt[0].event_loop_foreign && in lws_context_destroy()
2060 context->event_loop_ops->destroy_context1) { in lws_context_destroy()
2062 lwsl_cx_info(context, in lws_context_destroy()
2068 if (context->event_loop_ops->destroy_context1 && in lws_context_destroy()
2069 !context->pt[0].event_loop_foreign) { in lws_context_destroy()
2070 lwsl_cx_notice(context, "waiting for internal loop exit"); in lws_context_destroy()
2080 lws_metrics_dump(context); in lws_context_destroy()
2083 context->evlib_finalize_destroy_after_int_loops_stop = 1; in lws_context_destroy()
2086 if (context->event_loop_ops->destroy_context2) in lws_context_destroy()
2087 context->event_loop_ops->destroy_context2(context); in lws_context_destroy()
2089 lws_state_transition_steps(&context->mgr_system, in lws_context_destroy()
2096 for (n = 0; n < context->count_threads; n++) { in lws_context_destroy()
2097 struct lws_context_per_thread *pt = &context->pt[n]; in lws_context_destroy()
2106 pt_init_destroy(context, NULL, pt, 1); in lws_context_destroy()
2111 pt_init_destroy(context, NULL, pt, 1); in lws_context_destroy()
2119 lwsl_cx_info(context, "pt %d fully destroyed", in lws_context_destroy()
2120 (int)(pt - pt->context->pt)); in lws_context_destroy()
2130 lws_cache_destroy(&context->trust_cache); in lws_context_destroy()
2131 lws_tls_jit_trust_inflight_destroy_all(context); in lws_context_destroy()
2135 lws_cache_destroy(&context->nsc); in lws_context_destroy()
2136 lws_cache_destroy(&context->l1); in lws_context_destroy()
2140 _lws_smd_destroy(context); in lws_context_destroy()
2144 lws_async_dns_deinit(&context->async_dns); in lws_context_destroy()
2147 lws_dhcpc_remove(context, NULL); in lws_context_destroy()
2150 if (context->pt[0].fds) in lws_context_destroy()
2151 lws_free_set_NULL(context->pt[0].fds); in lws_context_destroy()
2153 lws_context_deinit_ssl_library(context); in lws_context_destroy()
2156 if (context->latencies_fd != -1) in lws_context_destroy()
2157 compatible_close(context->latencies_fd); in lws_context_destroy()
2162 lws_system_get_blob(context, (lws_system_blob_item_t)n, 0)); in lws_context_destroy()
2167 while (context->server_der_list) { in lws_context_destroy()
2168 struct lws_ss_x509 *x = context->server_der_list; in lws_context_destroy()
2170 context->server_der_list = x->next; in lws_context_destroy()
2174 if (context->ac_policy) in lws_context_destroy()
2175 lwsac_free(&context->ac_policy); in lws_context_destroy()
2182 lws_context_unlock(context); in lws_context_destroy()
2185 lws_mutex_refcount_destroy(&context->mr); in lws_context_destroy()
2189 lws_metrics_destroy(context); in lws_context_destroy()
2192 if (context->external_baggage_free_on_destroy) in lws_context_destroy()
2193 free(context->external_baggage_free_on_destroy); in lws_context_destroy()
2197 context->last_free_heap = xPortGetFreeHeapSize(); in lws_context_destroy()
2199 context->last_free_heap = esp_get_free_heap_size(); in lws_context_destroy()
2204 if (context->evlib_plugin_list) in lws_context_destroy()
2205 lws_plugins_destroy(&context->evlib_plugin_list, in lws_context_destroy()
2210 lws_fi_destroy(&context->fic); in lws_context_destroy()
2213 lwsl_refcount_cx(context->log_cx, -1); in lws_context_destroy()
2215 lws_free(context); in lws_context_destroy()
2226 lwsl_cx_info(context, "leaving"); in lws_context_destroy()
2227 context->inside_context_destroy = 0; in lws_context_destroy()
2228 lws_context_unlock(context); in lws_context_destroy()
2232 lws_context_is_being_destroyed(struct lws_context *context) in lws_context_is_being_destroyed() argument
2234 return !!context->being_destroyed; in lws_context_is_being_destroyed()
2242 return mgr->context; in lws_system_context_from_system_mgr()