facebook/hhvm — pull request #3713 by idning (2014-09-10 05:19:21+00:00)
Title: fix fgets bug & redis sockReadLine bug

doc for ``fgets`` from php.net::

Reading ends when length - 1 bytes have been read, or a newline (which is included in the return value), or an EOF (whichever comes first). If no length is specified, it will keep reading from the stream until it reaches the end of the line.

3 situation when fgets return:

1. read got '\n'
2. eof
3. read length-1 bytes

**but in the code, there is one more situation** ::

m_writepos = filteredReadToBuffer();
m_readpos = 0;
if (bufferedLen() == 0) {
break; ///////////////////////// if read got 0 bytes
}

Socket::readImpl (hphp/runtime/base/socket.cpp) may return 0 bytes if ``poll`` got timeouted.

so fgets may return a string not endwith '\n'