Exemple #1
0
void ThreadImpl::joinImpl()
{
	if (!_thread) return;

	switch (WaitForSingleObject(_thread, INFINITE))
	{
	case WAIT_OBJECT_0:
		threadCleanup();
		return;
	default:
		throw SystemException("cannot join thread");
	}
}
Exemple #2
0
bool ThreadImpl::joinImpl(long milliseconds)
{
	if (!_thread) return true;

	switch (WaitForSingleObject(_thread, milliseconds + 1))
	{
	case WAIT_TIMEOUT:
		return false;
	case WAIT_OBJECT_0:
		threadCleanup();
		return true;
	default:
		throw SystemException("cannot join thread");
	}
}
Exemple #3
0
void inspectFile (char * fileName, uuid_t uuid) {
	void * threadData = NULL;
	if (threadInit != NULL) {
		if (!threadInit(&threadData)) {
			rzb_log(LOG_ERR, "Couldn't run nugget inspection threadInit.");
			exit(-1);
		} else {
			rzb_log(LOG_DEBUG, "Thread init for nugget complete.");
		}
	}
	sleep(sleepTime);
	struct EventId * eventId;
	eventId = calloc(1,sizeof(struct EventId));
	struct Block * block = Block_Create ();
	struct List * list	= NTLVList_Create();
	struct stat st;
	stat(fileName, &st);
	//BlockPool_Init();
	block->pId->iLength = st.st_size;
	if (!Transfer_Prepare_File(block, fileName, false)) {
		rzb_log(LOG_ERR, "Trouble preparing file transfer - '%s'", fileName);
		Block_Destroy(block);
		free(eventId);
		List_Destroy(list);
		return;
	}
	Hash_Update(block->pId->pHash, block->data.pointer, block->pId->iLength);
	Hash_Finalize(block->pId->pHash);
	uuid_copy(block->pId->uuidDataType,uuid);
	struct ContextList * current = NULL;
	while (contextList != NULL) {
		current = contextList;
		uint8_t ret = function (block, eventId, list, threadData);
		if ( ret >= 0 ) {
			rzb_log(LOG_NOTICE, "Returned with: %u", ret);
		}
		if (current == contextList)
			break;
	}
	List_Destroy(list);
	/*Don't need to free/destroy as it's done with the judgment.
	 * Was needed previously because of cloning - cloning removed*/
	//Block_Destroy(block);
	//free(eventId);
	if (threadCleanup != NULL) {
		threadCleanup(threadData);
	}
}
Exemple #4
0
void GT_finalize(void)
{
	if (--init_count > 0) {
		/* Do nothing: still being used by someone. */
		return;
	}
	/* In theory we should also check for init_count < 0, but
	 * in practice nothing could be done in this case... */

	threadCleanup();
	OBJ_cleanup();
	ERR_free_strings();
	ERR_remove_state(0);
	EVP_cleanup();
	CRYPTO_cleanup_all_ex_data();
}