Page MenuHomePhabricator

Incorrect return value checks in collector component of webstatscollector
Open, MediumPublic

Description

from IRC conversation with Brandon Black:
<bblack> I did notice there are a number of obvious bugs in the collector source, but they're unlikely to have a big effect most of the time
<bblack> e.g. you'll see this pattern in a few places:
<bblack> /* Process incoming UDP queue */
<bblack> while(( fds[0].revents & POLLIN ) &&
<bblack> ((l=recvfrom(s,&buf,1500,0,NULL,NULL))!=-1)) {
<bblack> if (l==EAGAIN)
<bblack> break;
<bblack> handleMessage((char *)&buf,l);
<bblack> }
<bblack> "l" (return value from recvfrom() or similar network calls) will never be EAGAIN. you would actually check for errno==EAGAIN when l==-1
<bblack> so those EAGAIN / EWOULDBLOCK checks are just wrong
<bblack> actually I think the way that code ends up working, it's skipping any packet it receives that is 11 bytes in length (because EAGAIN happens to be error code 11), and then again also not handling the true EAGAIN case very well (but well enough, since the outer loop is simple)


Version: unspecified
Severity: normal

Details

Reference
bz54303

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 1:59 AM
bzimport set Reference to bz54303.
bzimport added a subscriber: Unknown Object (MLST).