ndb -

  Fix bug wrt to '\r' handling in latest commit to bug#24011
parent c8d07748
...@@ -47,15 +47,9 @@ SocketInputStream::gets(char * buf, int bufLen) { ...@@ -47,15 +47,9 @@ SocketInputStream::gets(char * buf, int bufLen) {
int res = readln_socket(m_socket, m_timeout, buf, bufLen - 1); int res = readln_socket(m_socket, m_timeout, buf, bufLen - 1);
if(res == -1) if(res == -1)
return 0; return 0;
if(res == 0 && buf[0] == 77){ // select return 0 if(res == 0 && buf[0] == 77)
{ // select return 0
buf[0] = 0; buf[0] = 0;
} else if(res == 0 && buf[0] == 0){ // only newline
buf[0] = '\n';
buf[1] = 0;
} else {
int len = strlen(buf);
buf[len + 1] = '\0';
buf[len] = '\n';
} }
return buf; return buf;
} }
...@@ -98,6 +98,11 @@ readln_socket(NDB_SOCKET_TYPE socket, int timeout_millis, ...@@ -98,6 +98,11 @@ readln_socket(NDB_SOCKET_TYPE socket, int timeout_millis,
ptr += t; ptr += t;
len -= t; len -= t;
} }
if (i > 0 && buf[i-1] == '\r')
{
buf[i-1] = '\n';
ptr--;
}
ptr[0]= 0; ptr[0]= 0;
return ptr - buf; return ptr - buf;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment