rem: LOG(L_ERR,"ERROR:do_read: invalid message length read %u\n" ,len);
add: LOG(L_ERR,"ERROR:do_read (sock=%d): invalid message " "length read %u (%x)\n",p->sock,len,p->first_4bytes);
context: inline static int do_read( struct peer *p){	unsigned char  *ptr;	unsigned int   wanted_len, n, len;	str s;	if (p->buf==0) {		wanted_len = sizeof(p->first_4bytes) - p->buf_len;		ptr = ((unsigned char*)&(p->first_4bytes)) + p->buf_len;	} else {		wanted_len = p->first_4bytes - p->buf_len;		ptr = p->buf + p->buf_len;	}	while( (n=recv( p->sock, ptr, wanted_len, MSG_DONTWAIT ))>0 ) {		//DBG(">>>>>> read -> n=%d (expected=%d)\n",n,wanted_len);		p->buf_len += n;		if (n<wanted_len) {			//DBG("only %d bytes read from %d expected\n",n,wanted_len);			wanted_len -= n;			ptr += n;		} else {			if (p->buf==0) {				/* I just finished reading the the first 4 bytes from msg */				len = ntohl(p->first_4bytes)&0x00ffffff;				if (len<AAA_MSG_HDR_SIZE || len>MAX_AAA_MSG_SIZE) {					LOG(L_ERR,"ERROR:do_read: invalid message length read %u\n"						,len);					goto error;				}				//DBG("message length = %d(%x)\n",len,len);				if ( (p->buf=shm_malloc(len))==0  ) {					LOG(L_ERR,"ERROR:do_read: no more free memory\n");					goto error;				}				*((unsigned int*)p->buf) = p->first_4bytes;				p->buf_len = sizeof(p->first_4bytes);				p->first_4bytes = len;				/* update the reading position and len */				ptr = p->buf + p->buf_len;				wanted_len = p->first_4bytes - p->buf_len;			} else {				/* I finished reading the whole message */				DBG("DEBUG:do_read: whole message read (len=%d)!\n",					p->first_4bytes);				s.s   = p->buf;				s.len = p->buf_len;				/* reset the read buffer */				p->buf = 0;				p->buf_len = 0;				p->first_4bytes = 0;				/* process the mesage */				dispatch_message( p, &s);				break;			}		}	}	//DBG(">>>>>>>>>> n=%d, errno=%d \n",n,errno);	if (n==0 || (n==-1 && errno!=EINTR && errno!=EAGAIN) ) {		LOG(L_ERR,"ERROR:do_read: n=%d , errno=%d\n",n,errno);		goto error;	}	return 1;error:	return -1;}