Skip to content
Snippets Groups Projects
Commit 28afcbfd authored by Adrien Béraud's avatar Adrien Béraud Committed by Adrien Béraud
Browse files

gitserver: improve logs

Change-Id: I940952e1f805a1a8bb3f3b0de9de626147e3c4e7
parent 33f42691
Branches
No related tags found
No related merge requests found
...@@ -44,13 +44,19 @@ namespace jami { ...@@ -44,13 +44,19 @@ namespace jami {
class GitServer::Impl class GitServer::Impl
{ {
public: public:
Impl(const std::string& repositoryId, Impl(const std::string& accountId,
const std::string& repositoryId,
const std::string& repository, const std::string& repository,
const std::shared_ptr<dhtnet::ChannelSocket>& socket) const std::shared_ptr<dhtnet::ChannelSocket>& socket)
: repositoryId_(repositoryId) : accountId_(accountId)
, repositoryId_(repositoryId)
, repository_(repository) , repository_(repository)
, socket_(socket) , socket_(socket)
{ {
JAMI_DEBUG("[Account {}] [Conversation {}] [GitServer {}] created",
accountId_,
repositoryId_,
fmt::ptr(this));
// Check at least if repository is correct // Check at least if repository is correct
git_repository* repo; git_repository* repo;
if (git_repository_open(&repo, repository_.c_str()) != 0) { if (git_repository_open(&repo, repository_.c_str()) != 0) {
...@@ -68,7 +74,13 @@ public: ...@@ -68,7 +74,13 @@ public:
return len; return len;
}); });
} }
~Impl() { stop(); } ~Impl() {
stop();
JAMI_DEBUG("[Account {}] [Conversation {}] [GitServer {}] destroyed",
accountId_,
repositoryId_,
fmt::ptr(this));
}
void stop() void stop()
{ {
std::lock_guard lk(destroyMtx_); std::lock_guard lk(destroyMtx_);
...@@ -86,6 +98,7 @@ public: ...@@ -86,6 +98,7 @@ public:
void sendPackData(); void sendPackData();
std::map<std::string, std::string> getParameters(std::string_view pkt_line); std::map<std::string, std::string> getParameters(std::string_view pkt_line);
std::string accountId_ {};
std::string repositoryId_ {}; std::string repositoryId_ {};
std::string repository_ {}; std::string repository_ {};
std::shared_ptr<dhtnet::ChannelSocket> socket_ {}; std::shared_ptr<dhtnet::ChannelSocket> socket_ {};
...@@ -228,7 +241,7 @@ GitServer::Impl::sendReferenceCapabilities(bool sendVersion) ...@@ -228,7 +241,7 @@ GitServer::Impl::sendReferenceCapabilities(bool sendVersion)
// **** with a version number (if "version=1" is sent as an Extra Parameter), // **** with a version number (if "version=1" is sent as an Extra Parameter),
std::error_code ec; std::error_code ec;
if (sendVersion) { if (sendVersion) {
auto toSend = "000eversion 1\0"sv; constexpr auto toSend = "000eversion 1\0"sv;
socket_->write(reinterpret_cast<const unsigned char*>(toSend.data()), socket_->write(reinterpret_cast<const unsigned char*>(toSend.data()),
toSend.size(), toSend.size(),
ec); ec);
...@@ -479,14 +492,13 @@ GitServer::GitServer(const std::string& accountId, ...@@ -479,14 +492,13 @@ GitServer::GitServer(const std::string& accountId,
const std::shared_ptr<dhtnet::ChannelSocket>& client) const std::shared_ptr<dhtnet::ChannelSocket>& client)
{ {
auto path = (fileutils::get_data_dir() / accountId / "conversations" / conversationId).string(); auto path = (fileutils::get_data_dir() / accountId / "conversations" / conversationId).string();
pimpl_ = std::make_unique<GitServer::Impl>(conversationId, path, client); pimpl_ = std::make_unique<GitServer::Impl>(accountId, conversationId, path, client);
} }
GitServer::~GitServer() GitServer::~GitServer()
{ {
stop(); stop();
pimpl_.reset(); pimpl_.reset();
JAMI_INFO("GitServer destroyed");
} }
void void
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment