mirror of
https://github.com/valitydev/osquery-1.git
synced 2024-11-07 01:55:20 +00:00
c7355b19aa
Summary: Pull Request resolved: https://github.com/facebook/osquery/pull/5452 As suggested in another diff, this diff updates the language we use to describe the osquery licensing terms. We are changing all instances of //This source code is licensed as defined on the LICENSE file found in the root directory of this source tree.// to //This source code is licensed in accordance with the terms specified in the LICENSE file found in the root directory of this source tree.// We accomplish this with a codemod: $ codemod -md xplat/osquery/oss --extensions cpp,h,in,py,sh,mm,ps1 "(.\s+)This source code is licensed as defined on the LICENSE file found in the(.*)root directory of this source tree\." "\1This source code is licensed in accordance with the terms specified in\2the LICENSE file found in the root directory of this source tree." Reviewed By: fmanco Differential Revision: D14131290 fbshipit-source-id: 52c90da342263e2a80f5a678ecd760c19cf7513e
50 lines
1.4 KiB
C++
50 lines
1.4 KiB
C++
/**
|
|
* Copyright (c) 2018-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed in accordance with the terms specified in
|
|
* the LICENSE file found in the root directory of this source tree.
|
|
*/
|
|
|
|
#include <osquery/ev2/manager.h>
|
|
#include <osquery/utils/expected/expected.h>
|
|
|
|
#include <mutex>
|
|
|
|
namespace osquery {
|
|
namespace ev2 {
|
|
|
|
ExpectedSuccess<EventManager::Error> EventManager::bind(
|
|
std::shared_ptr<Subscription> sub) {
|
|
std::unique_lock<std::mutex> lock(mutex_);
|
|
|
|
auto it = publishers_.find(sub->pubType());
|
|
if (it != publishers_.end()) {
|
|
auto ret = it->second->subscribe(std::move(sub));
|
|
if (ret.isError()) {
|
|
return createError(Error::PublisherError,
|
|
"Calling subscribe() on publisher '" +
|
|
it->second->name() +
|
|
"' for subscription from request from '" +
|
|
sub->subscriber() + "' returned an error.",
|
|
ret.takeError());
|
|
}
|
|
} else {
|
|
return createError(Error::UnknownPublisher,
|
|
"No registered publisher for bind request from '" +
|
|
sub->subscriber() + "'");
|
|
}
|
|
|
|
return Success();
|
|
}
|
|
|
|
void EventManager::registerPublisher(std::shared_ptr<Publisher> pub) {
|
|
std::unique_lock<std::mutex> lock(mutex_);
|
|
|
|
auto& r = *pub.get();
|
|
publishers_[typeid(r)] = std::move(pub);
|
|
}
|
|
|
|
} // namespace ev2
|
|
} // namespace osquery
|