On 07/15/2015 05:40 AM, Team Zaga wrote:
> Dear all, I am trying to code consensus algorithm. When one of my server
> trying to send message to all other servers, (my cluster has 3 server).
> There is one server received right buffer. The other one received wrong
> buffer.
> The code to check and send just like bellow:
> void on_recv(uv_udp_t* handle, ssize_t nread,const uv_buf_t *buf,const
> struct sockaddr* recv_addr, unsigned flags)
> {
>
> if (nread > 0) {
> printf("Recv %d %d\n",buf->len,nread);
> for (int i = 0; i < nread; i++)
> printf("0x%2x\t",(unsigned char)buf->base[i]);
> printf("\n");
> }
> }
> void request_sending(clusterMsg sendRequest,uv_idle_t* handle,char
> ip[vIMDB_IP_STR_LEN],int port){
> ...
>
> printf("Send %d\n",buf.len);
> for (int i = 0; i < buf.len; i++)
> printf("0x%2x\t",(unsigned char)buf.base[i]);
> printf("\n");
> uv_udp_send(specific_req,server_uv,&buf,buf_count,(const struct
> sockaddr*) &recv_addr,send_cb);
>
> return;
> }
> Because my code is quite long, I only show a part.
> Please tell me, what reason can cause this bug?
> Thank you so much
> It's impossible to tell given the small amount of code you've shown. Are you using a single send request or one for each time you send the data? (you need the latter). Are you reusing the buffer? If so, are you sure the memory stays valid until all send requests have been completed? -- Saúl Ibarra Corretgé bettercallsaghul.com -- You received this message because you are subscribed to the Google Groups "libuv" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/libuv. For more options, visit https://groups.google.com/d/optout.
signature.asc
Description: OpenPGP digital signature
