コード例 #1
0
ファイル: tls_prng_egd.c プロジェクト: 10jschen/acl
int     tls_prng_egd_close(TLS_PRNG_SRC *egd)
{
    const char *myname = "tls_prng_egd_close";
    int     err;

    if (acl_msg_verbose)
	acl_msg_info("%s: close EGD server %s", myname, egd->name);
    err = acl_file_close(egd->fd.file);
    acl_myfree(egd->name);
    acl_myfree(egd);
    return (err);
}
コード例 #2
0
ファイル: tls_prng_dev.c プロジェクト: 1514louluo/acl
int     tls_prng_dev_close(TLS_PRNG_SRC *dev)
{
    const char *myname = "tls_prng_dev_close";
    int     err;

    if (acl_msg_verbose)
	acl_msg_info("%s: close entropy device %s", myname, dev->name);
    err = acl_file_close(dev->fd.file);
    acl_myfree(dev->name);
    acl_myfree(dev);
    return (err);
}
コード例 #3
0
ファイル: tls_prng_exch.c プロジェクト: aaronshang/acl
void    tls_prng_exch_close(TLS_PRNG_SRC *eh)
{
    const char *myname = "tls_prng_exch_close";

    if (acl_file_close(eh->fd.file) < 0)
	acl_msg_fatal("%s: close PRNG exchange file %s: %s",
		myname, eh->name, acl_last_serror());
    if (acl_msg_verbose)
	acl_msg_info("%s: closed PRNG exchange file %s", myname, eh->name);
    acl_myfree(eh->name);
    acl_myfree(eh);
}
コード例 #4
0
ファイル: tls_prng_file.c プロジェクト: DayBreakZhang/acl
int     tls_prng_file_close(TLS_PRNG_SRC *fh)
{
    const char *myname = "tls_prng_file_close";
    int     err;

    if (acl_msg_verbose)
	acl_msg_info("%s: close entropy file %s", myname, fh->name);
    err = acl_file_close(fh->fd.file);
    acl_myfree(fh->name);
    acl_myfree(fh);
    return (err);
}
コード例 #5
0
ファイル: acl_pipe.c プロジェクト: 1514louluo/acl
int acl_pipe(ACL_FILE_HANDLE fds[2])
{
	const char *myname = "acl_pipe";
	DWORD dwPipeMode;
	DWORD dwOpenMode;
	char name[250];
	SECURITY_ATTRIBUTES sa;
	static unsigned long id = 0;

	InterlockedIncrement(&id);

	sa.nLength = sizeof(sa);
	sa.bInheritHandle = TRUE;
	sa.lpSecurityDescriptor = NULL;

	/* Create the read/write end of the pipe */

	dwOpenMode = PIPE_ACCESS_DUPLEX;
	dwPipeMode = PIPE_WAIT; /* PIPE_NOWAIT; */
	snprintf(name, sizeof(name), "\\\\.\\pipe\\acl-pipe-%u-%lu-%lu",
		_getpid(), (unsigned long) acl_pthread_self(), id);
	fds[0] = CreateNamedPipe(name,
				dwOpenMode,
				dwPipeMode,
				1,            /* nMaxInstances */
				65536,        /* nOutBufferSize */
				65536,        /* nInBufferSize */
				1,            /* nDefaultTimeOut */
				&sa);

	/* Create the read/write end of the pipe */
	dwOpenMode = FILE_ATTRIBUTE_NORMAL;
	fds[1] = CreateFile(name,
				GENERIC_WRITE | GENERIC_READ,   /* access mode */
				0,               /* share mode */
				NULL,            /* Security attributes */
				OPEN_EXISTING,   /* dwCreationDisposition */
				dwOpenMode,      /* Pipe attributes */
				NULL);           /* handle to template file */

	if (fds[1] == ACL_FILE_INVALID) {
		acl_msg_error("%s(%d): CreateFile(%s) error(%s)",
			myname, __LINE__, name, acl_last_serror());
		acl_file_close(fds[0]);
		return (-1);
	}
	return (0);
}
コード例 #6
0
ファイル: fstream.cpp プロジェクト: aaronshang/acl
	bool fstream::close()
	{
		if (m_bOpened == false)
			return (false);

		if (m_pStream == NULL)
			return (true);

		if (m_pStream->type != ACL_VSTREAM_TYPE_FILE)
			return (false);

		ACL_FILE_HANDLE fh = ACL_VSTREAM_FILE(m_pStream);
		if (fh == ACL_FILE_INVALID)
			return (false);
		m_bEof = true;
		m_bOpened = false;
		return (acl_file_close(fh) == 0 ? true : false);
	}
コード例 #7
0
ファイル: main.c プロジェクト: 1514louluo/acl
int main(int argc, char *argv[])
{
	char  filename[256];
	int   ch, debug = 0;
	ssize_t max = 8192;
	ACL_FILE_HANDLE fd;

	snprintf(filename, sizeof(filename), "mmap.local");

	while ((ch = getopt(argc, argv, "hf:n:d")) > 0) {
		switch (ch) {
		case 'h':
			usage(argv[0]);
			return 0;
		case 'f':
			snprintf(filename, sizeof(filename), "%s", optarg);
			break;
		case 'n':
			max = atol(optarg);
			break;
		case 'd':
			debug = 1;
			break;
		default:
			break;
		}
	}

	acl_msg_stdout_enable(1);

	printf("filename: %s, max size: %ld\r\n", filename, (long) max);

	fd = acl_file_open(filename, O_RDWR | O_CREAT | O_TRUNC, 0600);

	if (fd  == ACL_FILE_INVALID) {
		printf("open %s error %s\r\n", filename, acl_last_serror());
		return 1;
	}

	test_string(fd, max, debug);

	acl_file_close(fd);
	return 0;
}
コード例 #8
0
ファイル: locker.cpp プロジェクト: 1514louluo/acl
locker::~locker()
{
	if (pFile_)
		acl_myfree(pFile_);
	if (myFHandle_ && fHandle_ != ACL_FILE_INVALID)
		acl_file_close(fHandle_);
	if (mutex_)
	{
#ifndef	ACL_WINDOWS
		(void) pthread_mutexattr_destroy(&mutex_attr_);
#endif
		(void) acl_pthread_mutex_destroy(mutex_);
		acl_myfree(mutex_);
	}
#ifdef	ACL_HAS_SPINLOCK
	if (spinlock_)
	{
		pthread_spin_destroy(spinlock_);
		acl_myfree_fn((void*) spinlock_);
	}
#endif
}
コード例 #9
0
ファイル: acl_pipe.c プロジェクト: 1514louluo/acl
int acl_pipe_close(ACL_FILE_HANDLE fds[2])
{
	return ((acl_file_close(fds[0]) == 0 && acl_file_close(fds[1]) == 0) ? 0 : -1);
}