Example #1
0
int main(int argc, char **argv) {
	int fd, rv = 0, i, max;

	if (argc < 3) {
		printf("Use: oldtest host iterations\n");
		return 1;
	}

	fd = old_connect(argv[1], 2626);
	if (fd < 0) {
		perror("Error in connect");
		return 1;
	}

	max = atoi(argv[2]);
	printf("Number of iterations: %d\n", max);
	
	/* unlock, just in case it's locked, this makes testing easier */
	old_unlock(fd, "ABCD");

	for (i = 0; i < max; i++) {
		rv = old_lock(fd, "ABCD");
		if (unlikely(rv < 0))
			break;
		
		rv = old_unlock(fd, "ABCD");
		if (unlikely(rv < 0))
			break;
	}
	if (rv < 0)
		perror("ERROR");

	return 0;
}
Example #2
0
/* connect */
int connect(int fd, const struct sockaddr * name, socklen_t namelen)
{
	int ret;

	_libvpn_init();
	if(fd < _vpn_offset)
		return old_connect(fd, name, namelen);
	if(appclient_call(_appclient, (void **)&ret, "connect",
				fd - _vpn_offset)
			!= 0)
		return -1;
#ifdef DEBUG
	fprintf(stderr, "DEBUG: connect(%d) => %d\n", fd - VFS_OFFSET, ret);
#endif
	if(ret != 0)
		return _vpn_errno(_vpn_error, _vpn_error_cnt, -ret, 1);
	return ret;
}