Exemplo n.º 1
0
ssize_t sendto(int sockfd, const void *buf, size_t len, int flags,
                    const struct sockaddr *dest_addr, socklen_t addrlen) {

    bw_bytes += len;

    if (bw_mustDrop()) 
        return len;

    printf("bytes sent: %d\n",len);
    return __libc_sendto(sockfd, buf, len, flags, dest_addr, addrlen);
}
Exemplo n.º 2
0
ssize_t
__sock_sendto_r(int fd, const void *buf, size_t len, int flags, const struct sockaddr *addr,
		socklen_t alen)
{
	ssize_t ret = -1;

	pthread_cleanup_push_defer_np(__sock_putuser, &fd);
	if (__sock_getuser(fd)) {
		if ((ret = __sock_sendto(fd, buf, len, flags, addr, alen)) == -1)
			pthread_testcancel();
		__sock_putuser(&fd);
	} else {
		if ((ret = __libc_sendto(fd, buf, len, flags, addr, alen)) == -1)
			pthread_testcancel();
	}
	pthread_cleanup_pop_restore_np(0);
	return (ret);
}