本文整理汇总了C++中LE_FATAL_IF函数的典型用法代码示例。如果您正苦于以下问题:C++ LE_FATAL_IF函数的具体用法?C++ LE_FATAL_IF怎么用?C++ LE_FATAL_IF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LE_FATAL_IF函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: LE_FATAL_IF
//--------------------------------------------------------------------------------------------------
static tu_UserRef_t GetUserInfo
(
le_msg_SessionRef_t currentSession, ///< [IN] Get the user information for this message
///< session.
bool* wasCreated ///< [OUT] Was the user info created for this request?
///< Pass NULL if you don't need this.
)
//--------------------------------------------------------------------------------------------------
{
LE_FATAL_IF(currentSession == NULL, "Bad user message session reference.");
// Look up the user id of the requesting connection...
uid_t userId;
LE_FATAL_IF(le_msg_GetClientUserId(currentSession, &userId) == LE_CLOSED,
"tu_GetUserInfo must be called within an active connection.");
// Now that we have a user ID, let's see if we can look them up.
tu_UserRef_t userRef = GetUser(userId, wasCreated);
LE_ASSERT(userRef != NULL);
LE_DEBUG("** Found user <%p>: '%s', %u with default tree, '%s'.",
userRef,
userRef->userName,
userRef->userId,
userRef->treeName);
return userRef;
}
开发者ID:andreasanna,项目名称:legato-af,代码行数:30,代码来源:treeUser.c
示例2: LE_FATAL_IF
//--------------------------------------------------------------------------------------------------
void cgrp_Init
(
void
)
{
// Setup the cgroup root directory if it does not already exist.
if (!fs_IsMounted(ROOT_NAME, ROOT_PATH))
{
LE_FATAL_IF(mount(ROOT_NAME, ROOT_PATH, "tmpfs", 0, NULL) != 0,
"Could not mount cgroup root file system. %m.");
}
// Setup a separate cgroup hierarch for each supported subsystem.
cgrp_SubSys_t subSys = 0;
for (; subSys < CGRP_NUM_SUBSYSTEMS; subSys++)
{
char dir[LIMIT_MAX_PATH_BYTES] = ROOT_PATH;
LE_ASSERT(le_path_Concat("/", dir, sizeof(dir), SubSysName[subSys], (char*)NULL) == LE_OK);
LE_ASSERT(le_dir_Make(dir, S_IRWXU) != LE_FAULT);
if (!fs_IsMounted(SubSysName[subSys], dir))
{
LE_FATAL_IF(mount(SubSysName[subSys], dir, "cgroup", 0, SubSysName[subSys]) != 0,
"Could not mount cgroup subsystem '%s'. %m.", SubSysName[subSys]);
LE_INFO("Mounted cgroup hiearchy for subsystem '%s'.", SubSysName[subSys]);
}
}
}
开发者ID:H-H-bin,项目名称:legato-af,代码行数:32,代码来源:cgroups.c
示例3: open
//--------------------------------------------------------------------------------------------------
void smack_RevokeSubject
(
const char* subjectLabelPtr ///< [IN] Subject label.
)
{
// Open the SMACK revoke file.
int fd;
do
{
fd = open(SMACK_REVOKE_FILE, O_WRONLY);
}
while ( (fd == -1) && (errno == EINTR) );
LE_FATAL_IF(fd == -1, "Could not open %s. %m.\n", SMACK_REVOKE_FILE);
// Write the label to the SMACK revoke file.
int numBytes = 0;
do
{
numBytes = write(fd, subjectLabelPtr, strlen(subjectLabelPtr));
}
while ( (numBytes == -1) && (errno == EINTR) );
LE_FATAL_IF(numBytes < 0, "Could not revoke SMACK label '%s'. %m.", subjectLabelPtr);
fd_Close(fd);
LE_DEBUG("Revoked SMACK label '%s'.", subjectLabelPtr);
}
开发者ID:tegoo,项目名称:legato-af,代码行数:32,代码来源:smack.c
示例4: le_utf8_Append
//--------------------------------------------------------------------------------------------------
LE_SHARED void cfgInstall_Add
(
const char* appName
)
//--------------------------------------------------------------------------------------------------
{
le_result_t result;
char filePath[256] = "/opt/legato/apps/";
result = le_utf8_Append(filePath, appName, sizeof(filePath), NULL);
LE_FATAL_IF(result != LE_OK, "App name '%s' is too long.", appName);
result = le_utf8_Append(filePath, "/root.cfg", sizeof(filePath), NULL);
LE_FATAL_IF(result != LE_OK, "App name '%s' is too long.", appName);
LE_INFO("Importing configuration for application '%s' from '%s'.", appName, filePath);
le_cfg_IteratorRef_t i = le_cfg_CreateWriteTxn("/apps");
result = le_cfgAdmin_ImportTree(i, filePath, appName);
LE_FATAL_IF(result != LE_OK,
"Failed to import configuration from '%s' to 'root:/apps/%s' (%s)",
filePath,
appName,
LE_RESULT_TXT(result));
le_cfg_CommitTxn(i);
}
开发者ID:tegoo,项目名称:legato-af,代码行数:31,代码来源:configInstaller.c
示例5: strlen
//--------------------------------------------------------------------------------------------------
static void CheckLabel
(
const char* labelPtr ///< [IN] Label to check.
)
{
// Check lengths.
size_t labelSize = strlen(labelPtr);
LE_FATAL_IF(labelSize == 0, "SMACK label cannot be empty.");
LE_FATAL_IF(labelSize > LIMIT_MAX_SMACK_LABEL_LEN,
"SMACK label length, %zd chars, is too long. Labels must be less than %d chars",
labelSize, LIMIT_MAX_SMACK_LABEL_LEN);
// Check for invalid characters.
LE_FATAL_IF(labelPtr[0] == '-',
"SMACK label '%s' is invalid because it begins with '-'.", labelPtr);
int i;
for (i = 0; i < labelSize; i++)
{
char c = labelPtr[i];
if ( !isprint(c) || !isascii(c) || (c == '/') || (c == '\\') || (c == '\'') || (c == '"') )
{
LE_FATAL("SMACK label '%s' contain invalid character(s).", labelPtr);
}
}
}
开发者ID:tegoo,项目名称:legato-af,代码行数:30,代码来源:smack.c
示例6: le_mem_ForceAlloc
//--------------------------------------------------------------------------------------------------
event_PerThreadRec_t* fa_event_CreatePerThreadInfo
(
void
)
{
event_LinuxPerThreadRec_t* recPtr = le_mem_ForceAlloc(PerThreadPool);
// Create the epoll file descriptor for this thread. This will be used to monitor for
// events on various file descriptors.
recPtr->epollFd = epoll_create1(0);
LE_FATAL_IF(recPtr->epollFd < 0, "epoll_create1(0) failed with errno %d.", errno);
// Open an eventfd for this thread. This will be uses to signal to the epoll fd that there
// are Event Reports on the Event Queue.
recPtr->eventQueueFd = eventfd(0, 0);
LE_FATAL_IF(recPtr->eventQueueFd < 0, "eventfd() failed with errno %d.", errno);
// Add the eventfd to the list of file descriptors to wait for using epoll_wait().
struct epoll_event ev;
memset(&ev, 0, sizeof(ev));
ev.events = EPOLLIN | EPOLLWAKEUP;
ev.data.ptr = NULL; // This being set to NULL is what tells the main event loop that this
// is the Event Queue FD, rather than another FD that is being
// monitored.
if (epoll_ctl(recPtr->epollFd, EPOLL_CTL_ADD, recPtr->eventQueueFd, &ev) == -1)
{
LE_FATAL( "epoll_ctl(ADD) failed for fd %d. errno = %d",
recPtr->eventQueueFd,
errno);
}
return &recPtr->portablePerThreadRec;
}
开发者ID:legatoproject,项目名称:legato-af,代码行数:34,代码来源:eventLoop.c
示例7: le_ref_Lookup
//--------------------------------------------------------------------------------------------------
void le_fdMonitor_Enable
(
le_fdMonitor_Ref_t monitorRef, ///< [in] Reference to the File Descriptor Monitor object.
short events ///< [in] Bit map of events.
)
//--------------------------------------------------------------------------------------------------
{
// Look up the File Descriptor Monitor object using the safe reference provided.
// Note that the safe reference map is shared by all threads in the process, so it
// must be protected using the mutex. The File Descriptor Monitor objects, on the other
// hand, are only allowed to be accessed by the one thread that created them, so it is
// safe to unlock the mutex after doing the safe reference lookup.
LOCK
FdMonitor_t* monitorPtr = le_ref_Lookup(FdMonitorRefMap, monitorRef);
UNLOCK
LE_FATAL_IF(monitorPtr == NULL, "File Descriptor Monitor %p doesn't exist!", monitorRef);
LE_FATAL_IF(thread_GetEventRecPtr() != monitorPtr->threadRecPtr,
"FD Monitor '%s' (fd %d) is owned by another thread.",
monitorPtr->name,
monitorPtr->fd);
short filteredEvents = events & (POLLIN | POLLOUT | POLLPRI);
if (filteredEvents != events)
{
char textBuff[64];
LE_WARN("Attempt to enable events that can't be disabled (%s).",
GetPollEventsText(textBuff, sizeof(textBuff), events & ~filteredEvents));
}
uint32_t epollEvents = PollToEPoll(filteredEvents);
// If the fd doesn't support epoll, we assume it is always ready for read and write.
// As long as EPOLLIN or EPOLLOUT (or both) is enabled for one of these fds, DispatchToHandler()
// keeps re-queueing itself to the thread's event queue. But it will stop doing that if
// EPOLLIN and EPOLLOUT are both disabled. So, here is where we get things going again when
// EPOLLIN or EPOLLOUT is enabled outside DispatchToHandler() for that fd.
if ( (monitorPtr->isAlwaysReady)
&& (epollEvents & (EPOLLIN | EPOLLOUT))
&& ((monitorPtr->epollEvents & (EPOLLIN | EPOLLOUT)) == 0) )
{
// Fetch the pointer to the FD Monitor from thread-specific data.
// This will be NULL if we are not inside an FD Monitor handler.
FdMonitor_t* handlerMonitorPtr = pthread_getspecific(FDMonitorPtrKey);
// If no handler is running or some other fd's handler is running,
if ((handlerMonitorPtr == NULL) || (handlerMonitorPtr->safeRef == monitorRef))
{
// Queue up DispatchToHandler() for this fd.
fdMon_Report(monitorRef, epollEvents & (EPOLLIN | EPOLLOUT));
}
}
// Bit-wise OR the newly enabled event flags into the FD Monitor's epoll(7) flags set.
monitorPtr->epollEvents |= epollEvents;
UpdateEpollFd(monitorPtr);
}
开发者ID:tegoo,项目名称:legato-af,代码行数:61,代码来源:fdMonitor.c
示例8: LE_FATAL_IF
//--------------------------------------------------------------------------------------------------
le_msg_SessionEventHandlerRef_t le_msg_AddServiceCloseHandler
(
le_msg_ServiceRef_t serviceRef, ///< [in] Reference to the service.
le_msg_SessionEventHandler_t handlerFunc,///< [in] Handler function.
void* contextPtr ///< [in] Opaque pointer value to pass to handler.
)
//--------------------------------------------------------------------------------------------------
{
LE_FATAL_IF(serviceRef == NULL,
"Service doesn't exist. Make sure service is started before setting handlers");
LE_FATAL_IF(serviceRef->serverThread != le_thread_GetCurrent(),
"Service (%s:%s) not owned by calling thread.",
serviceRef->id.name,
le_msg_GetProtocolIdStr(serviceRef->id.protocolRef));
// Create the node.
SessionEventHandler_t* closeEventPtr = le_mem_ForceAlloc(HandlerEventPoolRef);
// Initialize the node.
closeEventPtr->handler = handlerFunc;
closeEventPtr->contextPtr = contextPtr;
closeEventPtr->link = LE_DLS_LINK_INIT;
closeEventPtr->listPtr = &serviceRef->closeListPtr;
// Add the node to the head of the list by passing in the node's link.
le_dls_Stack(&serviceRef->closeListPtr, &closeEventPtr->link);
// Need to return a unique reference that will be used by the remove function.
closeEventPtr->ref = le_ref_CreateRef(HandlersRefMap, &closeEventPtr->link);
return closeEventPtr->ref;
}
开发者ID:andreasanna,项目名称:legato-af,代码行数:33,代码来源:messagingService.c
示例9: true
//--------------------------------------------------------------------------------------------------
void le_fdMonitor_SetDeferrable
(
le_fdMonitor_Ref_t monitorRef, ///< [in] Reference to the File Descriptor Monitor object.
bool isDeferrable ///< [in] true (deferrable) or false (urgent).
)
//--------------------------------------------------------------------------------------------------
{
// Look up the File Descriptor Monitor object using the safe reference provided.
// Note that the safe reference map is shared by all threads in the process, so it
// must be protected using the mutex. The File Descriptor Monitor objects, on the other
// hand, are only allowed to be accessed by the one thread that created them, so it is
// safe to unlock the mutex after doing the safe reference lookup.
LOCK
FdMonitor_t* monitorPtr = le_ref_Lookup(FdMonitorRefMap, monitorRef);
UNLOCK
LE_FATAL_IF(monitorPtr == NULL, "File Descriptor Monitor %p doesn't exist!", monitorRef);
LE_FATAL_IF(thread_GetEventRecPtr() != monitorPtr->threadRecPtr,
"FD Monitor '%s' (fd %d) is owned by another thread.",
monitorPtr->name,
monitorPtr->fd);
// Set/clear the EPOLLWAKEUP flag in the FD Monitor's epoll(7) flags set.
if (isDeferrable)
{
monitorPtr->epollEvents &= ~EPOLLWAKEUP;
}
else
{
monitorPtr->epollEvents |= EPOLLWAKEUP;
}
UpdateEpollFd(monitorPtr);
}
开发者ID:tegoo,项目名称:legato-af,代码行数:35,代码来源:fdMonitor.c
示例10: unixSocket_CreateSeqPacketUnnamed
//--------------------------------------------------------------------------------------------------
void le_msg_AdvertiseService
(
le_msg_ServiceRef_t serviceRef ///< [in] Reference to the service.
)
//--------------------------------------------------------------------------------------------------
{
// Open a socket and connect it to the Service Directory.
int fd = unixSocket_CreateSeqPacketUnnamed();
// Check for failure.
LE_FATAL_IF(fd == LE_NOT_PERMITTED, "Permission to open socket denied.");
LE_FATAL_IF(fd == LE_FAULT, "Failed to open socket.");
// Warn if one of the three standard I/O streams have been somehow connected to the
// Service Directory.
if (fd < 3)
{
const char* streamNameStr;
switch (fd)
{
case 0:
streamNameStr = "stdin";
break;
case 1:
streamNameStr = "stdout";
break;
case 2:
streamNameStr = "stderr";
break;
}
LE_WARN("Service Directory connection mapped to %s.", streamNameStr);
}
le_result_t result = unixSocket_Connect(fd, LE_SVCDIR_SERVER_SOCKET_NAME);
LE_FATAL_IF(result != LE_OK,
"Failed to connect to Service Directory. Result = %d (%s).",
result,
LE_RESULT_TXT(result));
serviceRef->directorySocketFd = fd;
// Set the socket non-blocking.
fd_SetNonBlocking(fd);
// Start monitoring the socket for events.
StartMonitoringDirectorySocket(serviceRef);
// Send the Service ID to the Service Directory.
msgService_SendServiceId(serviceRef, fd);
// Wait for the Service Directory to respond by either dropping the connection
// (meaning that we have been denied permission to offer this service) or by
// forwarding us file descriptors for authenticated client connections.
}
开发者ID:hakanernam,项目名称:legato-af,代码行数:55,代码来源:messagingService.c
示例11: LE_FATAL_IF
//--------------------------------------------------------------------------------------------------
static void CheckFor
(
appCfg_Iter_t iterRef,
IterType_t type
)
{
LE_FATAL_IF(iterRef == NULL, "Iterator reference can not be NULL.");
LE_FATAL_IF(iterRef->type != type,
"Expected %s, but received %s instead.",
TypeToStr(type),
TypeToStr(iterRef->type));
}
开发者ID:mbaglin,项目名称:legato-af,代码行数:13,代码来源:appCfg.c
示例12: CheckLabel
//--------------------------------------------------------------------------------------------------
bool smack_HasAccess
(
const char* subjectLabelPtr, ///< [IN] Subject label.
const char* accessModePtr, ///< [IN] Access mode.
const char* objectLabelPtr ///< [IN] Object label.
)
{
CheckLabel(subjectLabelPtr);
CheckLabel(objectLabelPtr);
// Create the SMACK rule.
char rule[SMACK_RULE_STR_BYTES];
MakeRuleStr(subjectLabelPtr, accessModePtr, objectLabelPtr, rule, sizeof(rule));
// Open the SMACK access file.
int fd;
do
{
fd = open(SMACK_ACCESS_FILE, O_RDWR);
}
while ( (fd == -1) && (errno == EINTR) );
LE_FATAL_IF(fd == -1, "Could not open %s. %m.\n", SMACK_ACCESS_FILE);
// Write the rule to the SMACK access file.
int numBytes = 0;
do
{
numBytes = write(fd, rule, sizeof(rule)-1);
}
while ( (numBytes == -1) && (errno == EINTR) );
LE_FATAL_IF(numBytes < 0, "Could not write SMACK rule '%s'. %m.", rule);
// Read the SMACK access file to see if access would be granted.
char a;
do
{
numBytes = read(fd, &a, 1);
}
while ( (numBytes == -1) && (errno == EINTR) );
LE_FATAL_IF(numBytes <= 0, "Could not read '%s'. %m.", SMACK_ACCESS_FILE);
fd_Close(fd);
return (a == '1');
}
开发者ID:tegoo,项目名称:legato-af,代码行数:51,代码来源:smack.c
示例13: LE_ASSERT
//--------------------------------------------------------------------------------------------------
le_event_FdHandlerRef_t le_event_SetFdHandler
(
le_event_FdMonitorRef_t monitorRef, ///< [in] Reference to the File Descriptor Monitor object.
le_event_FdEventType_t eventType, ///< [in] The type of event to be reported to this handler.
le_event_FdHandlerFunc_t handlerFunc ///< [in] The handler function.
)
//--------------------------------------------------------------------------------------------------
{
LE_ASSERT(handlerFunc != NULL);
// Look up the File Descriptor Monitor object using the safe reference provided.
// Note that the safe reference map is shared by all threads in the process, so it
// must be protected using the mutex. The File Descriptor Monitor objects, on the other
// hand, are only allowed to be accessed by the one thread that created them, so it is
// safe to unlock the mutex after doing the safe reference lookup.
LOCK
FdMonitor_t* monitorPtr = le_ref_Lookup(FdMonitorRefMap, monitorRef);
UNLOCK
LE_FATAL_IF(monitorPtr == NULL, "File Descriptor Monitor %p doesn't exist!", monitorRef);
LE_FATAL_IF(thread_GetEventRecPtr() != monitorPtr->threadRecPtr,
"FD Monitor '%s' (fd %d) is owned by another thread.",
monitorPtr->name,
monitorPtr->fd);
// Get a pointer to the Handler object in the appropriate spot for this type of event in the
// FD Monitor's array of handlers.
Handler_t* handlerPtr = &(monitorPtr->handlerArray[eventType]);
// Double check that no one has tried setting this handler yet.
LE_FATAL_IF(handlerPtr->handlerFunc != NULL,
"FD handler already set for event '%s' on FD Monitor '%s' (fd %d).",
GetFdEventTypeName(eventType),
monitorPtr->name,
monitorPtr->fd);
// Initialize the Handler object.
handlerPtr->handlerFunc = handlerFunc;
handlerPtr->contextPtr = NULL;
handlerPtr->monitorPtr = monitorPtr;
LOCK
handlerPtr->safeRef = le_ref_CreateRef(HandlerRefMap, handlerPtr);
UNLOCK
// Enable the monitoring of this event.
EnableFdMonitoring(monitorPtr, eventType);
return handlerPtr->safeRef;
}
开发者ID:mbarazzouq,项目名称:legato-af,代码行数:50,代码来源:fdMonitor.c
示例14: LE_ASSERT
//--------------------------------------------------------------------------------------------------
void TriggerCallbackTestRespond
(
ServerCmdRef_t _cmdRef
)
{
LE_ASSERT(_cmdRef != NULL);
// Get the message related data
le_msg_MessageRef_t _msgRef = (le_msg_MessageRef_t)_cmdRef;
_Message_t* _msgPtr = le_msg_GetPayloadPtr(_msgRef);
__attribute__((unused)) uint8_t* _msgBufPtr = _msgPtr->buffer;
// Ensure the passed in msgRef is for the correct message
LE_ASSERT(_msgPtr->id == _MSGID_TriggerCallbackTest);
// Ensure that this Respond function has not already been called
LE_FATAL_IF( !le_msg_NeedsResponse(_msgRef), "Response has already been sent");
// Pack any "out" parameters
// Return the response
LE_DEBUG("Sending response to client session %p", le_msg_GetSession(_msgRef));
le_msg_Respond(_msgRef);
}
开发者ID:mbarazzouq,项目名称:legato-af,代码行数:27,代码来源:server.c
示例15: while
//--------------------------------------------------------------------------------------------------
void atmachinestring_AddInList
(
le_dls_List_t *list, ///< List of atmachinestring_t
const char **patternListPtr ///< List of pattern
)
{
uint32_t i = 0;
if (!patternListPtr) {
return;
}
while(patternListPtr[i] != NULL) {
atmachinestring_t* newStringPtr = le_mem_ForceAlloc(AtStringPool);
LE_FATAL_IF(
(strlen(patternListPtr[i])>ATSTRING_SIZE),
"%s is too long (%zd): Max size %d",
patternListPtr[i],strlen(patternListPtr[i]),ATSTRING_SIZE);
strncpy(newStringPtr->line,patternListPtr[i],ATSTRING_SIZE);
newStringPtr->line[ATSTRING_SIZE-1]='\0';
newStringPtr->link = LE_DLS_LINK_INIT;
le_dls_Queue(list,&(newStringPtr->link));
i++;
}
}
开发者ID:mbarazzouq,项目名称:legato-af,代码行数:29,代码来源:atMachineString.c
示例16: thread_GetSemaphoreRecPtr
//--------------------------------------------------------------------------------------------------
void le_sem_Wait
(
le_sem_Ref_t semaphorePtr ///< [IN] Pointer to the semaphore
)
{
// TODO: Implement this:
// if (semaphorePtr->isTraceable)
// {
// }
// else
{
int result;
sem_ThreadRec_t* perThreadRecPtr = thread_GetSemaphoreRecPtr();
ListOfSemaphoresChgCnt++;
perThreadRecPtr->waitingOnSemaphore = semaphorePtr;
AddToWaitingList(semaphorePtr, perThreadRecPtr);
result = sem_wait(&semaphorePtr->semaphore);
RemoveFromWaitingList(semaphorePtr, perThreadRecPtr);
ListOfSemaphoresChgCnt++;
perThreadRecPtr->waitingOnSemaphore = NULL;
LE_FATAL_IF( (result!=0), "Thread '%s' failed to wait on semaphore '%s'. Error code %d (%m).",
le_thread_GetMyName(),
semaphorePtr->nameStr,
result);
}
}
开发者ID:tegoo,项目名称:legato-af,代码行数:32,代码来源:semaphores.c
示例17: fd_ReadLine
//--------------------------------------------------------------------------------------------------
static pid_t GetTasksId
(
int fd ///< [IN] File descriptor to an opened procs or tasks file.
)
{
// Read a pid from the file.
pid_t pid;
char pidStr[100];
le_result_t result = fd_ReadLine(fd, pidStr, sizeof(pidStr));
LE_FATAL_IF(result == LE_OVERFLOW, "Buffer to read PID is too small.");
if (result == LE_OK)
{
// Convert the string to a pid and store it in the caller's buffer.
le_result_t r = le_utf8_ParseInt(&pid, pidStr);
if (r == LE_OK)
{
return pid;
}
LE_ERROR("Could not convert '%s' to a PID. %s.", pidStr, LE_RESULT_TXT(r));
result = LE_FAULT;
}
return result;
}
开发者ID:H-H-bin,项目名称:legato-af,代码行数:29,代码来源:cgroups.c
示例18: GetService
//--------------------------------------------------------------------------------------------------
le_msg_ServiceRef_t le_msg_CreateService
(
le_msg_ProtocolRef_t protocolRef, ///< [in] Reference to the protocol to be used.
const char* serviceName ///< [in] The service instance name.
)
//--------------------------------------------------------------------------------------------------
{
// Must lock the mutex to prevent races between different threads trying to offer the
// same service at the same time, or one thread trying to delete a service while another
// tries to create it, or accessing the Service List hashmap while another thread
// is updating it.
LOCK
// Get a Service object.
Service_t* servicePtr = GetService(protocolRef, serviceName);
// If the Service object already has a server thread, then it means that this service
// is already being offered by someone else in this very process.
LE_FATAL_IF(servicePtr->serverThread != NULL,
"Duplicate service (%s:%s) offered in same process.",
serviceName,
le_msg_GetProtocolIdStr(protocolRef));
servicePtr->serverThread = le_thread_GetCurrent();
UNLOCK
return servicePtr;
}
开发者ID:andreasanna,项目名称:legato-af,代码行数:31,代码来源:messagingService.c
示例19: le_utf8_Append
//--------------------------------------------------------------------------------------------------
void userAddRemove_Add
(
const char* appName
)
//--------------------------------------------------------------------------------------------------
{
le_result_t result;
uid_t uid;
gid_t gid;
char userName[256] = "app";
result = le_utf8_Append(userName, appName, sizeof(userName), NULL);
LE_FATAL_IF(result != LE_OK, "App name '%s' is too long.", appName);
LE_INFO("Creating user '%s' for application '%s'.", userName, appName);
// Start a read transaction and go to node /apps/app-name
le_cfg_ConnectService();
le_cfg_IteratorRef_t i = le_cfg_CreateReadTxn("/apps");
le_cfg_GoToNode(i, appName);
// If the node doesn't exist, bail out.
if (!le_cfg_NodeExists(i, ""))
{
fprintf(stderr, "** ERROR: App '%s' doesn't exist in the system configuration.\n", appName);
}
else
{
result = user_Create(userName, &uid, &gid);
if (result == LE_OK)
{
printf("Created user '%s' (uid %u, gid %u).\n", userName, uid, gid);
// TODO: Groups configuration.
le_cfg_CancelTxn(i);
exit(EXIT_SUCCESS);
}
else if (result == LE_DUPLICATE)
{
// TODO: Verify correct groups configuration.
printf("User '%s' already exists (uid %u, gid %u).\n", userName, uid, gid);
le_cfg_CancelTxn(i);
exit(EXIT_SUCCESS);
}
else
{
fprintf(stderr, "** ERROR: user_Create() failed for user '%s'.\n", userName);
}
}
le_cfg_CancelTxn(i);
exit(EXIT_FAILURE);
}
开发者ID:andreasanna,项目名称:legato-af,代码行数:61,代码来源:userAdderRemover.c
示例20: LE_ASSERT
//--------------------------------------------------------------------------------------------------
void le_mem_DeleteSubPool
(
le_mem_PoolRef_t subPool ///< [IN] The sub-pool to be deleted.
)
{
LE_ASSERT(subPool != NULL);
Lock();
// Make sure all sub-pool objects are free.
le_mem_PoolRef_t superPool = subPool->superPoolPtr;
LE_FATAL_IF(subPool->numBlocksInUse != 0,
"Subpool '%s' deleted while %zu blocks remain allocated.",
subPool->name,
subPool->numBlocksInUse);
size_t numBlocks = subPool->totalBlocks;
// Move the blocks from the subPool back to the superpool.
MoveBlocks(superPool, subPool, numBlocks);
// Update the superPool's block use count.
superPool->numBlocksInUse -= numBlocks;
// Remove the sub-pool from the list of sub-pools.
ListOfPoolsChgCnt++;
le_dls_Remove(&ListOfPools, &(subPool->poolLink));
Unlock();
// Release the sub-pool.
le_mem_Release(subPool);
}
开发者ID:tegoo,项目名称:legato-af,代码行数:35,代码来源:mem.c
注:本文中的LE_FATAL_IF函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论