@ -354,6 +354,12 @@ static void parse_client_msg(cdata_t *cdata, client_instance_t *client)
json_t * val ;
json_t * val ;
retry :
retry :
if ( unlikely ( client - > bufofs > MAX_MSGSIZE ) ) {
LOGNOTICE ( " Client id % " PRId64 " fd %d overloaded buffer without EOL, disconnecting " ,
client - > id , client - > fd ) ;
invalidate_client ( ckp , cdata , client ) ;
return ;
}
buflen = PAGESIZE - client - > bufofs ;
buflen = PAGESIZE - client - > bufofs ;
/* This read call is non-blocking since the socket is set to O_NOBLOCK */
/* This read call is non-blocking since the socket is set to O_NOBLOCK */
ret = read ( client - > fd , client - > buf + client - > bufofs , buflen ) ;
ret = read ( client - > fd , client - > buf + client - > bufofs , buflen ) ;
@ -368,14 +374,8 @@ retry:
client - > bufofs + = ret ;
client - > bufofs + = ret ;
reparse :
reparse :
eol = memchr ( client - > buf , ' \n ' , client - > bufofs ) ;
eol = memchr ( client - > buf , ' \n ' , client - > bufofs ) ;
if ( ! eol ) {
if ( ! eol )
if ( unlikely ( client - > bufofs > MAX_MSGSIZE ) ) {
LOGWARNING ( " Client fd %d overloaded buffer without EOL, disconnecting " , client - > fd ) ;
invalidate_client ( ckp , cdata , client ) ;
return ;
}
goto retry ;
goto retry ;
}
/* Do something useful with this message now */
/* Do something useful with this message now */
buflen = eol - client - > buf + 1 ;
buflen = eol - client - > buf + 1 ;