[Libwebsockets] emulated_poll breaks on disabled sockets on Windows XP

Graham Newton gnewton at peavey-eu.com
Fri Nov 8 15:22:45 CET 2013


A common practise to temporarily disable a socket in a poll call is to 
negate the socket fd.  poll should then ignore the socket.
emulated_poll does this with the following code:
         if (poll_fd->fd < 0 || !poll_fd->events)
             goto skip1;

However on Windows the fd field in WSAPOLLFD is unsigned int!!!  So the 
check for a negative fd value always fails.
This results in select returning an error with an error code of 10038 -- 
Socket operation on nonsocket.
The fix is to type cast fd like so:
if ((int)poll_fd->fd < 0 || !poll_fd->events)

This may be the cause of some high CPU load reports.  I noticed the load 
being 50% with my application running on Windows XP.

Regards
Graham

-- 
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/20131108/afa21f44/attachment.html>


More information about the Libwebsockets mailing list