fix for publish

This commit is contained in:
qicosmos
2020-10-27 23:30:17 +08:00
parent 12b58bd036
commit 0d896025fd
2 changed files with 5 additions and 6 deletions
+2 -1
View File
@@ -76,7 +76,8 @@
<IncludePath>..\..\include;..\..\third\msgpack\include;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<IncludePath>..\..\include;..\..\third\msgpack\include;$(IncludePath)</IncludePath>
<IncludePath>..\..\include;..\..\third\msgpack\include;D:\boost_1_73_0;$(IncludePath)</IncludePath>
<LibraryPath>D:\boost_1_73_0\lib64-msvc-14.2;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<IncludePath>..\..\include;..\..\third\msgpack\include;$(IncludePath)</IncludePath>
+3 -5
View File
@@ -161,17 +161,15 @@ namespace rest_rpc {
template<typename T>
void publish(std::string key, std::string token, T data) {
decltype(sub_map_.equal_range(key)) range;
{
std::unique_lock<std::mutex> lock(sub_mtx_);
if (sub_map_.empty())
return;
range = sub_map_.equal_range(key + token);
}
std::shared_ptr<std::string> shared_data = get_shared_data<T>(std::move(data));
std::shared_ptr<std::string> shared_data = get_shared_data<T>(std::move(data));
std::unique_lock<std::mutex> lock(sub_mtx_);
auto range = sub_map_.equal_range(key + token);
for (auto it = range.first; it != range.second; ++it) {
auto conn = it->second.lock();
if (conn == nullptr || conn->has_closed()) {