diff --git a/git-teaspeak b/git-teaspeak index 46fd235..c3a2818 160000 --- a/git-teaspeak +++ b/git-teaspeak @@ -1 +1 @@ -Subproject commit 46fd2354c3a900b7c8fe2712854bc4b332a0d10e +Subproject commit c3a2818a7f698f3a0efbf32426924299214106da diff --git a/license/shared/src/client.cpp b/license/shared/src/client.cpp index 238df2f..33e7169 100644 --- a/license/shared/src/client.cpp +++ b/license/shared/src/client.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "shared/include/license/client.h" #include "crypt.h" @@ -46,7 +47,10 @@ LicenseServerClient::~LicenseServerClient() { if(this->buffers.read) Buffer::free(this->buffers.read); - threads::save_join(this->network.event_dispatch, false); + + const auto is_event_loop = this->network.event_dispatch.get_id() == std::this_thread::get_id(); + if(is_event_loop) this->network.event_dispatch.detach(); + else this->network.event_dispatch.join(); } bool LicenseServerClient::start_connection(std::string &error) { @@ -95,7 +99,6 @@ bool LicenseServerClient::start_connection(std::string &error) { client->callback_write(e); }, this); - event_dispatch_spawned = true; this->network.event_dispatch = std::thread([&] { signal(SIGPIPE, SIG_IGN); @@ -114,10 +117,6 @@ bool LicenseServerClient::start_connection(std::string &error) { return true; error_cleanup: this->cleanup_network_resources(); - if(!event_dispatch_spawned) { - event_base_free(this->network.event_base); - this->network.event_base = nullptr; - } this->connection_state = ConnectionState::UNCONNECTED; return false; } diff --git a/music b/music index 8a896f7..ed56872 160000 --- a/music +++ b/music @@ -1 +1 @@ -Subproject commit 8a896f7a797251b8104ba68559546e083da6518e +Subproject commit ed56872346f5e90320e62bf1b5e02466fb866b2e diff --git a/server/src/DatabaseHelper.cpp b/server/src/DatabaseHelper.cpp index ab35a59..4ba07a8 100644 --- a/server/src/DatabaseHelper.cpp +++ b/server/src/DatabaseHelper.cpp @@ -159,7 +159,12 @@ void DatabaseHelper::deleteClient(const std::shared_ptr& server, //TODO delete complains } -inline sql::result load_permissions_v2(const std::shared_ptr& server, v2::PermissionManager* manager, sql::command& command, bool test_channel /* only used for client permissions (client channel permissions) */) { +inline sql::result load_permissions_v2( + const std::shared_ptr& server, + v2::PermissionManager* manager, + sql::command& command, + bool test_channel, /* only used for client permissions (client channel permissions) */ + bool is_channel) { auto start = system_clock::now(); auto server_id = server ? server->getServerId() : 0; @@ -213,7 +218,7 @@ inline sql::result load_permissions_v2(const std::shared_ptr& ser return 0; } - if(channel_id == 0) + if(channel_id == 0 || is_channel) manager->load_permission(key, {value, granted}, skipped, negated, value != permNotGranted, granted != permNotGranted); else manager->load_permission(key, {value, granted}, channel_id, skipped, negated, value != permNotGranted, granted != permNotGranted); @@ -282,7 +287,7 @@ std::shared_ptr DatabaseHelper::loadClientPermissionManag variable{":serverId", server ? server->getServerId() : 0}, variable{":type", permission::SQL_PERM_USER}, variable{":id", cldbid}); - LOG_SQL_CMD(load_permissions_v2(server, permission_manager.get(), command, true)); + LOG_SQL_CMD(load_permissions_v2(server, permission_manager.get(), command, true, false)); } @@ -364,7 +369,7 @@ std::shared_ptr DatabaseHelper::loadGroupPerm variable{":serverId", server ? server->getServerId() : 0}, variable{":type", permission::SQL_PERM_GROUP}, variable{":id", group_id}); - LOG_SQL_CMD(load_permissions_v2(server, result.get(), command, false)); + LOG_SQL_CMD(load_permissions_v2(server, result.get(), command, false, false)); return result; } @@ -436,7 +441,7 @@ std::shared_ptr DatabaseHelper::loadPlaylistP variable{":serverId", server ? server->getServerId() : 0}, variable{":type", permission::SQL_PERM_PLAYLIST}, variable{":id", playlist_id}); - LOG_SQL_CMD(load_permissions_v2(server, result.get(), command, false)); + LOG_SQL_CMD(load_permissions_v2(server, result.get(), command, false, false)); return result; } @@ -502,7 +507,7 @@ std::shared_ptr DatabaseHelper::loadChannelPe variable{":chid", channel}, variable{":id", 0}, variable{":type", permission::SQL_PERM_CHANNEL}); - LOG_SQL_CMD(load_permissions_v2(server, result.get(), command, false)); + LOG_SQL_CMD(load_permissions_v2(server, result.get(), command, false, true)); return result; } diff --git a/server/src/VirtualServer.cpp b/server/src/VirtualServer.cpp index 5b4c832..0203d15 100644 --- a/server/src/VirtualServer.cpp +++ b/server/src/VirtualServer.cpp @@ -1045,7 +1045,7 @@ float VirtualServer::averagePing() { } bool VirtualServer::resetPermissions(std::string& token) { - LOG_SQL_CMD(sql::command(this->sql, "DELETE FROM `permissions` WHERE `serverId` = :serverId", variable{":serverId", this->serverId}).execute()); + LOG_SQL_CMD(sql::command(this->sql, "DELETE FROM `permissions` WHERE `serverId` = :serverId AND `type` != :channel_type", variable{":serverId", this->serverId}, variable{":channel_type", permission::SQL_PERM_CHANNEL}).execute()); LOG_SQL_CMD(sql::command(this->sql, "DELETE FROM `assignedGroups` WHERE `serverId` = :serverId", variable{":serverId", this->serverId}).execute()); LOG_SQL_CMD(sql::command(this->sql, "DELETE FROM `groups` WHERE `serverId` = :serverId", variable{":serverId", this->serverId}).execute()); diff --git a/server/src/VirtualServerManager.cpp b/server/src/VirtualServerManager.cpp index 11bed8a..09f7a34 100644 --- a/server/src/VirtualServerManager.cpp +++ b/server/src/VirtualServerManager.cpp @@ -317,7 +317,7 @@ shared_ptr VirtualServerManager::create_server(std::string hosts, return nullptr; sql::command(this->handle->getSql(), "INSERT INTO `servers` (`serverId`, `host`, `port`) VALUES (:sid, :host, :port)", variable{":sid", serverId}, variable{":host", hosts}, variable{":port", port}).executeLater().waitAndGetLater(LOG_SQL_CMD, {1, "future failed"}); - //`serverId` INTEGER DEFAULT -1, `type` INTEGER, `id` INTEGER, `key` VARCHAR(" UNKNOWN_KEY_LENGTH "), `value` TEXT + auto prop_copy = sql::command(this->handle->getSql(), "INSERT INTO `properties` (`serverId`, `type`, `id`, `key`, `value`) SELECT :target_sid AS `serverId`, `type`, `id`, `key`, `value` FROM `properties` WHERE `type` = :type AND `id` = 0 AND `serverId` = 0;", variable{":target_sid", serverId}, variable{":type", property::PROP_TYPE_SERVER}).execute(); diff --git a/server/src/lincense/LicenseService.cpp b/server/src/lincense/LicenseService.cpp index d4849b5..627f50a 100644 --- a/server/src/lincense/LicenseService.cpp +++ b/server/src/lincense/LicenseService.cpp @@ -79,7 +79,7 @@ void LicenseService::abort_request(std::lock_guard & this->current_client->close_connection(); } - this->current_client.release(); + this->current_client.reset(); } } diff --git a/shared b/shared index ece70e4..064d54e 160000 --- a/shared +++ b/shared @@ -1 +1 @@ -Subproject commit ece70e4df474a5e027e3c54e8a8e1be84a2a6a72 +Subproject commit 064d54eac552250db6b5d706490ab2095ade0bb7