Uploaded image for project: 'Qpid Dispatch'
  1. Qpid Dispatch
  2. DISPATCH-1271

The LWS_CALLBACK_USER handler in http-libwebsockets.c is never triggered

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.5.0
    • None
    • None
    • None

    Description

              lws_callback_all_protocol(hs->context, &protocols[1], LWS_CALLBACK_USER);
              lws_callback_all_protocol(hs->context, &protocols[2], LWS_CALLBACK_USER);
      

      The problem is that lws_callback_all_protocol compares pointers to protocol structs with protocol parameter. They are never equal, because early on in listener_start, lws_create_vhost gets called, and it allocates a copy of the protocols array only for that vhost.

      I expected that this will cause dispatch not to send heartbeats to clients connected over amqpws (since pn_transport_tick is not called). I tested that with qpid-jms, and it turned out that the heartbeats are flowing correctly. In other words, I am not aware of any user-visible bug caused by this. Is calling _tick unnecessary? What is it there for? I saw that dispatch is not sending its own heartbeats on the amqpws connections.

      LWS_VISIBLE int
      lws_callback_all_protocol(struct lws_context *context,
      			  const struct lws_protocols *protocol, int reason)
      {
      	struct lws_context_per_thread *pt = &context->pt[0];
      	unsigned int n, m = context->count_threads;
      	struct lws *wsi;
      
      	while (m--) {
      		for (n = 0; n < pt->fds_count; n++) {
      			wsi = wsi_from_fd(context, pt->fds[n].fd);
      			if (!wsi)
      				continue;
      			if (wsi->protocol == protocol)
      				protocol->callback(wsi, reason, wsi->user_space,
      						   NULL, 0);
      		}
      		pt++;
      	}
      
      	return 0;
      }
      
      LWS_VISIBLE struct lws_vhost *
      lws_create_vhost(struct lws_context *context,
      		 const struct lws_context_creation_info *info)
      {
          [...]
          
      	/*
      	 * give the vhost a unified list of protocols including the
      	 * ones that came from plugins
      	 */
      	lwsp = lws_zalloc(sizeof(struct lws_protocols) * (vh->count_protocols +
      				   context->plugin_protocol_count + 1),
      			  "vhost-specific plugin table");
      	if (!lwsp) {
      		lwsl_err("OOM\n");
      		return NULL;
      	}
      
      	m = vh->count_protocols;
      	memcpy(lwsp, pcols, sizeof(struct lws_protocols) * m);
      
          [...]
      
      	if (
      #ifdef LWS_WITH_PLUGINS
      	    (context->plugin_list) ||
      #endif
      	    context->options & LWS_SERVER_OPTION_EXPLICIT_VHOSTS)
      		vh->protocols = lwsp;
      	else {
      		vh->protocols = pcols;
      		lws_free(lwsp);
      	}
      
          [...]
      }
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jdanek Jiri Daněk
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: