cache_req_search.c revision 8bb6680637ead03e24a38d15ec5265d11a920a1d
/*
Authors:
Pavel Březina <pbrezina@redhat.com>
Copyright (C) 2016 Red Hat
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <ldb.h>
#include <talloc.h>
#include <tevent.h>
#include "responder/common/cache_req/cache_req_private.h"
#include "responder/common/cache_req/cache_req_plugin.h"
{
"This request type does not support negative cache\n");
return EOK;
}
"Checking negative cache for [%s]\n",
"[%s] does not exist (negative cache)\n",
return ENOENT;
"Unable to check negative cache [%d]: %s\n",
return ret;
}
"[%s] is not present in negative cache\n",
return EOK;
}
{
"This request type does not support negative cache\n");
return;
}
"Cannot set negative cache for [%s] [%d]: %s\n",
/* not fatal */
}
return;
}
struct ldb_result **_result)
{
"Bug: No cache lookup function specified\n");
return ERR_INTERNAL;
}
"Looking up [%s] in cache\n",
}
switch (ret) {
case EOK:
"Multiple objects were found when "
"only one was expected!\n");
ret = ERR_INTERNAL;
goto done;
}
break;
case ENOENT:
"Object [%s] was not found in cache\n",
break;
default:
"Unable to lookup [%s] in cache [%d]: %s\n",
break;
}
done:
}
return ret;
}
static enum cache_object_status
struct ldb_result *result)
{
return CACHE_OBJECT_MISSING;
}
return CACHE_OBJECT_VALID;
return CACHE_OBJECT_MIDPOINT;
}
return CACHE_OBJECT_EXPIRED;
}
struct cache_req_search_state {
/* input data */
struct tevent_context *ev;
/* output data */
struct ldb_result *result;
bool dp_success;
};
enum cache_object_status status);
struct tevent_req *
struct tevent_context *ev,
bool bypass_cache,
bool bypass_dp)
{
struct cache_req_search_state *state;
enum cache_object_status status;
struct tevent_req *req;
return NULL;
}
goto done;
}
/* If bypass_cache is enabled we always contact data provider before
* searching the cache. Thus we set expiration status to missing,
* which will trigger data provider request later.
*
* If disabled, we want to search the cache here to see if the
* object is already cached and valid or if data provider needs
* to be contacted.
*/
if (!bypass_cache) {
goto done;
}
if (status == CACHE_OBJECT_VALID) {
goto done;
}
}
if (!bypass_dp) {
}
goto done;
}
return req;
done:
} else {
}
return req;
}
enum cache_object_status status)
{
struct cache_req_search_state *state;
struct tevent_req *subreq;
switch (status) {
case CACHE_OBJECT_MIDPOINT:
/* Out of band update. The calling function will return the cached
* entry immediately. We need to use rctx so the request is not
* removed when state is freed. */
"Performing midpoint cache update of [%s]\n",
"data provider request\n");
/* This is non-fatal, so we'll continue here */
} else {
}
break;
case CACHE_OBJECT_EXPIRED:
case CACHE_OBJECT_MISSING:
"Looking up [%s] in data provider\n",
"Out of memory sending data provider request\n");
break;
}
break;
default:
/* error */
"Unexpected status [%d]\n", status);
ret = ERR_INTERNAL;
break;
}
return ret;
}
{
return;
}
{
struct cache_req_search_state *state;
struct tevent_req *req;
/* Get result from cache again. */
/* Only store entry in negative cache if DP request succeeded
* because only then we know that the entry does not exist. */
if (state->dp_success) {
}
return;
return;
}
return;
}
struct tevent_req *req,
struct ldb_result **_result,
bool *_dp_success)
{
return EOK;
}