本文整理汇总了C++中StringRef::release_ref方法的典型用法代码示例。如果您正苦于以下问题:C++ StringRef::release_ref方法的具体用法?C++ StringRef::release_ref怎么用?C++ StringRef::release_ref使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringRef
的用法示例。
在下文中一共展示了StringRef::release_ref方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: list_threads
/*
* generate a human-readable status report of my threads
*/
void TadsListenerThread::list_threads(NetString *buf)
{
/* protect against concurrent access */
mutex->lock();
/* scan threads */
for (TadsServerThread *cur = servers ; cur != 0 ; cur = cur->next_server)
{
/* report on this thread */
StringRef *state = cur->get_state();
buf->appendf("Thread ID=%d (thread object=%lx): %s<br>",
cur->thread_id, (unsigned long)cur, state->get());
/* done with the state string */
state->release_ref();
}
/* done with concurrent access protection */
mutex->unlock();
}
示例2: process_request
//.........这里部分代码省略.........
* newline, following the '0' end length marker, so we're in
* state 2. We could have either another newline following, or
* "trailers" (more headers, following the content body).
*/
long nlofs = read_to_nl(body, ofs, 2, 4);
if (nlofs < 0)
goto done;
/*
* if we have more than just the closing blank line, we have
* trailers - append them to the headers
*/
if (nlofs > ofs + 2)
{
TadsHttpRequestHeader::parse_headers(
hdr_list, hdr_tail, TRUE, body, ofs);
}
/*
* the trailers (if any) and closing newline aren't part of the
* content - clip them out of the body
*/
body->truncate(ofs);
}
else
{
/*
* Other combinations of these headers are illegal. Send an
* error and abort.
*/
send_simple(S_http_400, "text/html",
"<html><title>Bad Request</title>"
"<h1>Bad Request</h1>"
"This server does not accept the specified "
"transfer-encoding.");
goto done;
}
done_with_upload:
/* done with the upload - check for overflow */
if (overflow)
{
/* release the body, if present */
if (body != 0)
{
body->release_ref();
body = 0;
}
}
}
/* create a message object for the request */
req = new TadsHttpRequest(
this, verb, verb_len, hdrs, hdr_list, body, overflow,
resource_name, res_name_len,
listener->get_shutdown_evt());
/* we've handed over the header list to the request */
hdr_list = 0;
/* send it to the main thread, and wait for the reply */
if (queue->send(req, OS_FOREVER))
{
/*
* success - the server will already have sent the reply, so we're
* done
*/
}
else if (queue->is_quitting())
{
/* failed due to server shutdown */
send_simple(S_http_503, "text/html", S_http_503_quitting_body);
}
else
{
/* 'send' failed - return an internal server error */
send_simple(S_http_500, "text/html", S_http_500_body);
}
/* we're done with the request */
req->release_ref();
/* success */
ok = TRUE;
done:
/* release the message body buffer */
if (body != 0)
body->release_ref();
/* release the header buffer */
hdrs->release_ref();
/* delete the header list */
if (hdr_list != 0)
delete hdr_list;
/* return the success/failure indication */
return ok;
}