本文整理汇总了C++中LE_FATAL函数的典型用法代码示例。如果您正苦于以下问题:C++ LE_FATAL函数的具体用法?C++ LE_FATAL怎么用?C++ LE_FATAL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LE_FATAL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: system
//--------------------------------------------------------------------------------------------------
static void LoadIpcBindingConfig
(
void
)
{
int result = system("sdir load");
if (result == -1)
{
LE_FATAL("Failed to fork child process. (%m)");
}
else if (WIFEXITED(result))
{
int exitCode = WEXITSTATUS(result);
if (exitCode != 0)
{
LE_FATAL("Couldn't load IPC binding config. `sdir load` exit code: %d.", exitCode);
}
}
else if (WIFSIGNALED(result))
{
int sigNum = WTERMSIG(result);
LE_FATAL("Couldn't load IPC binding config. `sdir load` received signal: %d.", sigNum);
}
}
示例2: policy
// -------------------------------------------------------------------------------------------------
static void* ThreadMainFunction
(
void* expectedPolicy ///< The expected Linux scheduling policy (SCHED_IDLE or SCHED_OTHER).
)
// -------------------------------------------------------------------------------------------------
{
LE_INFO("Checking scheduling policy...");
int schedPolicy = sched_getscheduler(0);
if (schedPolicy == -1)
{
LE_FATAL("Failed to fetch scheduling policy (error %d).", errno);
}
if (expectedPolicy != (void*)(size_t)schedPolicy)
{
LE_FATAL("Expected policy %p. Got %p.", expectedPolicy, (void*)(size_t)schedPolicy);
}
else
{
LE_INFO("Policy correct.");
}
return NULL;
}
示例3: CONTAINER_OF
//--------------------------------------------------------------------------------------------------
void fa_event_TriggerEvent_NoLock
(
event_PerThreadRec_t* portablePerThreadRecPtr
)
{
static const uint64_t writeBuff = 1; // Write the value 1 to increment the eventfd by 1.
event_LinuxPerThreadRec_t* perThreadRecPtr =
CONTAINER_OF(portablePerThreadRecPtr,
event_LinuxPerThreadRec_t,
portablePerThreadRec);
ssize_t writeSize;
for (;;)
{
writeSize = write(perThreadRecPtr->eventQueueFd, &writeBuff, sizeof(writeBuff));
if (writeSize == sizeof(writeBuff))
{
return;
}
else
{
if ((writeSize == -1) && (errno != EINTR))
{
LE_FATAL("write() failed with errno %d.", errno);
}
else
{
LE_FATAL("write() returned %zd! (expected %zd)", writeSize, sizeof(writeBuff));
}
}
}
}
示例4: le_pm_Relax
//--------------------------------------------------------------------------------------------------
void le_pm_Relax(le_pm_WakeupSourceRef_t w)
{
WakeupSource_t *ws, *entry;
// Validate the reference, check if it exists
ws = ToWakeupSource(w);
// If the wakeup source is NULL then the client will have
// been killed and we can just return
if (NULL == ws)
return;
entry = (WakeupSource_t*)le_hashmap_Get(PowerManager.locks, ws->name);
if (!entry)
LE_FATAL("Wakeup source '%s' not created.\n", ws->name);
if (!entry->taken) {
LE_ERROR("Wakeup source '%s' already released.", entry->name);
return;
}
// write to /sys/power/wake_unlock
if (0 > write(PowerManager.wu, entry->name, strlen(entry->name)))
LE_FATAL("Error releasing wakeup soruce '%s', errno = %d.",
entry->name, errno);
entry->taken = LE_OFF;
return;
}
示例5: LE_FATAL
//--------------------------------------------------------------------------------------------------
static _ClientThreadData_t* InitClientThreadData
(
const char* serviceInstanceName
)
{
// Open a session.
le_msg_ProtocolRef_t protocolRef;
le_msg_SessionRef_t sessionRef;
// The instance name must not be an empty string
if ( serviceInstanceName[0] == '\0' )
{
LE_FATAL("Undefined client service instance name (Was StartClient() called?)");
}
protocolRef = le_msg_GetProtocolRef(PROTOCOL_ID_STR, sizeof(_Message_t));
sessionRef = le_msg_CreateSession(protocolRef, serviceInstanceName);
le_msg_SetSessionRecvHandler(sessionRef, ClientIndicationRecvHandler, NULL);
le_msg_OpenSessionSync(sessionRef);
// Store the client sessionRef in thread-local storage, since each thread requires
// its own sessionRef.
_ClientThreadData_t* clientThreadPtr = le_mem_ForceAlloc(_ClientThreadDataPool);
clientThreadPtr->sessionRef = sessionRef;
if (pthread_setspecific(_ThreadDataKey, clientThreadPtr) != 0)
{
LE_FATAL("pthread_setspecific() failed!");
}
return clientThreadPtr;
}
示例6: LE_DEBUG
//--------------------------------------------------------------------------------------------------
static void LoadECallSettings
(
int32_t* hMinAccuracyPtr,
int32_t* dirMinAccuracyPtr
)
{
char psapStr[LE_MDMDEFS_PHONE_NUM_MAX_BYTES] = {0};
LE_DEBUG("Start reading eCall app settings in Configuration Tree");
le_cfg_IteratorRef_t eCallCfgRef = le_cfg_CreateReadTxn(CFG_ECALL_APP_PATH);
// Get PSAP
if (le_cfg_NodeExists(eCallCfgRef, CFG_NODE_PSAP))
{
if ( le_cfg_GetString(eCallCfgRef, CFG_NODE_PSAP, psapStr, sizeof(psapStr), "") != LE_OK )
{
LE_FATAL("No node value set for '%s', exit the app!", CFG_NODE_PSAP);
}
LE_DEBUG("eCall settings, PSAP number is %s", psapStr);
if (le_ecall_SetPsapNumber(psapStr) != LE_OK)
{
LE_FATAL("Cannot set PSAP number, exit the app!");
}
}
else
{
LE_FATAL("No value set for '%s', restart the app!", CFG_NODE_PSAP);
}
// Get minimum horizontal accuracy
if (le_cfg_NodeExists(eCallCfgRef, CFG_NODE_H_MIN_ACCURACY))
{
*hMinAccuracyPtr = le_cfg_GetInt(eCallCfgRef, CFG_NODE_H_MIN_ACCURACY, DEFAULT_H_ACCURACY);
LE_DEBUG("eCall app settings, horizontal accuracy is %d meter(s)", *hMinAccuracyPtr);
}
else
{
*hMinAccuracyPtr = DEFAULT_H_ACCURACY;
}
// Get minimum direction accuracy
if (le_cfg_NodeExists(eCallCfgRef, CFG_NODE_DIR_MIN_ACCURACY))
{
*dirMinAccuracyPtr = le_cfg_GetInt(eCallCfgRef, CFG_NODE_DIR_MIN_ACCURACY, DEFAULT_DIR_ACCURACY);
LE_DEBUG("eCall app settings, direction accuracy is %d degree(s)", *dirMinAccuracyPtr);
}
else
{
*dirMinAccuracyPtr = DEFAULT_DIR_ACCURACY;
}
le_cfg_CancelTxn(eCallCfgRef);
}
示例7: LE_ASSERT
//--------------------------------------------------------------------------------------------------
le_result_t pa_audioSimu_CheckAudioPathSet
(
void
)
{
le_audio_If_t inItf;
le_audio_If_t outItf;
for (inItf = 0; inItf < LE_AUDIO_NUM_INTERFACES; inItf++)
{
for (outItf = 0; outItf < LE_AUDIO_NUM_INTERFACES; outItf++)
{
if ( inItf == outItf )
{
// audio path can't be built between a stream and the same stream
LE_ASSERT( BuildAudioPath[inItf][outItf] == 0 );
}
else if ( IS_OUTPUT_STREAM(inItf) )
{
// if the input stream is an output, it is not a valuable path
LE_ASSERT( BuildAudioPath[inItf][outItf] == 0 );
}
else if ( IS_INPUT_STREAM(inItf) )
{
if ( IS_OUTPUT_STREAM(outItf) )
{
// this is an expected audio path. It should be set only once
LE_ASSERT( BuildAudioPath[inItf][outItf] == 1 );
}
else if (IS_INPUT_STREAM(outItf))
{
// if the output stream is an input, it is not a valuable path
LE_ASSERT( BuildAudioPath[inItf][outItf] == 0 );
}
else
{
LE_FATAL("Unknown audio path");
}
}
else
{
LE_FATAL("Unknown audio path");
}
}
}
return LE_OK;
}
示例8: le_mem_ForceAlloc
//--------------------------------------------------------------------------------------------------
le_sem_Ref_t CreateSemaphore
(
const char* nameStr,
int initialCount,
bool isTraceable
)
//--------------------------------------------------------------------------------------------------
{
// Allocate a semaphore object and initialize it.
Semaphore_t* semaphorePtr = le_mem_ForceAlloc(SemaphorePoolRef);
semaphorePtr->semaphoreListLink = LE_DLS_LINK_INIT;
semaphorePtr->waitingList = LE_DLS_LIST_INIT;
pthread_mutex_init(&semaphorePtr->waitingListMutex, NULL); // Default attributes = Fast mutex.
semaphorePtr->isTraceable = isTraceable;
if (le_utf8_Copy(semaphorePtr->nameStr, nameStr, sizeof(semaphorePtr->nameStr), NULL) == LE_OVERFLOW)
{
LE_WARN("Semaphore name '%s' truncated to '%s'.", nameStr, semaphorePtr->nameStr);
}
// Initialize the underlying POSIX semaphore shared between thread.
int result = sem_init(&semaphorePtr->semaphore,0, initialCount);
if (result != 0)
{
LE_FATAL("Failed to set the semaphore . errno = %d (%m).", errno);
}
// Add the semaphore to the process's Semaphore List.
LOCK_SEMAPHORE_LIST();
le_dls_Queue(&SemaphoreList, &semaphorePtr->semaphoreListLink);
UNLOCK_SEMAPHORE_LIST();
return semaphorePtr;
}
示例9: sem_trywait
//--------------------------------------------------------------------------------------------------
le_result_t le_sem_TryWait
(
le_sem_Ref_t semaphorePtr ///< [IN] Pointer to the semaphore
)
{
// TODO: Implement this.
// if (semaphorePtr->isTraceable)
// {
// }
// else
{
int result;
result = sem_trywait(&semaphorePtr->semaphore);
if (result != 0)
{
if ( errno == EAGAIN ) {
return LE_WOULD_BLOCK;
} else {
LE_FATAL("Thread '%s' failed to trywait on semaphore '%s'. Error code %d (%m).",
le_thread_GetMyName(),
semaphorePtr->nameStr,
result);
}
}
}
return LE_OK;
}
示例10: SigUser2Handler
static void SigUser2Handler(int sigNum)
{
LE_INFO("%s received through fd handler.", strsignal(sigNum));
switch (checkCount)
{
case 2:
{
// Send to the other thread. But the other thread should not get it.
checkCount++;
LE_ASSERT(kill(getpid(), SIGUSR1) == 0);
// Make sure that the signal to thread 1 is sent first.
sleep(1);
// Send to ourself and we should get it
checkCount++;
LE_ASSERT(kill(getpid(), SIGUSR2) == 0);
break;
}
case 4:
{
LE_INFO("======== Signal Events Test Completed (PASSED) ========");
exit(EXIT_SUCCESS);
}
default: LE_FATAL("Should not be here.");
}
}
示例11: main
int main(int argc, char* argv[])
{
arg_SetArgs((size_t)argc, (char**)argv);
LE_DEBUG("== Starting Executable '%s' ==", STRINGIZE(LE_EXECUTABLE_NAME));
LE_LOG_SESSION = log_RegComponent( STRINGIZE(LE_COMPONENT_NAME), &LE_LOG_LEVEL_FILTER_PTR);
// Connect to the Log Control Daemon.
// The sooner we can connect to the Log Control Daemon, the better, because that is when
// we obtain any non-default log settings that have been set using the interactive log
// control tool. However, we can't do that until we have a working IPC messaging system.
// However, the Log Control Daemon shouldn't try to connect to itself.
// Also, the Service Directory shouldn't try to use the messaging system, so it can't
// connect to the Log Control Daemon either. Besides, the Service Directory starts before
// the Log Control Daemon starts.
#ifndef NO_LOG_CONTROL
log_ConnectToControlDaemon();
#endif
//@todo: Block all signals that the user intends to handle with signal events.
// Queue up all the component initialization functions to be called by the Event Loop after
// it processes any messages that were received from the Log Control Daemon.
event_QueueComponentInit(_le_event_InitializeComponent);
LE_DEBUG("== Starting Event Processing Loop ==");
le_event_RunLoop();
LE_FATAL("SHOULDN'T GET HERE!");
}
示例12: memset
//--------------------------------------------------------------------------------------------------
void msgService_SendServiceId
(
le_msg_ServiceRef_t serviceRef, ///< [in] Pointer to the service whose ID is to be sent.
int socketFd ///< [in] File descriptor of the connected socket to send on.
)
//--------------------------------------------------------------------------------------------------
{
svcdir_ServiceId_t serviceId;
memset(&serviceId, 0, sizeof(serviceId));
serviceId.maxProtocolMsgSize = le_msg_GetProtocolMaxMsgSize(serviceRef->id.protocolRef);
le_utf8_Copy(serviceId.protocolId,
le_msg_GetProtocolIdStr(serviceRef->id.protocolRef),
sizeof(serviceId.protocolId),
NULL);
le_utf8_Copy(serviceId.serviceName,
serviceRef->id.name,
sizeof(serviceId.serviceName),
NULL);
le_result_t result = unixSocket_SendDataMsg(socketFd, &serviceId, sizeof(serviceId));
if (result != LE_OK)
{
LE_FATAL("Failed to send. Result = %d (%s)", result, LE_RESULT_TXT(result));
}
// NOTE: This is only done when the socket is newly opened, so this shouldn't ever
// return LE_NO_MEMORY to indicate send buffers being full.
}
示例13: main
int main(int argc, char** argv)
{
struct pollfd pollControl;
le_sms_ConnectService();
// Register a callback function to be called when an SMS arrives.
(void)le_sms_AddRxMessageHandler(SmsRxHandler, NULL);
printf("Waiting for SMS messages to arrive...\n");
// Get the Legato event loop "readyness" file descriptor and put it in a pollfd struct
// configured to detect "ready to read".
pollControl.fd = le_event_GetFd();
pollControl.events = POLLIN;
while (true)
{
// Block until the file descriptor is "ready to read".
int result = poll(&pollControl, 1, -1);
if (result > 0)
{
// The Legato event loop needs servicing. Keep servicing it until there's nothing left.
while (le_event_ServiceLoop() == LE_OK)
{
/* le_event_ServiceLoop() has more to do. Need to call it again. */
}
}
else
{
LE_FATAL("poll() failed with errno %m.");
}
}
}
示例14: pthread_getspecific
//--------------------------------------------------------------------------------------------------
void StopClient
(
void
)
{
_ClientThreadData_t* clientThreadPtr = pthread_getspecific(_ThreadDataKey);
// If the thread specific data is NULL, then there is no current client session.
if (clientThreadPtr == NULL)
{
LE_ERROR("Trying to stop non-existent client session for '%s' service",
GlobalServiceInstanceName);
}
else
{
le_msg_CloseSession( clientThreadPtr->sessionRef );
// Need to delete the thread specific data, since it is no longer valid. If a new
// client session is started, new thread specific data will be allocated.
le_mem_Release(clientThreadPtr);
if (pthread_setspecific(_ThreadDataKey, NULL) != 0)
{
LE_FATAL("pthread_setspecific() failed!");
}
LE_DEBUG("======= Stopping Client %s ========", GlobalServiceInstanceName);
}
}
示例15: LE_FATAL
//--------------------------------------------------------------------------------------------------
le_result_t le_clk_ConvertToUTCString
(
le_clk_Time_t time, ///< [IN] date/time to convert
const char* formatSpecStrPtr, ///< [IN] Format specifier string, using conversion
/// specifiers defined for strftime().
char* destStrPtr, ///< [OUT] Destination for the formatted date/time string
size_t destSize, ///< [IN] Size of the destination buffer in bytes.
size_t* numBytesPtr ///< [OUT] Number of bytes copied, not including NULL-terminator.
/// Parameter can be set to NULL if the number of
/// bytes copied is not needed.
)
{
struct tm brokenTime;
le_result_t result;
if (gmtime_r(&time.sec, &brokenTime) == NULL)
{
LE_FATAL("Cannot convert time into UTC broken down time.");
}
result = FormatBrokenTime(time, brokenTime, formatSpecStrPtr, destStrPtr, destSize, numBytesPtr);
return result;
}