[Libwebsockets] HTTP Server sockets not closed on HUP

Graham Newton gnewton at peavey-eu.com
Mon Oct 28 14:38:44 CET 2013


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?

     /* 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://libwebsockets.org/pipermail/libwebsockets/attachments/20131028/31405b75/attachment.html>


More information about the Libwebsockets mailing list