Example #1
0
int main(){

node_t * newNode = (node_t *)malloc(sizeof(node_t));

//node_t * newNode1 = (node_t *)malloc(sizeof(node_t));

//std::cout << "newNode1__" << newNode1 << std::endl;

newNode->lChild =3194798272 ;
 //create_child_word(newNode1,INTERNAL,ONEED);

std::cout << "child__" << (node_t *)get_child(newNode->lChild) << std::endl;
//std::cout << "is_leaf__" << is_ext(newNode->lChild) << std::endl;
std::cout << "status__" << get_child_status(newNode->lChild) << std::endl;

AO_t word =124660536341  ;// combine_oprec_status_child_opdata(NULL,ANNOUNCE,RIGHT); //4503567416215574;
std::cout << "oprec__" <<  (oprec_t *)extract_oprec_from_opdata(word) << std::endl;
std::cout << "status__" << extract_status_from_opdata(word) << std::endl;
std::cout << "child__" << extract_child_from_opdata(word) << std::endl;
std::cout << "marked__" << is_node_marked(word) << std::endl;
std::cout << "pos__" << (node_t *)extract_position_from_oprecord(281474077953408) << std::endl;

}
Example #2
0
void LLErrorThread::run()
{
	LLApp::sErrorThreadRunning = TRUE;
	// This thread sits and waits for the sole purpose
	// of waiting for the signal/exception handlers to flag the
	// application state as APP_STATUS_ERROR.
	llinfos << "thread_error - Waiting for an error" << llendl;

	S32 counter = 0;
#if !LL_WINDOWS
	U32 last_sig_child_count = 0;
#endif
	while (1)
	{
		if (LLApp::isError() || LLApp::isStopped())
		{
			// The application has stopped running, time to take action (maybe)
			break;
		}
#if !LL_WINDOWS
		// Check whether or not the main thread had a sig child we haven't handled.
		U32 current_sig_child_count = LLApp::getSigChildCount();
		if (last_sig_child_count != current_sig_child_count)
		{
			int status = 0;
			pid_t child_pid = 0;
			last_sig_child_count = current_sig_child_count;
			if (LLApp::sLogInSignal)
			{
				llinfos << "thread_error handling SIGCHLD #" << current_sig_child_count << llendl;
			}
			for (LLApp::child_map::iterator iter = LLApp::sChildMap.begin(); iter != LLApp::sChildMap.end();)
			{
				child_pid = iter->first;
				LLChildInfo &child_info = iter->second;
				// check the status of *all* children, in case we missed a signal
				if (0 != waitpid(child_pid, &status, WNOHANG))
				{
					bool exited = false;
					int exit_status = -1;
					get_child_status(status, exit_status, exited, LLApp::sLogInSignal);

					if (child_info.mCallback)
					{
						if (LLApp::sLogInSignal)
						{
							llinfos << "Signal handler - Running child callback" << llendl;
						}
						child_info.mCallback(child_pid, exited, status);
					}
					LLApp::sChildMap.erase(iter++);
				}
				else
				{
					// Child didn't terminate, yet we got a sigchild somewhere...
					if (child_info.mGotSigChild && child_info.mCallback)
					{
						child_info.mCallback(child_pid, false, 0);
					}
					child_info.mGotSigChild = FALSE;
					iter++;
				}
			}

			// check the status of *all* children, in case we missed a signal
			// Same as above, but use the default child callback
			while(0 < (child_pid = waitpid( -1, &status, WNOHANG )))
			{
				if (0 != waitpid(child_pid, &status, WNOHANG))
				{
					bool exited = false;
					int exit_status = -1;
					get_child_status(status, exit_status, exited, LLApp::sLogInSignal);
					if (LLApp::sDefaultChildCallback)
					{
						if (LLApp::sLogInSignal)
						{
							llinfos << "Signal handler - Running default child callback" << llendl;
						}
						LLApp::sDefaultChildCallback(child_pid, true, status);
					}
				}
			}
		}


#endif
		ms_sleep(10);
		counter++;
	}
	if (LLApp::isError())
	{
		// The app is in an error state, run the application's error handler.
		//llinfos << "thread_error - An error has occurred, running error callback!" << llendl;
		// Run the error handling callback
		LLApp::runErrorHandler();
	}
	else
	{
		// Everything is okay, a clean exit.
		//llinfos << "thread_error - Application exited cleanly" << llendl;
	}
	
	//llinfos << "thread_error - Exiting" << llendl;
	LLApp::sErrorThreadRunning = FALSE;
}