[Libwebsockets] HTTP Server sockets not closed on HUP

"Andy Green (林安廸)" andy at warmcat.com
Mon Nov 4 02:49:32 CET 2013


On 28/10/13 21:38, the mail apparently from Graham Newton included:
> I am using libwebsockets on Windows 7 in external poll mode.
> I am finding that if I present a socket fd on a normal HTTP connection
> (LWS_CONNMODE_HTTP_SERVING:) to libwebsocket_service_fd with just a HUP
> event, the event doesn't get handled but revents gets cleared indicating
> that the event has been handled.  Should it be handled in the same way
> as LWS_CONNMODE_WS_SERVING?
> Maybe like this?

I see... thanks for pointing it out.

I adapted this slightly to just always check for that case outside the 
switch.

http://git.libwebsockets.org/cgi-bin/cgit/libwebsockets/commit/?id=b1aa1d3389416f44b1aab9b9255e4737fe91d5ec

it seemed to be okay here on the test apps.

-Andy

>      /* okay, what we came here to do... */
>
>      switch (wsi->mode) {
>
> #ifndef LWS_NO_SERVER
>      case LWS_CONNMODE_HTTP_SERVING:
>      case LWS_CONNMODE_HTTP_SERVING_ACCEPTED:
>      case LWS_CONNMODE_SERVER_LISTENER:
>      case LWS_CONNMODE_SSL_ACK_PENDING:
>          /*** Inserted ************************************/
>          if ((!(pollfd->revents & POLLIN)) &&
>                  (pollfd->revents & (POLLERR | POLLHUP))) {
>
>              lwsl_debug("Session Socket %p (fd=%d) dead\n",
>                  (void *)wsi, pollfd->fd);
>
>              goto close_and_handled;
>          }
>          /*************************************************/
>          n = lws_server_socket_service(context, wsi, pollfd);
>          goto handled;
> #endif
>
>      case LWS_CONNMODE_WS_SERVING:
>      case LWS_CONNMODE_WS_CLIENT:
>
>          /* handle session socket closed */
>
>          if ((!(pollfd->revents & POLLIN)) &&
>                  (pollfd->revents & (POLLERR | POLLHUP))) {
>
>              lwsl_debug("Session Socket %p (fd=%d) dead\n",
>                  (void *)wsi, pollfd->fd);
>
>              goto close_and_handled;
>          }
>
> Regards
> Graham
> p.s. I think libwebsockets is an excellent library for lightweight
> websockets support especially for embedded systems.
>
> --
> Graham Newton
> Senior Software Engineer
> ------------------------------------------------------------------------
> Peavey Digital Research
> A Division of Peavey Electronics Corporation
>
>
> Phone 	+44 1865 734397
> Direct 	+44 1865 734397
> Email 	gnewton at peavey-eu.com
> Web 	www.peaveycommercialaudio.com
> <http://www.peaveycommercialaudio.com> - mm.peavey.com
> <http://mm.peavey.com> - www.crestaudio.com <http://www.crestaudio.com>
> - aa.peavey.com <http://aa.peavey.com> - www.peaveyoxford.com
> <http://www.peaveyoxford.com>
>
>
> *PEAVEY COMMERCIAL AUDIO* - Great Folds Road, Corby, Northamptonshire,
> NN18 9ET UK
> *PEAVEY DIGITAL RESEARCH* - 6 Elm Place, Eynsham, Oxfordshire OX29 4BD UK
> *PEAVEY ITALIA* - Via P.La Torre 21, Zona Ind.le Cerretano, 60022
> Castelfidardo An, Italy
> *PEAVEY CHINA* - 1F Taiping Yaoye, 3 Gongye Wu Lu, Shekou, Shenzhen
> China 518067
> *PEAVEY ELECTRONICS CORPORATION* - 5022 Hartley Peavey Drive, Meridian,
> MS 39305 USA
>
>
> Peavey Electronics Limited is a registered company in England & Wales,
> Company Registration No.: 01249126
> Registered office: GREAT FOLDS ROAD OAKLEY HAY CORBY NORTHAMPTONSHIRE.
> NN18 9ET
>
>
>
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> http://ml.libwebsockets.org/mailman/listinfo/libwebsockets
>




More information about the Libwebsockets mailing list