本文整理汇总了C++中cbdataLock函数的典型用法代码示例。如果您正苦于以下问题:C++ cbdataLock函数的具体用法?C++ cbdataLock怎么用?C++ cbdataLock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cbdataLock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: refreshCheckSubmit
void
refreshCheckSubmit(StoreEntry * entry, REFRESHCHECK * callback, void *callback_data)
{
MemBuf buf;
const char *key;
refresh_check_helper *def = Config.Program.refresh_check;
refreshCheckState *state;
dlink_node *node;
refreshCheckState *oldstate = NULL;
if (!def) {
callback(callback_data, 0, NULL);
return;
}
key = makeRefreshCheckRequest(entry, def->format);
if (!key) {
callback(callback_data, 0, NULL);
return;
}
debug(84, 2) ("refreshCheckSubmit: for '%s'\n", key);
/* Check for a pending lookup to hook into */
for (node = def->queue.head; node; node = node->next) {
refreshCheckState *oldstatetmp = node->data;
if (entry == oldstatetmp->entry) {
oldstate = oldstatetmp;
break;
}
}
state = cbdataAlloc(refreshCheckState);
state->def = def;
cbdataLock(state->def);
state->entry = entry;
storeLockObject(entry);
state->callback = callback;
state->callback_data = callback_data;
cbdataLock(state->callback_data);
if (oldstate) {
/* Hook into pending lookup */
state->queue = oldstate->queue;
oldstate->queue = state;
} else {
/* No pending lookup found. Sumbit to helper */
/* Check for queue overload */
if (refreshCheckOverload(def)) {
debug(84, 1) ("refreshCheckSubmit: queue overload\n");
cbdataFree(state);
callback(callback_data, 0, "Overload");
return;
}
/* Send it off to the helper */
memBufDefInit(&buf);
memBufPrintf(&buf, "%s\n", key);
helperSubmit(def->helper, buf.buf, refreshCheckHandleReply, state);
dlinkAdd(state, &state->list, &def->queue);
memBufClean(&buf);
}
}
示例2: authenticateBasicStart
/* send the initial data to a basic authenticator module */
static void
authenticateBasicStart(auth_user_request_t * auth_user_request, RH * handler, void *data)
{
authenticateStateData *r = NULL;
char buf[8192];
char user[1024], pass[1024];
basic_data *basic_auth;
assert(auth_user_request);
assert(handler);
assert(auth_user_request->auth_user->auth_type == AUTH_BASIC);
assert(auth_user_request->auth_user->scheme_data != NULL);
basic_auth = auth_user_request->auth_user->scheme_data;
debug(29, 9) ("authenticateStart: '%s:%s'\n", basic_auth->username,
basic_auth->passwd);
if (basicConfig->authenticate == NULL) {
handler(data, NULL);
return;
}
/* check to see if the auth_user already has a request outstanding */
if (basic_auth->flags.credentials_ok == 2) {
/* there is a request with the same credentials already being verified */
auth_basic_queue_node *node;
node = xmalloc(sizeof(auth_basic_queue_node));
assert(node);
/* save the details */
node->next = basic_auth->auth_queue;
basic_auth->auth_queue = node;
node->handler = handler;
node->data = data;
cbdataLock(data);
return;
} else {
r = cbdataAlloc(authenticateStateData);
r->handler = handler;
cbdataLock(data);
r->data = data;
r->auth_user_request = auth_user_request;
authenticateAuthUserRequestLock(r->auth_user_request);
/* mark the user as haveing verification in progress */
basic_auth->flags.credentials_ok = 2;
if (basicConfig->utf8) {
latin1_to_utf8(user, sizeof(user), basic_auth->username);
latin1_to_utf8(pass, sizeof(pass), basic_auth->passwd);
xstrncpy(user, rfc1738_escape(user), sizeof(user));
xstrncpy(pass, rfc1738_escape(pass), sizeof(pass));
} else {
xstrncpy(user, rfc1738_escape(basic_auth->username), sizeof(user));
xstrncpy(pass, rfc1738_escape(basic_auth->passwd), sizeof(pass));
}
snprintf(buf, sizeof(buf), "%s %s\n", user, pass);
helperSubmit(basicauthenticators, buf, authenticateBasicHandleReply, r);
}
}
示例3: helperStatefulSubmit
void
helperStatefulSubmit(statefulhelper * hlp, const char *buf, HLPSCB * callback, void *data, helper_stateful_server * srv)
{
helper_stateful_request *r = memAllocate(MEM_HELPER_STATEFUL_REQUEST);
if (hlp == NULL) {
debug(84, 3) ("helperStatefulSubmit: hlp == NULL\n");
callback(data, 0, NULL);
return;
}
r->callback = callback;
r->data = data;
if (buf)
r->buf = xstrdup(buf);
cbdataLock(r->data);
if (!srv)
srv = helperStatefulGetServer(hlp);
if (srv) {
debug(84, 5) ("helperStatefulSubmit: sever %p, buf '%s'.\n", srv, buf ? buf : "NULL");
assert(!srv->request);
assert(!srv->flags.busy);
helperStatefulDispatch(srv, r);
} else {
debug(84, 9) ("helperStatefulSubmit: enqueued, buf '%s'.\n", buf ? buf : "NULL");
StatefulEnqueue(hlp, r);
}
}
示例4: storeClientListAdd
/* add client with fd to client list */
store_client *
storeClientListAdd(StoreEntry * e, void *data)
{
MemObject *mem = e->mem_obj;
store_client *sc;
assert(mem);
#if STORE_CLIENT_LIST_DEBUG
if (storeClientListSearch(mem, data) != NULL)
assert(1 == 0); /* XXX die! */
#endif
e->refcount++;
mem->nclients++;
sc = cbdataAlloc(store_client);
cbdataLock(data); /* locked while we point to it */
sc->callback_data = data;
sc->seen_offset = 0;
sc->copy_offset = 0;
sc->flags.disk_io_pending = 0;
sc->entry = e;
sc->type = storeClientType(e);
dlinkAdd(sc, &sc->node, &mem->clients);
#if DELAY_POOLS
sc->delay_id = 0;
#endif
return sc;
}
示例5: authenticateDigestStart
/* send the initial data to a digest authenticator module */
static void
authenticateDigestStart(auth_user_request_t * auth_user_request, RH * handler, void *data)
{
authenticateStateData *r = NULL;
char buf[8192];
digest_request_h *digest_request;
digest_user_h *digest_user;
assert(auth_user_request);
assert(handler);
assert(auth_user_request->auth_user->auth_type == AUTH_DIGEST);
assert(auth_user_request->auth_user->scheme_data != NULL);
assert(auth_user_request->scheme_data != NULL);
digest_request = auth_user_request->scheme_data;
digest_user = auth_user_request->auth_user->scheme_data;
debug(29, 9) ("authenticateStart: '\"%s\":\"%s\"'\n", digest_user->username,
digest_request->realm);
if (digestConfig->authenticate == NULL) {
handler(data, NULL);
return;
}
r = cbdataAlloc(authenticateStateData);
r->handler = handler;
cbdataLock(data);
r->data = data;
r->auth_user_request = auth_user_request;
authenticateAuthUserRequestLock(r->auth_user_request);
snprintf(buf, 8192, "\"%s\":\"%s\"\n", digest_user->username, digest_request->realm);
helperSubmit(digestauthenticators, buf, authenticateDigestHandleReply, r);
}
示例6: idnsPTRLookup
void
idnsPTRLookup(const struct in_addr addr, IDNSCB * callback, void *data)
{
idns_query *q;
const char *ip = inet_ntoa(addr);
q = cbdataAlloc(idns_query);
q->tcp_socket = -1;
q->id = idnsQueryID();
q->sz = rfc1035BuildPTRQuery(addr, q->buf, sizeof(q->buf), q->id, &q->query);
debug(78, 3) ("idnsPTRLookup: buf is %d bytes for %s, id = %#hx\n",
(int) q->sz, ip, q->id);
if (q->sz < 0) {
/* problem with query data -- query not sent */
callback(data, NULL, 0, "Internal error");
cbdataFree(q);
return;
}
if (idnsCachedLookup(q->query.name, callback, data)) {
cbdataFree(q);
return;
}
q->callback = callback;
q->callback_data = data;
cbdataLock(q->callback_data);
q->start_t = current_time;
idnsCacheQuery(q);
idnsSendQuery(q);
}
示例7: peerSelect
void
peerSelect(request_t * request,
StoreEntry * entry,
PSC * callback,
void *callback_data)
{
ps_state *psstate;
if (entry)
debug(44, 3) ("peerSelect: %s\n", storeUrl(entry));
else
debug(44, 3) ("peerSelect: %s\n", RequestMethods[request->method].str);
psstate = cbdataAlloc(ps_state);
psstate->request = requestLink(request);
psstate->entry = entry;
psstate->callback = callback;
psstate->callback_data = callback_data;
psstate->direct = DIRECT_UNKNOWN;
#if USE_CACHE_DIGESTS
request->hier.peer_select_start = current_time;
#endif
if (psstate->entry)
storeLockObject(psstate->entry);
cbdataLock(callback_data);
peerSelectFoo(psstate);
}
示例8: errorMapStart
int
errorMapStart(const errormap * map, request_t * client_req, HttpReply * reply, const char *aclname, ERRMAPCB * callback, void *callback_data)
{
char squid_error[100];
int len = 0;
const char *errorUrl;
ErrorMapState *state;
const char *tmp;
http_status status;
request_t *req;
HttpHeaderPos hdrpos;
HttpHeaderEntry *hdr;
if (!client_req || !reply)
return 0;
status = reply->sline.status;
tmp = httpHeaderGetStr(&reply->header, HDR_X_SQUID_ERROR);
squid_error[0] = '\0';
if (tmp) {
xstrncpy(squid_error, tmp, sizeof(squid_error));
len = strcspn(squid_error, " ");
}
squid_error[len] = '\0';
errorUrl = getErrorMap(map, status, squid_error, aclname);
if (!errorUrl)
return 0;
req = urlParse(urlMethodGetKnownByCode(METHOD_GET), (char *) errorUrl);
if (!req) {
debug(0, 0) ("errorMapStart: Invalid error URL '%s'\n", errorUrl);
return 0;
}
req->urlgroup = xstrdup("error");
state = cbdataAlloc(ErrorMapState);
state->req = requestLink(req);
state->e = storeCreateEntry(errorUrl, req->flags, req->method);
state->sc = storeClientRegister(state->e, state);
state->callback = callback;
state->callback_data = callback_data;
cbdataLock(callback_data);
hdrpos = HttpHeaderInitPos;
while ((hdr = httpHeaderGetEntry(&client_req->header, &hdrpos)) != NULL) {
if (CBIT_TEST(client_headers, hdr->id))
httpHeaderAddClone(&req->header, hdr);
}
hdrpos = HttpHeaderInitPos;
while ((hdr = httpHeaderGetEntry(&reply->header, &hdrpos)) != NULL) {
if (CBIT_TEST(server_headers, hdr->id))
httpHeaderAddClone(&req->header, hdr);
}
httpHeaderPutInt(&req->header, HDR_X_ERROR_STATUS, (int) reply->sline.status);
httpHeaderPutStr(&req->header, HDR_X_REQUEST_URI, urlCanonical(client_req));
fwdStart(-1, state->e, req);
storeClientRef(state->sc, state->e, 0, 0, SM_PAGE_SIZE, errorMapFetchHeaders, state);
return 1;
}
示例9: aioWrite
void
aioWrite(int fd, int offset, char *bufp, int len, AIOCB * callback, void *callback_data, FREE * free_func)
{
squidaio_ctrl_t *ctrlp;
int seekmode;
assert(initialised);
squidaio_counts.write++;
ctrlp = memPoolAlloc(squidaio_ctrl_pool);
ctrlp->fd = fd;
ctrlp->done_handler = callback;
ctrlp->done_handler_data = callback_data;
ctrlp->operation = _AIO_WRITE;
ctrlp->bufp = bufp;
ctrlp->free_func = free_func;
if (offset >= 0)
seekmode = SEEK_SET;
else {
seekmode = SEEK_END;
offset = 0;
}
cbdataLock(callback_data);
ctrlp->result.data = ctrlp;
squidaio_write(fd, bufp, len, offset, seekmode, &ctrlp->result);
dlinkAdd(ctrlp, &ctrlp->node, &used_list);
} /* aioWrite */
示例10: aioRead
void
aioRead(int fd, int offset, int len, AIOCB * callback, void *callback_data)
{
squidaio_ctrl_t *ctrlp;
int seekmode;
assert(initialised);
squidaio_counts.read++;
ctrlp = memPoolAlloc(squidaio_ctrl_pool);
ctrlp->fd = fd;
ctrlp->done_handler = callback;
ctrlp->done_handler_data = callback_data;
ctrlp->operation = _AIO_READ;
ctrlp->len = len;
ctrlp->bufp = squidaio_xmalloc(len);
if (offset >= 0)
seekmode = SEEK_SET;
else {
seekmode = SEEK_CUR;
offset = 0;
}
cbdataLock(callback_data);
ctrlp->result.data = ctrlp;
squidaio_read(fd, ctrlp->bufp, len, offset, seekmode, &ctrlp->result);
dlinkAdd(ctrlp, &ctrlp->node, &used_list);
return;
} /* aioRead */
示例11: aioOpen
void
aioOpen(const char *path, int oflag, mode_t mode, AIOCB * callback, void *callback_data)
{
aio_ctrl_t *ctrlp;
int ret;
assert(initialised);
aio_counts.open++;
ctrlp = memPoolAlloc(aio_ctrl_pool);
ctrlp->fd = -2;
ctrlp->done_handler = callback;
ctrlp->done_handler_data = callback_data;
ctrlp->operation = _AIO_OPEN;
cbdataLock(callback_data);
if (aio_open(path, oflag, mode, &ctrlp->result) < 0) {
ret = open(path, oflag, mode);
if (callback)
(callback) (ctrlp->fd, callback_data, ret, errno);
cbdataUnlock(callback_data);
memPoolFree(aio_ctrl_pool, ctrlp);
return;
}
ctrlp->next = used_list;
used_list = ctrlp;
return;
}
示例12: storeClientCopy2
static void
storeClientCopy2(StoreEntry * e, store_client * sc)
{
if (sc->flags.copy_event_pending)
return;
if (EBIT_TEST(e->flags, ENTRY_FWD_HDR_WAIT)) {
debug(20, 5) ("storeClientCopy2: returning because ENTRY_FWD_HDR_WAIT set\n");
return;
}
if (sc->flags.store_copying) {
sc->flags.copy_event_pending = 1;
debug(20, 3) ("storeClientCopy2: Queueing storeClientCopyEvent()\n");
eventAdd("storeClientCopyEvent", storeClientCopyEvent, sc, 0.0, 0);
return;
}
cbdataLock(sc); /* ick, prevent sc from getting freed */
sc->flags.store_copying = 1;
debug(20, 3) ("storeClientCopy2: %s\n", storeKeyText(e->hash.key));
assert(sc->callback != NULL);
/*
* We used to check for ENTRY_ABORTED here. But there were some
* problems. For example, we might have a slow client (or two) and
* the server-side is reading far ahead and swapping to disk. Even
* if the server-side aborts, we want to give the client(s)
* everything we got before the abort condition occurred.
*/
storeClientCopy3(e, sc);
sc->flags.store_copying = 0;
cbdataUnlock(sc); /* ick, allow sc to be freed */
}
示例13: aioStat
void
aioStat(char *path, struct stat *sb, AIOCB * callback, void *callback_data)
{
aio_ctrl_t *ctrlp;
assert(initialised);
aio_counts.stat++;
ctrlp = memPoolAlloc(aio_ctrl_pool);
ctrlp->fd = -2;
ctrlp->done_handler = callback;
ctrlp->done_handler_data = callback_data;
ctrlp->operation = _AIO_STAT;
cbdataLock(callback_data);
if (aio_stat(path, sb, &ctrlp->result) < 0) {
if (errno == ENOMEM || errno == EAGAIN || errno == EINVAL)
errno = EWOULDBLOCK;
if (callback)
(callback) (ctrlp->fd, callback_data, -1, errno);
cbdataUnlock(callback_data);
memPoolFree(aio_ctrl_pool, ctrlp);
return;
}
ctrlp->next = used_list;
used_list = ctrlp;
return;
} /* aioStat */
示例14: aioUnlink
void
aioUnlink(const char *pathname, AIOCB * callback, void *callback_data)
{
aio_ctrl_t *ctrlp;
char *path;
assert(initialised);
aio_counts.unlink++;
ctrlp = memPoolAlloc(aio_ctrl_pool);
ctrlp->fd = -2;
ctrlp->done_handler = callback;
ctrlp->done_handler_data = callback_data;
ctrlp->operation = _AIO_UNLINK;
path = xstrdup(pathname);
cbdataLock(callback_data);
if (aio_unlink(path, &ctrlp->result) < 0) {
int ret = unlink(path);
(callback) (ctrlp->fd, callback_data, ret, errno);
cbdataUnlock(callback_data);
memPoolFree(aio_ctrl_pool, ctrlp);
xfree(path);
return;
}
ctrlp->next = used_list;
used_list = ctrlp;
xfree(path);
} /* aioUnlink */
示例15: storeSwapInStart
void
storeSwapInStart(store_client * sc)
{
StoreEntry *e = sc->entry;
assert(e->mem_status == NOT_IN_MEMORY);
if (!EBIT_TEST(e->flags, ENTRY_VALIDATED)) {
/* We're still reloading and haven't validated this entry yet */
return;
}
debug(20, 3) ("storeSwapInStart: called for %08X %s \n",
e->swap_file_number, storeKeyText(e->key));
if (e->swap_status != SWAPOUT_WRITING && e->swap_status != SWAPOUT_DONE) {
debug(20, 1) ("storeSwapInStart: bad swap_status (%s)\n",
swapStatusStr[e->swap_status]);
return;
}
if (e->swap_file_number < 0) {
debug(20, 1) ("storeSwapInStart: swap_file_number < 0\n");
return;
}
assert(e->mem_obj != NULL);
debug(20, 3) ("storeSwapInStart: Opening fileno %08X\n",
e->swap_file_number);
sc->swapin_sio = storeOpen(e->swap_file_number,
O_RDONLY,
storeSwapInFileClosed,
sc);
cbdataLock(sc->swapin_sio);
}