/*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2004-present Facebook, Inc.
*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
+
#pragma once
#include <map>
class RequestData {
public:
virtual ~RequestData() = default;
+ // Avoid calling RequestContext::setContextData, setContextDataIfAbsent, or
+ // clearContextData from these callbacks. Doing so will cause deadlock. We
+ // could fix these deadlocks, but only at significant performance penalty, so
+ // just don't do it!
virtual void onSet() {}
virtual void onUnset() {}
};
// Create a new RequestContext and reset to the original value when
// this goes out of scope.
RequestContextScopeGuard() : prev_(RequestContext::saveContext()) {
- DLOG_IF(INFO, prev_ != nullptr)
- << "Overriding folly::RequestContext - did you mean to unset it first?";
RequestContext::create();
}
// be automatically reset to the original value when this goes out of scope.
explicit RequestContextScopeGuard(std::shared_ptr<RequestContext> ctx)
: prev_(RequestContext::setContext(std::move(ctx))) {
- DLOG_IF(INFO, prev_ != nullptr && prev_.get() != RequestContext::get())
- << "Overriding folly::RequestContext - did you mean to unset it first?";
}
~RequestContextScopeGuard() {