Re: Store client API

From: anita <anita.sivakumar_at_wipro.com>
Date: Mon, 7 May 2012 21:12:40 -0700 (PDT)

I kind of traced the cachemanager APIs. And found a way to pick up the
ipcache details. Not sure if what I am doing is 100% correct but it seems to
give me the result.

Would really appreciate any comments on this - it will guide me on whether
my approach is proper or not.

I call this API in client_side_reply.cc in clientReplyContext::processMiss()
by passing ipcacheprint(clientReplyContext*). This I am doing it only for a
test purpose. The actual place will be elsewhere - probably after the link
is fetched. I am trying to find this place, but not yet successful.

My doubts:
I had to pass the clientReplyContext* pointer to my function as otherwise I
get a segmentation fault in storeClientCopy() where they check if this is
null or not as they do a cbdataReference(data) in the _callback function.
I am not sure if I can simply add to the store otherwise? What if I had to
call this API from some random place that does not have a cbdatareference?
Can I still do it? In short how do I use the storeClientCopy function in
that case? Is my usage correct?

Would also appreciate if somebody could give me an overview of how the store
works. What APIs should I concentrate on to add a content to the store?

My test API for printing the ipcache contents. I am using Squid 3.1.16.

void ipcacheprint(void *data)
{

    char *uri = (char *)xmalloc(MAX_URL * sizeof(char));
    snprintf(uri, MAX_URL, "cache_object://myserver/ipcache");

    StoreEntry *e = storeCreateEntry(uri, uri, request_flags(), METHOD_GET);
    store_client *sc = storeClientListAdd(e, data);

    std::cout << "Mem-obj size = " << e->mem_obj->object_sz << std::endl;

    StoreIOBuffer tempBuffer;
    tempBuffer.offset = 0;
    tempBuffer.length = 4096;
    char reqdata[4096];
    tempBuffer.data = reqdata;

    e->lock();
    e->expires = squid_curtime;
    e->buffer();
    stat_ipcache_get(e);

    storeClientCopy(sc, e, tempBuffer, ipcacheprintcallbk, data);

    e->flush();
    e->complete();
    std:: cout << "temBuffer= " << tempBuffer.data << std::endl;
    e->unlock();
}

Regards,
Anita

--
View this message in context: http://squid-web-proxy-cache.1019090.n4.nabble.com/Store-client-API-tp4585888p4616548.html
Sent from the Squid - Development mailing list archive at Nabble.com.
Received on Tue May 08 2012 - 04:12:44 MDT

This archive was generated by hypermail 2.2.0 : Tue May 08 2012 - 12:00:10 MDT