Exemplo n.º 1
0
int closePipe(int pipe)
{
    Spipe *p = checkSpipeData(pipe);
    if(!p)
        return -1;

    int pid = getpid();

    enterProcessCriticalCode(pid);
    // лочим мютекс, блокируем io операции над пайпом
    lockMutex(&p->locker);
    free(p->memory);
    p->memory = 0;

    destroyWaitCond(p->ready_read_wid);
    destroyWaitCond(p->ready_write_wid);
    destroyWaitCond(p->fully_flushed_wid);
    destroyWaitCond(p->fully_empty_wid);
    unlockMutex(&p->locker);
    destroyMutex(&p->locker);

    freeSpipeData(p->id);
    leaveProcessCriticalCode(pid);

    return 0;
}
Exemplo n.º 2
0
static int suitebTest( const BOOLEAN isServer, const int testNo, 
					   const char *hostName, const int port, 
					   const int flags )
	{
	BOOLEAN isServerTest = FALSE;
	int value = testNo, status;

	if( value < 0 )
		{
		isServerTest = TRUE;
		value = -value;
		}

	/* Set up default argument values if required */
	if( hostName == NULL )
		hostName = "localhost";

	/* Run the test client or server */
	createMutex();
	if( isServer )
		status = suitebServer( value, hostName, port, flags, 
							   isServerTest );
	else
		status = suitebClient( value, hostName, port, flags, 
							   isServerTest );
	destroyMutex();
	return( status );
	}
Exemplo n.º 3
0
int testSessionRTCSServer( void )
	{
	int status;

	createMutex();
	acquireMutex();
	status = connectRTCS( CRYPT_SESSION_RTCS_SERVER, FALSE, FALSE );
	destroyMutex();

	return( status );
	}
Exemplo n.º 4
0
	Pool::~Pool()
	{
		mRunning = 0;
		int i;
		for (i = 0; i < mThreadCount; i++)
		{
			wait(mThread[i]);
			release(mThread[i]);
		}
		delete[] mThread;
		if (mWorkMutex)
			destroyMutex(mWorkMutex);
	}
Exemplo n.º 5
0
void child_clean_atexit()
{
    //printf("DEBUG-> Child is now free'in everything...\n");
    
    // Free everything
    JobsList = flush_JobsList(JobsList);
    cFilesList = free_array_of_array(cFilesList);
    
    // Destruction du ou des mutex(es)
    destroyMutex();
    
    exit(EXIT_SUCCESS);
}
Exemplo n.º 6
0
int testSessionOCSPClientServer( void )
	{
	HANDLE hThread;
	unsigned threadID;
	int status;

	/* Start the server and wait for it to initialise */
	createMutex();
	hThread = ( HANDLE ) _beginthreadex( NULL, 0, ocspServerThread,
										 NULL, 0, &threadID );
	Sleep( 1000 );

	/* Connect to the local server */
	status = connectOCSP( CRYPT_SESSION_OCSP, FALSE, FALSE, TRUE );
	waitForThread( hThread );
	destroyMutex();
	return( status );
	}
Exemplo n.º 7
0
int testSessionHTTPCertstoreClientServer( void )
	{
	HANDLE hThread;
	unsigned threadID;
	int status;

	/* Start the server and wait for it to initialise */
	createMutex();
	hThread = ( HANDLE ) _beginthreadex( NULL, 0, certstoreServerThread,
										 NULL, 0, &threadID );
	Sleep( 1000 );

	/* Connect to the local server */
	status = connectCertstoreClient();
	waitForThread( hThread );
	destroyMutex();
	return( status );
	}
Exemplo n.º 8
0
int testSessionSuiteBClientServer( void )
	{
	HANDLE hThread;
	unsigned threadID;
	BOOLEAN isServerTest = FALSE;
	int value = -1, status;	/* +ve = client, -ve = server */

	/* Start the server */
	createMutex();
	hThread = ( HANDLE ) _beginthreadex( NULL, 0, suitebServerThread,
										 &value, 0, &threadID );
	Sleep( 1000 );

	/* Connect to the local server */
	if( value < 0 )
		{
		isServerTest = TRUE;
		value = -value;
		}
	status = suitebClient( value, "localhost", 0, FALSE, isServerTest );
	waitForThread( hThread );
	destroyMutex();
	return( status );
	}
Exemplo n.º 9
0
void queue_destroy(queue_t*queue)
{
    free(queue->data);queue->data = 0;
    destroyMutex(&queue->mutex);
    memset(queue, 0, sizeof(queue_t));
}