Lines Matching refs:wsi

49 lws_callback_as_writeable(struct lws *wsi)
53 n = wsi->role_ops->writeable_cb[lwsi_role_server(wsi)];
54 m = user_callback_handle_rxflow(wsi->a.protocol->callback,
55 wsi, (enum lws_callback_reasons) n,
56 wsi->user_space, NULL, 0);
62 lws_handle_POLLOUT_event(struct lws *wsi, struct lws_pollfd *pollfd)
64 volatile struct lws *vwsi = (volatile struct lws *)wsi;
67 if (wsi->socket_is_permanently_unusable)
77 wsi->could_have_pending = 0; /* clear back-to-back write detection */
90 if (lws_has_buffered_out(wsi)) {
91 if (lws_issue_raw(wsi, NULL, 0) < 0) {
92 lwsl_wsi_info(wsi, "signalling to close");
98 if (lwsi_state(wsi) == LRS_FLUSHING_BEFORE_CLOSE) {
99 wsi->socket_is_permanently_unusable = 1;
106 if (wsi->http.comp_ctx.buflist_comp ||
107 wsi->http.comp_ctx.may_have_more) {
110 lwsl_wsi_info(wsi, "compl comp partial (buflist_comp %p, may %d)",
111 wsi->http.comp_ctx.buflist_comp,
112 wsi->http.comp_ctx.may_have_more);
114 if (lws_rops_fidx(wsi->role_ops, LWS_ROPS_write_role_protocol) &&
115 lws_rops_func_fidx(wsi->role_ops, LWS_ROPS_write_role_protocol).
116 write_role_protocol(wsi, NULL, 0, &wp) < 0) {
117 lwsl_wsi_info(wsi, "signalling to close");
120 lws_callback_on_writable(wsi);
131 if (wsi->http.cgi) {
134 if (lws_change_pollfd(wsi, LWS_POLLOUT, 0)) {
135 lwsl_wsi_info(wsi, "failed at set pollfd");
142 /* if we got here, we should have wire protocol ops set on the wsi */
143 assert(wsi->role_ops);
145 if (!lws_rops_fidx(wsi->role_ops, LWS_ROPS_handle_POLLOUT))
148 n = lws_rops_func_fidx(wsi->role_ops, LWS_ROPS_handle_POLLOUT).
149 handle_POLLOUT(wsi);
168 if (lws_change_pollfd(wsi, LWS_POLLOUT, 0)) {
169 lwsl_wsi_info(wsi, "failed at set pollfd");
177 if (!eff && wsi->leave_pollout_active) {
182 lwsl_wsi_debug(wsi, "leave_pollout_active");
183 if (lws_change_pollfd(wsi, 0, LWS_POLLOUT)) {
184 lwsl_wsi_info(wsi, "failed at set pollfd");
192 if (lwsi_role_client(wsi) && !wsi->hdr_parsing_completed &&
193 lwsi_state(wsi) != LRS_H2_WAITING_TO_SEND_HEADERS &&
194 lwsi_state(wsi) != LRS_ISSUE_HTTP_BODY)
205 if (lws_rops_fidx(wsi->role_ops, LWS_ROPS_perform_user_POLLOUT)) {
206 if (lws_rops_func_fidx(wsi->role_ops,
208 perform_user_POLLOUT(wsi) == -1)
214 lwsl_wsi_debug(wsi, "non mux: wsistate 0x%lx, ops %s",
215 (unsigned long)wsi->wsistate, wsi->role_ops->name);
217 vwsi = (volatile struct lws *)wsi;
220 n = lws_callback_as_writeable(wsi);
224 if (lws_change_pollfd(wsi, 0, LWS_POLLOUT))
248 lws_rxflow_cache(struct lws *wsi, unsigned char *buf, size_t n, size_t len)
250 struct lws_context_per_thread *pt = &wsi->a.context->pt[(int)wsi->tsi];
256 blen = lws_buflist_next_segment_len(&wsi->buflist, &buffered);
267 lws_buflist_use_segment(&wsi->buflist, blen - len);
268 lwsl_wsi_debug(wsi, "trim existing rxflow %d -> %d",
278 lwsl_wsi_debug(wsi, "rxflow append %d", (int)(len - n));
279 m = lws_buflist_append_segment(&wsi->buflist, buf + n, len - n);
284 lwsl_wsi_debug(wsi, "added to rxflow list");;
285 if (lws_dll2_is_detached(&wsi->dll_buflist))
286 lws_dll2_add_head(&wsi->dll_buflist, &pt->dll_buflist_owner);
357 * 4) If there is any wsi with rxflow buffered and in a state to process
362 struct lws *wsi = lws_container_of(d, struct lws, dll_buflist);
364 if (!lws_is_flowcontrolled(wsi) &&
365 lwsi_state(wsi) != LRS_DEFERRING_ACTION)
384 lws_buflist_aware_read(struct lws_context_per_thread *pt, struct lws *wsi,
390 // lwsl_debug("%s: %s: %s: prior %d\n", __func__, lws_wsi_tag(wsi), hint, prior);
391 // lws_buflist_describe(&wsi->buflist, wsi, __func__);
397 (unsigned int)ebuf->len > wsi->a.context->pt_serv_buf_size - LWS_PRE)
398 ebuf->len = (int)(wsi->a.context->pt_serv_buf_size - LWS_PRE);
405 if (wsi->mux_substream)
410 bns = (int)lws_buflist_next_segment_len(&wsi->buflist, &ebuf->token);
419 ebuf->len = n = lws_ssl_capable_read(wsi, ep, (size_t)e);
421 lwsl_wsi_debug(wsi, "%s: ssl_capable_read %d", hint, ebuf->len);
443 n = lws_buflist_append_segment(&wsi->buflist, ebuf->token, (size_t)ebuf->len);
446 if (n && lws_dll2_is_detached(&wsi->dll_buflist))
447 lws_dll2_add_head(&wsi->dll_buflist,
472 lws_buflist_aware_finished_consuming(struct lws *wsi, struct lws_tokens *ebuf,
475 struct lws_context_per_thread *pt = &wsi->a.context->pt[(int)wsi->tsi];
484 if (wsi->buflist) {
485 m = (int)lws_buflist_use_segment(&wsi->buflist,
491 lwsl_wsi_info(wsi, "removed from dll_buflist");
492 lws_dll2_remove(&wsi->dll_buflist);
500 m = lws_buflist_append_segment(&wsi->buflist,
506 lwsl_wsi_debug(wsi, "added to rxflow list");
507 if (lws_dll2_is_detached(&wsi->dll_buflist))
508 lws_dll2_add_head(&wsi->dll_buflist,
533 struct lws *wsi = lws_container_of(d, struct lws, dll_buflist);
539 lwsl_wsi_debug(wsi, "rxflow processing: fc=%d, 0x%lx",
540 lws_is_flowcontrolled(wsi),
541 (unsigned long)wsi->wsistate);
543 if (!lws_is_flowcontrolled(wsi) &&
544 lwsi_state(wsi) != LRS_DEFERRING_ACTION) {
547 if (lws_rops_func_fidx(wsi->role_ops,
549 handle_POLLIN(pt, wsi, &pfd) ==
551 lws_close_free_wsi(wsi, LWS_CLOSE_STATUS_NOSTATUS,
581 * 1) If there is any wsi with a buflist and in a state to process
586 struct lws *wsi = lws_container_of(d, struct lws, dll_buflist);
588 if (!lws_is_flowcontrolled(wsi) &&
589 lwsi_state(wsi) != LRS_DEFERRING_ACTION) {
610 struct lws *wsi = lws_container_of(p, struct lws,
613 if (wsi->position_in_fds_table >= 0) {
615 pt->fds[wsi->position_in_fds_table].revents = (short)(
616 pt->fds[wsi->position_in_fds_table].revents |
617 (pt->fds[wsi->position_in_fds_table].events &
619 if (pt->fds[wsi->position_in_fds_table].revents &
622 * We're not going to remove the wsi from the
642 struct lws *wsi;
664 wsi = wsi_from_fd(context, pollfd->fd);
665 if (!wsi)
670 if (wsi->undergoing_init_from_other_pt)
673 * this wsi right now for use on our service thread.
691 wsi->socket_is_permanently_unusable = 1;
697 if (!lws_buflist_total_len(&wsi->buflist)) {
701 * so acknowledge the wsi is done
704 lwsl_wsi_debug(wsi, "Session Socket %d dead",
715 lws_set_timeout(wsi, PENDING_TIMEOUT_CLOSE_ACK, 3);
721 wsi->sock_send_blocking = FALSE;
725 if (lwsi_state(wsi) == LRS_SHUTDOWN &&
726 lws_is_ssl(wsi) && wsi->tls.ssl) {
727 switch (__lws_tls_shutdown(wsi)) {
741 wsi->tls_read_wanted_write) {
743 * If this wsi has a pending WANT_WRITE from SSL_read(), it has
749 wsi->tls_read_wanted_write = 0;
755 wsi->could_have_pending = 0; /* clear back-to-back write detection */
760 /* if we got here, we should have wire protocol ops set on the wsi */
761 assert(wsi->role_ops);
763 // lwsl_notice("%s: %s: wsistate 0x%x\n", __func__, wsi->role_ops->name,
764 // wsi->wsistate);
766 switch (lws_rops_func_fidx(wsi->role_ops, LWS_ROPS_handle_POLLIN).
767 handle_POLLIN(pt, wsi, pollfd)) {
775 // wsi->role_ops->name);
777 lwsl_wsi_debug(wsi, "Close and handled");
778 lws_close_free_wsi(wsi, LWS_CLOSE_STATUS_NOSTATUS,
787 lws_close_free_wsi(wsi, LWS_CLOSE_STATUS_NOSTATUS,
806 lws_callback_on_writable(wsi);