[Libwebsockets] SegFault for Websocket Server on Multiple Network Interface

Andy Green andy at warmcat.com
Mon Jul 17 19:24:25 CEST 2017



On 07/17/2017 08:26 PM, techi eth wrote:
> Please find attached patch over test_server.Base test server code work 
> fine with one interface but with two interface i am seeing problem.
> Please check attached patch & point me for issue.I have run below 
> command to start test server.

It's good to know if the test server works OK for you as-is.

Destroying the vhost during service is probably going to make trouble, 
because the caller may hold pointers to it if nothing else.

+		case LWS_CALLBACK_ESTABLISHED :
+			lws_get_peer_simple(wsi,IPAddrBuf,32);
+			printf ("fWebsocketWrapServer1CB : LWS_CALLBACK_ESTABLISHED,Client 
IP=%s,Socket ID =%d\n",IPAddrBuf,lws_get_socket_fd(wsi));
+			printf("Calling LWS VHOST DESTROY\n");
+			lws_vhost_destroy(vhost1);

Why don't you follow what the test server does and create and destroy 
the vhosts outside of the service.

-		if (dynamic_vhost_enable && !dynamic_vhost) {
-			lwsl_notice("creating dynamic vhost...\n");
-			dynamic_vhost = lws_create_vhost(context, &info);
-		} else
-			if (!dynamic_vhost_enable && dynamic_vhost) {
-				lwsl_notice("destroying dynamic vhost...\n");
-				lws_vhost_destroy(dynamic_vhost);
-				dynamic_vhost = NULL;
-			}
+//		if (dynamic_vhost_enable && !dynamic_vhost) {
+//			lwsl_notice("creating dynamic vhost...\n");
+//			dynamic_vhost = lws_create_vhost(context, &info);
+//		} else
+//			if (!dynamic_vhost_enable && dynamic_vhost) {
+//				lwsl_notice("destroying dynamic vhost...\n");
+//				lws_vhost_destroy(dynamic_vhost);
+//				dynamic_vhost = NULL;
+//	

-Andy



More information about the Libwebsockets mailing list