Some fixes
This commit is contained in:
parent
1a4a6721a1
commit
d52496600f
@ -1 +1 @@
|
|||||||
Subproject commit 46fd2354c3a900b7c8fe2712854bc4b332a0d10e
|
Subproject commit c3a2818a7f698f3a0efbf32426924299214106da
|
@ -7,6 +7,7 @@
|
|||||||
#include <event.h>
|
#include <event.h>
|
||||||
#include <ThreadPool/ThreadHelper.h>
|
#include <ThreadPool/ThreadHelper.h>
|
||||||
#include <misc/endianness.h>
|
#include <misc/endianness.h>
|
||||||
|
#include <shared/include/license/client.h>
|
||||||
#include "shared/include/license/client.h"
|
#include "shared/include/license/client.h"
|
||||||
#include "crypt.h"
|
#include "crypt.h"
|
||||||
|
|
||||||
@ -46,7 +47,10 @@ LicenseServerClient::~LicenseServerClient() {
|
|||||||
|
|
||||||
if(this->buffers.read)
|
if(this->buffers.read)
|
||||||
Buffer::free(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) {
|
bool LicenseServerClient::start_connection(std::string &error) {
|
||||||
@ -95,7 +99,6 @@ bool LicenseServerClient::start_connection(std::string &error) {
|
|||||||
client->callback_write(e);
|
client->callback_write(e);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
event_dispatch_spawned = true;
|
|
||||||
this->network.event_dispatch = std::thread([&] {
|
this->network.event_dispatch = std::thread([&] {
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
|
|
||||||
@ -114,10 +117,6 @@ bool LicenseServerClient::start_connection(std::string &error) {
|
|||||||
return true;
|
return true;
|
||||||
error_cleanup:
|
error_cleanup:
|
||||||
this->cleanup_network_resources();
|
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;
|
this->connection_state = ConnectionState::UNCONNECTED;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
2
music
2
music
@ -1 +1 @@
|
|||||||
Subproject commit 8a896f7a797251b8104ba68559546e083da6518e
|
Subproject commit ed56872346f5e90320e62bf1b5e02466fb866b2e
|
@ -159,7 +159,12 @@ void DatabaseHelper::deleteClient(const std::shared_ptr<VirtualServer>& server,
|
|||||||
//TODO delete complains
|
//TODO delete complains
|
||||||
}
|
}
|
||||||
|
|
||||||
inline sql::result load_permissions_v2(const std::shared_ptr<VirtualServer>& 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<VirtualServer>& 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 start = system_clock::now();
|
||||||
|
|
||||||
auto server_id = server ? server->getServerId() : 0;
|
auto server_id = server ? server->getServerId() : 0;
|
||||||
@ -213,7 +218,7 @@ inline sql::result load_permissions_v2(const std::shared_ptr<VirtualServer>& ser
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(channel_id == 0)
|
if(channel_id == 0 || is_channel)
|
||||||
manager->load_permission(key, {value, granted}, skipped, negated, value != permNotGranted, granted != permNotGranted);
|
manager->load_permission(key, {value, granted}, skipped, negated, value != permNotGranted, granted != permNotGranted);
|
||||||
else
|
else
|
||||||
manager->load_permission(key, {value, granted}, channel_id, skipped, negated, value != permNotGranted, granted != permNotGranted);
|
manager->load_permission(key, {value, granted}, channel_id, skipped, negated, value != permNotGranted, granted != permNotGranted);
|
||||||
@ -282,7 +287,7 @@ std::shared_ptr<v2::PermissionManager> DatabaseHelper::loadClientPermissionManag
|
|||||||
variable{":serverId", server ? server->getServerId() : 0},
|
variable{":serverId", server ? server->getServerId() : 0},
|
||||||
variable{":type", permission::SQL_PERM_USER},
|
variable{":type", permission::SQL_PERM_USER},
|
||||||
variable{":id", cldbid});
|
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<permission::v2::PermissionManager> DatabaseHelper::loadGroupPerm
|
|||||||
variable{":serverId", server ? server->getServerId() : 0},
|
variable{":serverId", server ? server->getServerId() : 0},
|
||||||
variable{":type", permission::SQL_PERM_GROUP},
|
variable{":type", permission::SQL_PERM_GROUP},
|
||||||
variable{":id", group_id});
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,7 +441,7 @@ std::shared_ptr<permission::v2::PermissionManager> DatabaseHelper::loadPlaylistP
|
|||||||
variable{":serverId", server ? server->getServerId() : 0},
|
variable{":serverId", server ? server->getServerId() : 0},
|
||||||
variable{":type", permission::SQL_PERM_PLAYLIST},
|
variable{":type", permission::SQL_PERM_PLAYLIST},
|
||||||
variable{":id", playlist_id});
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -502,7 +507,7 @@ std::shared_ptr<permission::v2::PermissionManager> DatabaseHelper::loadChannelPe
|
|||||||
variable{":chid", channel},
|
variable{":chid", channel},
|
||||||
variable{":id", 0},
|
variable{":id", 0},
|
||||||
variable{":type", permission::SQL_PERM_CHANNEL});
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1045,7 +1045,7 @@ float VirtualServer::averagePing() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool VirtualServer::resetPermissions(std::string& token) {
|
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 `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());
|
LOG_SQL_CMD(sql::command(this->sql, "DELETE FROM `groups` WHERE `serverId` = :serverId", variable{":serverId", this->serverId}).execute());
|
||||||
|
|
||||||
|
@ -317,7 +317,7 @@ shared_ptr<VirtualServer> VirtualServerManager::create_server(std::string hosts,
|
|||||||
return nullptr;
|
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"});
|
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;",
|
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{":target_sid", serverId},
|
||||||
variable{":type", property::PROP_TYPE_SERVER}).execute();
|
variable{":type", property::PROP_TYPE_SERVER}).execute();
|
||||||
|
@ -79,7 +79,7 @@ void LicenseService::abort_request(std::lock_guard<std::recursive_timed_mutex> &
|
|||||||
this->current_client->close_connection();
|
this->current_client->close_connection();
|
||||||
}
|
}
|
||||||
|
|
||||||
this->current_client.release();
|
this->current_client.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
shared
2
shared
@ -1 +1 @@
|
|||||||
Subproject commit ece70e4df474a5e027e3c54e8a8e1be84a2a6a72
|
Subproject commit 064d54eac552250db6b5d706490ab2095ade0bb7
|
Loading…
Reference in New Issue
Block a user