本文整理汇总了C++中LM_E函数的典型用法代码示例。如果您正苦于以下问题:C++ LM_E函数的具体用法?C++ LM_E怎么用?C++ LM_E使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LM_E函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: semInit
/* ****************************************************************************
*
* semInit -
*
* parameter #2: 0 - the semaphore is to be shared between threads,
* parameter #3: 1 - initially the semaphore is free
*
* RETURN VALUE (of sem_init)
* 0 on success,
* -1 on failure
*
*/
int semInit(SemOpType _reqPolicy, bool semTimeStat, int shared, int takenInitially)
{
if (sem_init(&reqSem, shared, takenInitially) == -1)
{
LM_E(("Runtime Error (error initializing 'req' semaphore: %s)", strerror(errno)));
return -1;
}
if (sem_init(&transSem, shared, takenInitially) == -1)
{
LM_E(("Runtime Error (error initializing 'transactionId' semaphore: %s)", strerror(errno)));
return -1;
}
if (sem_init(&cacheSem, shared, takenInitially) == -1)
{
LM_E(("Runtime Error (error initializing 'cache' semaphore: %s)", strerror(errno)));
return -1;
}
if (sem_init(&timeStatSem, shared, takenInitially) == -1)
{
LM_E(("Runtime Error (error initializing 'timeStat' semaphore: %s)", strerror(errno)));
return -1;
}
reqPolicy = _reqPolicy;
// Measure accumulated semaphore waiting time?
semWaitStatistics = semTimeStat;
return 0;
}
示例2: attributeValue
/* ****************************************************************************
*
* attributeValue - return value of attribute as a string
*/
static void attributeValue(std::string* valueP, const std::vector<ContextAttribute*>& vec, char* attrName)
{
for (unsigned int ix = 0; ix < vec.size(); ++ix)
{
if (vec[ix]->name != attrName)
{
continue;
}
if (vec[ix]->valueType == orion::ValueTypeString)
{
*valueP = vec[ix]->stringValue;
}
else if (vec[ix]->valueType == orion::ValueTypeNumber)
{
*valueP = toString(vec[ix]->numberValue);
}
else if (vec[ix]->valueType == orion::ValueTypeBoolean)
{
*valueP = (vec[ix]->boolValue == true)? "true" : "false";
}
else if (vec[ix]->valueType == orion::ValueTypeNone)
{
*valueP = "null";
}
else if ((vec[ix]->valueType == orion::ValueTypeObject) || (vec[ix]->valueType == orion::ValueTypeVector))
{
if (vec[ix]->compoundValueP)
{
if (vec[ix]->compoundValueP->valueType == orion::ValueTypeVector)
{
*valueP = "[" + vec[ix]->compoundValueP->toJson(true) + "]";
}
else if (vec[ix]->compoundValueP->valueType == orion::ValueTypeObject)
{
*valueP = "{" + vec[ix]->compoundValueP->toJson(true) + "}";
}
else
{
LM_E(("Runtime Error (attribute is of object type but its compound is of invalid type)"));
*valueP = "";
}
}
else
{
LM_E(("Runtime Error (attribute is of object type but has no compound)"));
*valueP = "";
}
}
else
{
LM_E(("Runtime Error (unknown value type for attribute)"));
*valueP = "";
}
return;
}
*valueP = "";
}
示例3: response
/* ****************************************************************************
*
* RegisterContextRequest::check -
*/
std::string RegisterContextRequest::check(RequestType requestType, Format format, std::string indent, std::string predetectedError, int counter)
{
RegisterContextResponse response(this);
std::string res;
if (predetectedError != "")
{
LM_E(("predetectedError not empty"));
response.errorCode.fill(SccBadRequest, predetectedError);
}
else if (contextRegistrationVector.size() == 0)
{
LM_E(("contextRegistrationVector.size() == 0"));
response.errorCode.fill(SccBadRequest, "Empty Context Registration List");
}
else if (((res = contextRegistrationVector.check(RegisterContext, format, indent, predetectedError, counter)) != "OK") ||
((res = duration.check(RegisterContext, format, indent, predetectedError, counter)) != "OK") ||
((res = registrationId.check(RegisterContext, format, indent, predetectedError, counter)) != "OK"))
{
LM_E(("Some check method failed: %s", res.c_str()));
response.errorCode.fill(SccBadRequest, res);
}
else
return "OK";
LM_E(("Not OK - returning rendered error result"));
return response.render(RegisterContext, format, indent);
}
示例4: pthread_cancel
/* ****************************************************************************
*
* Notifier::destroyOntimeIntervalThreads -
*/
void Notifier::destroyOntimeIntervalThreads(const std::string& subId) {
std::vector<pthread_t> canceled;
/* Get all the ThreadParams associated to the given subId. Inspired in
* http://advancedcppwithexamples.blogspot.com.es/2009/04/example-of-c-multimap.html
*/
std::pair<std::multimap<std::string, ThreadData>::iterator, std::multimap<std::string, ThreadData>::iterator> ii;
std::multimap<std::string, ThreadData>::iterator it;
ii = this->threadsMap.equal_range(subId);
for (it = ii.first; it != ii.second; ++it) {
ThreadData td = it->second;
/* Destroy thread */
int ret = pthread_cancel(td.tid);
if (ret != 0)
{
LM_E(("Runtime Error (error canceling thread %lu: %d)", (unsigned long) td.tid, ret));
return;
}
/* Note that we do the cancelation in parallel, storing the thread ID. This
* vector is processed afterwards to wait for every thread to finish */
canceled.push_back(td.tid);
/* Release memory */
delete td.params;
}
/* Remove key from the hashmap */
threadsMap.erase(subId);
/* Wait for all the cancelation to end */
for (unsigned int ix = 0; ix < canceled.size(); ++ix) {
void* res;
/* pthread_join in blocking */
int ret = pthread_join(canceled[ix], &res);
if (ret != 0)
{
LM_E(("Runtime Error (error joining thread %lu: %d)", (unsigned long) canceled[ix], ret));
return;
}
if (res == PTHREAD_CANCELED)
{
LM_T(LmtNotifier, ("canceled thread: %lu", (unsigned long) canceled[ix]));
}
else
{
LM_E(("Runtime Error (unexpected error: thread can not be canceled)"));
return;
}
}
canceled.clear();
}
示例5: jsonTreat
/* ****************************************************************************
*
* jsonTreat -
*/
std::string jsonTreat(const char* content, ConnectionInfo* ciP, ParseData* parseDataP, RequestType request, std::string payloadWord, JsonRequest** reqPP)
{
std::string res = "OK";
JsonRequest* reqP = jsonRequestGet(request, ciP->method);
LM_T(LmtParse, ("Treating a JSON request: '%s'", content));
ciP->parseDataP = parseDataP;
if (reqP == NULL)
{
std::string errorReply = restErrorReplyGet(ciP, ciP->outFormat, "", requestType(request), SccBadRequest,
std::string("Sorry, no request treating object found for RequestType '") + requestType(request) + "'");
LM_RE(errorReply, ("Sorry, no request treating object found for RequestType %d (%s)", request, requestType(request)));
}
if (reqPP != NULL)
*reqPP = reqP;
LM_T(LmtParse, ("Treating '%s' request", reqP->keyword.c_str()));
reqP->init(parseDataP);
try
{
res = jsonParse(ciP, content, reqP->keyword, reqP->parseVector, parseDataP);
if (ciP->inCompoundValue == true)
orion::compoundValueEnd(ciP, parseDataP);
if ((lmTraceIsSet(LmtCompoundValueShow)) && (ciP->compoundValueP != NULL))
ciP->compoundValueP->shortShow("after parse: ");
}
catch (std::exception &e)
{
std::string errorReply = restErrorReplyGet(ciP, ciP->outFormat, "", reqP->keyword, SccBadRequest, std::string("JSON Parse Error: ") + e.what());
LM_E(("JSON Parse Error: '%s'", e.what()));
LM_RE(errorReply, (res.c_str()));
}
if (res != "OK")
{
LM_E(("JSON parse error: %s", res.c_str()));
ciP->httpStatusCode = SccBadRequest;
std::string answer = restErrorReplyGet(ciP, ciP->outFormat, "", payloadWord, ciP->httpStatusCode, res);
return answer;
}
reqP->present(parseDataP);
LM_T(LmtParseCheck, ("Calling check for JSON parsed tree (%s)", ciP->payloadWord));
res = reqP->check(parseDataP, ciP);
reqP->present(parseDataP);
return res;
}
示例6: treat
/* ****************************************************************************
*
* treat -
*
* This is the function that actually treats a node, bu calling its treat function
* provided by src/lib/xmlRequest - the entry point of XML parsing.
*
* It simple compares the current path with the paths in the incoming vector 'parseVector'
* and if a hit is found calls the 'treat' function of that hit (the instance of the vector).
*
* If no hit is found it means that the path of the current XML node is unknown.
* This will result in either a 'PARSE ERROR' or thatthe node is part of a Compound.
*/
static bool treat(ConnectionInfo* ciP, xml_node<>* node, const std::string& path, XmlNode* parseVector, ParseData* parseDataP)
{
for (unsigned int ix = 0; parseVector[ix].path != "LAST"; ++ix)
{
if (path == parseVector[ix].path)
{
int r;
//
// Before treating a node, a check is made that the value of the node has no forbidden
// characters.
// However, if the the node has attributes, then the values of the attributes are checked instead
//
if (node->first_attribute() == NULL)
{
if (forbiddenChars(node->value()) == true)
{
LM_E(("Found a forbidden value in '%s'", node->value()));
ciP->httpStatusCode = SccBadRequest;
ciP->answer = std::string("Illegal value for XML attribute");
return true;
}
}
else
{
for (xml_attribute<> *attr = node->first_attribute(); attr; attr = attr->next_attribute())
{
if (forbiddenChars(attr->value()) == true)
{
LM_E(("Found a forbidden value in attribute: '%s'", node->value()));
ciP->httpStatusCode = SccBadRequest;
ciP->answer = std::string("Illegal value for XML attribute");
return true;
}
}
}
if ((r = parseVector[ix].treat(node, parseDataP)) != 0)
{
LM_W(("Bad Input (xml parse error %d)", r));
}
return true; // Node has been treated
}
}
return false; // Node was not found in the parse vector
}
示例7: strToLower
/* ****************************************************************************
*
* strToLower -
*/
char* strToLower(char* to, const char* from, int toSize)
{
int fromSize = strlen(from);
if (toSize < fromSize + 1)
{
LM_E(("Runtime Error (cannot copy %d bytes into a buffer of %d bytes)", fromSize + 1, toSize));
fromSize = toSize;
}
int ix;
for (ix = 0; ix < fromSize; ix++)
{
if ((from[ix] >= 'A') && (from[ix] <= 'Z'))
{
to[ix] = from[ix] + ('a' - 'A');
}
else
{
to[ix] = from[ix];
}
}
to[ix] = 0;
return to;
}
示例8: forbiddenChars
/* ****************************************************************************
*
* forbiddenChars -
*/
bool forbiddenChars(const char* s, const char* exceptions)
{
if (s == (void*) 0)
{
return false;
}
while (*s != 0)
{
if ((exceptions != NULL) && (strchr(exceptions, *s) != NULL))
{
++s;
continue;
}
switch (*s)
{
case '<':
case '>':
case '"':
case '\'':
case '=':
case ';':
case '(':
case ')':
LM_E(("Bad Input (character '%c')", *s));
return true;
}
++s;
}
return false;
}
示例9: restReply
/* ****************************************************************************
*
* restReply -
*/
void restReply(ConnectionInfo* ciP, const std::string& answer)
{
MHD_Response* response;
++replyIx;
LM_T(LmtServiceOutPayload, ("Response %d: responding with %d bytes, Status Code %d", replyIx, answer.length(), ciP->httpStatusCode));
LM_T(LmtServiceOutPayload, ("Response payload: '%s'", answer.c_str()));
if (answer == "")
response = MHD_create_response_from_data(answer.length(), (void*) answer.c_str(), MHD_NO, MHD_NO);
else
response = MHD_create_response_from_data(answer.length(), (void*) answer.c_str(), MHD_YES, MHD_YES);
if (!response)
{
LM_E(("Runtime Error (MHD_create_response_from_buffer FAILED)"));
return;
}
for (unsigned int hIx = 0; hIx < ciP->httpHeader.size(); ++hIx)
MHD_add_response_header(response, ciP->httpHeader[hIx].c_str(), ciP->httpHeaderValue[hIx].c_str());
if (answer != "")
{
if (ciP->outFormat == XML)
MHD_add_response_header(response, "Content-Type", "application/xml");
else if (ciP->outFormat == JSON)
MHD_add_response_header(response, "Content-Type", "application/json");
}
MHD_queue_response(ciP->connection, ciP->httpStatusCode, response);
MHD_destroy_response(response);
}
示例10: clock_gettime
/* ****************************************************************************
*
* QueueNotifier::sendNotifyContextRequest -
*/
void QueueNotifier::sendNotifyContextRequest
(
NotifyContextRequest* ncr,
const ngsiv2::HttpInfo& httpInfo,
const std::string& tenant,
const std::string& xauthToken,
const std::string& fiwareCorrelator,
RenderFormat renderFormat,
const std::vector<std::string>& attrsOrder,
const std::vector<std::string>& metadataFilter,
bool blacklist
)
{
std::vector<SenderThreadParams*> *paramsV = Notifier::buildSenderParams(ncr, httpInfo, tenant, xauthToken, fiwareCorrelator, renderFormat, attrsOrder, metadataFilter, blacklist);
for (unsigned ix = 0; ix < paramsV->size(); ix++) {
clock_gettime(CLOCK_REALTIME, &(((*paramsV)[ix])->timeStamp));
}
bool enqueued = queue.try_push(paramsV);
if (!enqueued)
{
QueueStatistics::incReject(paramsV->size());
LM_E(("Runtime Error (notification queue is full)"));
for (unsigned ix = 0; ix < paramsV->size(); ix++) {
delete (*paramsV)[ix];
}
delete paramsV;
return;
}
QueueStatistics::incIn(paramsV->size());
}
示例11: get_curl_context
/* ****************************************************************************
*
* httpRequestSend -
*
* RETURN VALUES
* httpRequestSend returns 0 on success and a negative number on failure:
* -1: Invalid port
* -2: Invalid IP
* -3: Invalid verb
* -4: Invalid resource
* -5: No Content-Type BUT content present
* -6: Content-Type present but there is no content
* -7: Total outgoing message size is too big
* -8: Unable to initialize libcurl
* -9: Error making HTTP request
*
* [ error codes -1 to -7 comes from httpRequestSendWithCurl ]
*/
int httpRequestSend
(
const std::string& _ip,
unsigned short port,
const std::string& protocol,
const std::string& verb,
const std::string& tenant,
const std::string& servicePath,
const std::string& xauthToken,
const std::string& resource,
const std::string& orig_content_type,
const std::string& content,
const std::string& fiwareCorrelation,
const std::string& ngisv2AttrFormat,
bool useRush,
bool waitForResponse,
std::string* outP,
const std::string& acceptFormat,
long timeoutInMilliseconds
)
{
struct curl_context cc;
int response;
get_curl_context(_ip, &cc);
if (cc.curl == NULL)
{
release_curl_context(&cc);
LM_E(("Runtime Error (could not init libcurl)"));
lmTransactionEnd();
*outP = "error";
return -8;
}
response = httpRequestSendWithCurl(cc.curl,
_ip,
port,
protocol,
verb,
tenant,
servicePath,
xauthToken,
resource,
orig_content_type,
content,
fiwareCorrelation,
ngisv2AttrFormat,
useRush,
waitForResponse,
outP,
acceptFormat,
timeoutInMilliseconds);
release_curl_context(&cc);
return response;
}
示例12: LM_E
/* ****************************************************************************
*
* AlarmManager::semInit -
*/
int AlarmManager::semInit(void)
{
if (sem_init(&sem, 0, 1) == -1)
{
LM_E(("Runtime Error (error initializing 'alarm mgr' semaphore: %s)", strerror(errno)));
return -1;
}
return 0;
}
示例13: SenderThreadParams
/* ****************************************************************************
*
* Notifier::sendNotifyContextAvailabilityRequest -
*
* FIXME: this method is very similar to sendNotifyContextRequest and probably
* they could be refactored in the future to have a common part using a parent
* class for both types of notifications and using it as first argument
*/
void Notifier::sendNotifyContextAvailabilityRequest
(
NotifyContextAvailabilityRequest* ncar,
const std::string& url,
const std::string& tenant,
const std::string& fiwareCorrelator,
RenderFormat renderFormat
)
{
/* Render NotifyContextAvailabilityRequest */
std::string payload = ncar->render(NotifyContextAvailability, "");
/* Parse URL */
std::string host;
int port;
std::string uriPath;
std::string protocol;
if (!parseUrl(url, host, port, uriPath, protocol))
{
std::string details = std::string("sending NotifyContextAvailabilityRequest: malformed URL: '") + url + "'";
alarmMgr.badInput(clientIp, details);
return;
}
/* Set Content-Type */
std::string content_type = "application/json";
/* Send the message (without awaiting response, in a separate thread to avoid blocking) */
pthread_t tid;
SenderThreadParams* params = new SenderThreadParams();
params->ip = host;
params->port = port;
params->verb = "POST";
params->tenant = tenant;
params->resource = uriPath;
params->content_type = content_type;
params->content = payload;
params->mimeType = JSON;
params->fiwareCorrelator = fiwareCorrelator;
params->renderFormat = renderFormatToString(renderFormat);
strncpy(params->transactionId, transactionId, sizeof(params->transactionId));
int ret = pthread_create(&tid, NULL, startSenderThread, params);
if (ret != 0)
{
LM_E(("Runtime Error (error creating thread: %d)", ret));
return;
}
pthread_detach(tid);
}
示例14: LM_E
/* ****************************************************************************
*
* SubscriptionCache::insert -
*/
void SubscriptionCache::insert(Subscription* subP)
{
if (subP->entityIdInfos.size() == 0)
{
LM_E(("Runtime Error (no entity for subscription - not inserted in subscription cache)"));
return;
}
subs.push_back(subP);
++noOfSubCacheEntries;
}
示例15: semInit
/* ****************************************************************************
*
* semInit -
*
* parameter #1: 0 - the semaphore is to be shared between threads,
* parameter #2: 1 - initially the semaphore is free
*
* RETURN VALUE (of sem_init)
* 0 on success,
* -1 on failure
*
*/
int semInit(int shared, int takenInitially)
{
if (sem_init(&reqSem, shared, takenInitially) == -1)
{
LM_E(("Runtime Error (error initializing 'req' semaphore: %s)", strerror(errno)));
return 1;
}
if (sem_init(&mongoSem, shared, takenInitially) == -1)
{
LM_E(("Runtime Error (error initializing 'mongo' semaphore: %s)", strerror(errno)));
return 2;
}
if (sem_init(&transSem, shared, takenInitially) == -1)
{
LM_E(("Runtime Error (error initializing 'transactionId' semaphore: %s)", strerror(errno)));
return 3;
}
return 0;
}