Improve sendto(2) error log messages

This commit is contained in:
Andrew Bettison 2013-11-22 11:52:11 +10:30
parent 9ddcfb87aa
commit e92e7cb65e
3 changed files with 7 additions and 3 deletions

View File

@ -137,7 +137,7 @@ int overlay_mdp_send(int mdp_sockfd, overlay_mdp_frame *mdp, int flags, int time
mdp->packetTypeAndFlags=MDP_ERROR;
mdp->error.error=1;
snprintf(mdp->error.message,128,"Error sending frame to MDP server.");
return WHY_perror("sendto(f)");
return WHYF_perror("sendto(fd=%d,len=%zu,addr=%s)", mdp_sockfd, (size_t)len, alloca_sockaddr(&addr, addrlen));
} else {
if (!(flags&MDP_AWAITREPLY)) {
return 0;

View File

@ -982,7 +982,11 @@ int overlay_broadcast_ensemble(struct network_destination *destination, struct o
(struct sockaddr *)&destination->address, sizeof(destination->address));
ob_free(buffer);
if (sent!= len){
WHY_perror("sendto(c)");
WHYF_perror("sendto(fd=%d,len=%zu,addr=%s)",
interface->alarm.poll.fd,
(size_t)len,
alloca_sockaddr((struct sockaddr *)&destination->address, sizeof destination->address)
);
// close the interface if we had any error while sending broadcast packets,
// unicast packets should not bring the interface down
if (destination == interface->destination)

View File

@ -163,7 +163,7 @@ int overlay_mdp_reply(int sock,struct sockaddr_un *recvaddr, socklen_t recvaddrl
int r=sendto(sock,(char *)mdpreply,replylen,0,
(struct sockaddr *)recvaddr,recvaddrlen);
if (r<replylen) {
WHY_perror("sendto(d)");
WHYF_perror("sendto(fd=%d,len=%zu,addr=%s)", sock, (size_t)replylen, alloca_sockaddr((struct sockaddr *)recvaddr, recvaddrlen));
return WHYF("sendto() failed when sending MDP reply, sock=%d, r=%d", sock, r);
} else
if (0) DEBUGF("reply of %d bytes sent",r);