Skip to content

Commit

Permalink
Disallow memory allocation in [sg]etDcpConnHandler
Browse files Browse the repository at this point in the history
By doing so we don't have to toggle to the NonAllocationGuard
in ep-engine as the method just wants to set/get a pointer
from the connection.

Change-Id: I4db69bc504497df18a5e9dcc0f7b7d6b690fdeae
Reviewed-on: http://review.couchbase.org/c/kv_engine/+/145803
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
  • Loading branch information
trondn committed Feb 12, 2021
1 parent 710dd74 commit af21985
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
17 changes: 2 additions & 15 deletions engines/ep/src/ep_engine.cc
Expand Up @@ -1799,18 +1799,6 @@ void EventuallyPersistentEngine::releaseCookie(const void* cookie) {
serverApi->cookie->release(cookie);
}

void EventuallyPersistentEngine::setDcpConnHandler(
const void* cookie, DcpConnHandlerIface* handler) {
NonBucketAllocationGuard guard;
serverApi->cookie->setDcpConnHandler(cookie, handler);
}

DcpConnHandlerIface* EventuallyPersistentEngine::getDcpConnHandler(
const void* cookie) {
NonBucketAllocationGuard guard;
return serverApi->cookie->getDcpConnHandler(cookie);
}

void EventuallyPersistentEngine::storeEngineSpecific(const void* cookie,
void* engine_data) {
NonBucketAllocationGuard guard;
Expand Down Expand Up @@ -6246,16 +6234,15 @@ cb::engine_errc EventuallyPersistentEngine::dcpAddStream(const void* cookie,
}

ConnHandler* EventuallyPersistentEngine::tryGetConnHandler(const void* cookie) {
auto* iface = getDcpConnHandler(cookie);
auto* iface = serverApi->cookie->getDcpConnHandler(cookie);
if (iface) {
auto* handler = dynamic_cast<ConnHandler*>(iface);
if (handler) {
return handler;
}
throw std::logic_error(
"EventuallyPersistentEngine::tryGetConnHandler(): The "
"registered "
"connection handler is not a ConnHandler");
"registered connection handler is not a ConnHandler");
}

return nullptr;
Expand Down
3 changes: 0 additions & 3 deletions engines/ep/src/ep_engine.h
Expand Up @@ -535,9 +535,6 @@ class EventuallyPersistentEngine : public EngineIface, public DcpIface {
void reserveCookie(const void* cookie);
void releaseCookie(const void* cookie);

void setDcpConnHandler(const void* cookie, DcpConnHandlerIface* handler);
DcpConnHandlerIface* getDcpConnHandler(const void* cookie);

void storeEngineSpecific(const void* cookie, void* engine_data);

void* getEngineSpecific(const void* cookie);
Expand Down
8 changes: 8 additions & 0 deletions include/memcached/server_cookie_iface.h
Expand Up @@ -43,6 +43,10 @@ struct ServerCookieIface {
* Set the DCP connection handler to be used for the connection the
* provided cookie belongs to.
*
* NOTE: No logging or memory allocation is allowed in the impl
* of this as ep-engine will not try to set the memory
* allocation guard before calling it
*
* @param cookie The cookie provided by the core for the operation
* @param handler The new handler (may be nullptr to clear the handler)
*/
Expand All @@ -53,6 +57,10 @@ struct ServerCookieIface {
* Get the DCP connection handler for the connection the provided
* cookie belongs to
*
* NOTE: No logging or memory allocation is allowed in the impl
* of this as ep-engine will not try to set the memory
* allocation guard before calling it
*
* @param cookie The cookie provided by the core for the operation
* @return The handler stored for the connection (may be nullptr if
* none is specified)
Expand Down

0 comments on commit af21985

Please sign in to comment.