#define _GNU_SOURCE
#include <stdlib.h>
#include <sys/types.h>
#include <stddef.h>
#include <dlfcn.h>
#include <errno.h>

static ssize_t (*real_send)(int s, const void *buf, size_t n, int flags) = NULL;

__attribute__((constructor))
void
lib_init(void)
{
	real_send = dlsym(RTLD_NEXT,"send");
}

int
send(int s, const void *buf, size_t n, int flags)
{
	if (n == 64 && rand() % 10 == 0)
	{
		errno = EAGAIN;
		return -1;
	}
	return real_send(s, buf, n, flags);
}
