Lines Matching defs:wsi

24  * This role for wrapping dbus fds in a wsi + role is unusual in that the
25 * wsi it creates and binds to the role do not have control over the related fd
31 * create a lightweight "shadow" wsi for any fd from dbus that has a POLLIN or
33 * destroy the wsi, since this is indistinguishable from dbus close path
35 * worries we create a new shadow wsi until it looks like it is closing again.
43 * retreives existing or creates new shadow wsi for fd owned by dbus stuff.
51 struct lws *wsi;
61 wsi = wsi_from_fd(ctx->vh->context, fd);
62 if (wsi) {
63 assert(wsi->opaque_parent_data == ctx);
65 return wsi;
71 lws_context_assert_lock_held(wsi->a.context);
72 lws_vhost_assert_lock_held(wsi->a.vhost);
75 wsi = __lws_wsi_create_with_role(ctx->vh->context, ctx->tsi, NULL,
77 if (wsi == NULL) {
82 lwsl_info("%s: creating shadow wsi\n", __func__);
84 wsi->desc.sockfd = fd;
85 lws_role_transition(wsi, 0, LRS_ESTABLISHED, &role_ops_dbus);
86 wsi->a.protocol = ctx->vh->protocols;
87 wsi->shadow = 1;
88 wsi->opaque_parent_data = ctx;
92 &wsi->lc, "dbus|%s", ctx->vh->name);
94 lws_vhost_bind_wsi(ctx->vh, wsi);
95 if (__insert_wsi_socket_into_fds(ctx->vh->context, wsi)) {
96 lwsl_err("inserting wsi socket into fds failed\n");
97 __lws_vhost_unbind_wsi(wsi); /* cx + vh lock */
98 lws_free(wsi);
102 return wsi;
110 __lws_shadow_wsi_destroy(struct lws_dbus_ctx *ctx, struct lws *wsi)
112 lwsl_info("%s: destroying shadow wsi\n", __func__);
114 lws_context_assert_lock_held(wsi->a.context);
115 lws_vhost_assert_lock_held(wsi->a.vhost);
117 if (__remove_wsi_socket_from_fds(wsi)) {
119 wsi->desc.sockfd);
124 __lws_vhost_unbind_wsi(wsi);
126 lws_free(wsi);
154 struct lws *wsi;
160 wsi = __lws_shadow_wsi(ctx, w, dbus_watch_get_unix_fd(w), 1);
161 if (!wsi) {
164 lwsl_err("%s: unable to get wsi\n", __func__);
190 lws_wsi_tag(wsi), w, dbus_watch_get_unix_fd(w),
194 __lws_change_pollfd(wsi, 0, (int)lws_flags);
204 __check_destroy_shadow_wsi(struct lws_dbus_ctx *ctx, struct lws *wsi)
208 if (!wsi)
215 __lws_shadow_wsi_destroy(ctx, wsi);
236 struct lws *wsi;
242 wsi = __lws_shadow_wsi(ctx, w, dbus_watch_get_unix_fd(w), 0);
243 if (!wsi)
265 __lws_change_pollfd(wsi, (int)lws_flags, 0);
471 * If it removes the watcher and we remove the wsi and fd entry before this,
472 * actually we can no longer map the fd to this invalidated wsi pointer to call
477 rops_handle_POLLIN_dbus(struct lws_context_per_thread *pt, struct lws *wsi,
481 (struct lws_dbus_ctx *)wsi->opaque_parent_data;
495 * wsi. wsi->opaque_parent_data is the watcher handle bound to the wsi
511 __check_destroy_shadow_wsi(ctx, wsi);