[Libwebsockets] FW: pollfd->revents == 0

Bekiares Tyrone-CTB041 Tyrone.Bekiares at motorolasolutions.com
Thu Jul 24 17:11:08 CEST 2014


Hi Andy,

I tried your proposed fix, and the server becomes unresponsive (Chrome initiates several connections, but no files appear to actually be served out). It seems that checking for new_wsi==NULL after some processing has been done appears to be leaving something in an indeterminate state?

Treating (networkevents.lNetworkEvents == 0) like a timeout in lws_plat_service seems to work (so far).

I did find this article on stackoverflow (http://stackoverflow.com/questions/12268811/wsaeventselect-zero-event) which seems to suggest that ignoring it is a reasonable approach?

Thoughts?
Ty

-----Original Message-----
From: Andy Green [mailto:extracats at googlemail.com] On Behalf Of Andy Green
Sent: Wednesday, July 23, 2014 7:47 PM
To: Bekiares Tyrone-CTB041; libwebsockets at ml.libwebsockets.org
Subject: Re: [Libwebsockets] FW: pollfd->revents == 0



On 07/24/2014 05:01 AM, Bekiares Tyrone-CTB041 wrote:
> Check that:
>
>>> 	if (networkevents.lNetworkEvents == 0)
>>> 		return 0;
>
> -----Original Message-----
> From: Bekiares Tyrone-CTB041
> Sent: Wednesday, July 23, 2014 3:52 PM
> To: 'libwebsockets at ml.libwebsockets.org'
> Subject: RE: FW: pollfd->revents == 0
>
> As I workaround, I added:
>
> LWS_VISIBLE int
> lws_plat_service(struct libwebsocket_context *context, int timeout_ms) {
> 	...
>
> 	if (WSAEnumNetworkEvents(pfd->fd,
> 			context->events[ev - WSA_WAIT_EVENT_0],
> 					      &networkevents) == SOCKET_ERROR) {
> 		lwsl_err("WSAEnumNetworkEvents() failed with error %d\n",
> 								     LWS_ERRNO);
> 		return -1;
> 	}
>
>>> 	if (pfd->revents == 0)
>>> 		return 0;
>
> 	...
> }
>
> Which seems to resolve the issue. Thoughts?

Thanks.  Can you check if this also makes the problem go away instead of your workaround?

diff --git a/lib/server.c b/lib/server.c index 5f8749f..d6a65cf 100644
--- a/lib/server.c
+++ b/lib/server.c
@@ -731,8 +731,10 @@ int lws_server_socket_service(struct libwebsocket_context *context,
                 break;
         }

-       if (lws_server_socket_service_ssl(context, &wsi, new_wsi, 
accept_fd, pollfd))
-               goto fail;
+       if (new_wsi)
+               if (lws_server_socket_service_ssl(context, &wsi, new_wsi,
+                                                 accept_fd, pollfd))
+                       goto fail;

         return 0;


-Andy


> tb
>
> -----Original Message-----
> From: Bekiares Tyrone-CTB041
> Sent: Wednesday, July 23, 2014 3:37 PM
> To: 'libwebsockets at ml.libwebsockets.org'
> Subject: RE: FW: pollfd->revents == 0
>
> Just to add some additional detail, I'm linking against the 1.0.1h version of OpenSSL.
>
> If I run the server without "-s", it works fine. I only see this error in SSL mode. I'm using the included demo cert and key.
>
> wsi->mode=LWS_CONNMODE_SERVER_LISTENER, but pollfd->revents=0, causing the crash.
>
> Any idea what could cause this?
>
> Thx,
> Ty
>
> -----Original Message-----
> From: Bekiares Tyrone-CTB041
> Sent: Wednesday, July 23, 2014 12:40 PM
> To: 'libwebsockets at ml.libwebsockets.org'
> Subject: FW: pollfd->revents == 0
>
> Hi,
>
> I'm using libwebsockets 1.3, compiled using VS2013Update2 for Win32, run under Win7/64. I am connecting from Chrome 36 via SSL to the included test-server app.  I am serving out a .html page which references a few .js and .css files.
>
> The first 2 files are transferred properly, the third crashes in lws_server_socket_service_ssl() because  new_wsi is NULL. If I trace the crash, lws_server_socket_service is not creating a new new_wsi prior to calling lws_server_socket_service_ssl because (pollfd->revents & LWS_POLLIN) == 0 when lws_server_socket_service is called.
>
> There does not appear to be a check for pollfd->revents==0 inside libwebsocket_service_fd (which calls lws_server_socket_service). Should there be? Is pollfd->revents==0 expected?
>
> Has anyone else experienced this?
>
> Thanks!
> Ty
>
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> http://ml.libwebsockets.org/mailman/listinfo/libwebsockets
>



More information about the Libwebsockets mailing list