!20 修复kiran2.3-round1相关缺陷
From: @kylinsecos_admin Reviewed-by: @tangjie02 Signed-off-by: @tangjie02
This commit is contained in:
commit
df70cf6f70
@ -1,45 +0,0 @@
|
||||
From 6d88cb7e7196a266f0e33b364cd6580516e47402 Mon Sep 17 00:00:00 2001
|
||||
From: tangjie02 <tangjie02@kylinsec.com.cn>
|
||||
Date: Mon, 11 Jul 2022 20:41:53 +0800
|
||||
Subject: [PATCH 1/2] fix(coredump): Fix the coredump as failed to connect
|
||||
pulaseaudio service.
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
- 修复失败连接pulseaudio服务时导致的崩溃问题
|
||||
|
||||
Signed-off-by: tangjie02 <tangjie02@kylinsec.com.cn>
|
||||
---
|
||||
plugins/audio/pulse/pulse-context.cpp | 10 +++++++---
|
||||
1 file changed, 7 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/plugins/audio/pulse/pulse-context.cpp b/plugins/audio/pulse/pulse-context.cpp
|
||||
index e32e02d..699b7c6 100644
|
||||
--- a/plugins/audio/pulse/pulse-context.cpp
|
||||
+++ b/plugins/audio/pulse/pulse-context.cpp
|
||||
@@ -83,8 +83,12 @@ bool PulseContext::connect(bool wait_for_daemon)
|
||||
}
|
||||
else
|
||||
{
|
||||
- pa_context_unref(this->context_);
|
||||
- this->context_ = NULL;
|
||||
+ // on_pulse_state_cb回调函数可能已经进行了释放操作,所以这里需要进一步判断
|
||||
+ if (this->context_)
|
||||
+ {
|
||||
+ pa_context_unref(this->context_);
|
||||
+ this->context_ = NULL;
|
||||
+ }
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -787,4 +791,4 @@ std::string PulseContext::get_default_app_name()
|
||||
|
||||
return PROJECT_NAME;
|
||||
}
|
||||
-} // namespace Kiran
|
||||
\ No newline at end of file
|
||||
+} // namespace Kiran
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -1,184 +0,0 @@
|
||||
From 7a35e9c6b3a8ec4eb45b708b32b175e1f4419983 Mon Sep 17 00:00:00 2001
|
||||
From: tangjie02 <tangjie02@kylinsec.com.cn>
|
||||
Date: Mon, 11 Jul 2022 21:00:16 +0800
|
||||
Subject: [PATCH 2/2] feature(audio): Try reconnection if failed to connect
|
||||
pulseaudio service firstly.
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
- 如果第一次链接puluseaudio失败,也进行重新连接尝试,因为pulseaudio可能在kiran-session-daemon之后启动
|
||||
|
||||
Signed-off-by: tangjie02 <tangjie02@kylinsec.com.cn>
|
||||
---
|
||||
plugins/audio/pulse/pulse-backend.cpp | 50 ++++++++++++++-------------
|
||||
plugins/audio/pulse/pulse-backend.h | 4 +--
|
||||
plugins/audio/pulse/pulse-context.cpp | 6 ++--
|
||||
3 files changed, 32 insertions(+), 28 deletions(-)
|
||||
|
||||
diff --git a/plugins/audio/pulse/pulse-backend.cpp b/plugins/audio/pulse/pulse-backend.cpp
|
||||
index e1844dc..5190eb4 100644
|
||||
--- a/plugins/audio/pulse/pulse-backend.cpp
|
||||
+++ b/plugins/audio/pulse/pulse-backend.cpp
|
||||
@@ -16,8 +16,10 @@
|
||||
|
||||
namespace Kiran
|
||||
{
|
||||
+#define MAX_RECONNECTION_NUM 50
|
||||
+
|
||||
PulseBackend::PulseBackend() : state_(AudioState::AUDIO_STATE_IDLE),
|
||||
- connected_once_(false),
|
||||
+ reconnection_count_(0),
|
||||
reconnection_handle_(0)
|
||||
{
|
||||
this->context_ = std::make_shared<PulseContext>();
|
||||
@@ -99,7 +101,7 @@ bool PulseBackend::init()
|
||||
|
||||
this->set_state(AudioState::AUDIO_STATE_CONNECTING);
|
||||
|
||||
- if (!this->context_->connect(false))
|
||||
+ if (!this->context_->connect(true))
|
||||
{
|
||||
this->set_state(AudioState::AUDIO_STATE_FAILED);
|
||||
return false;
|
||||
@@ -110,7 +112,7 @@ bool PulseBackend::init()
|
||||
|
||||
void PulseBackend::set_state(AudioState state)
|
||||
{
|
||||
- KLOG_PROFILE("state: %d.", state);
|
||||
+ KLOG_DEBUG("Audio state: %d.", state);
|
||||
|
||||
if (this->state_ != state)
|
||||
{
|
||||
@@ -121,7 +123,16 @@ void PulseBackend::set_state(AudioState state)
|
||||
|
||||
bool PulseBackend::try_reconnection()
|
||||
{
|
||||
- KLOG_PROFILE("");
|
||||
+ ++this->reconnection_count_;
|
||||
+
|
||||
+ KLOG_DEBUG("Try to reconnect pulseaudio service. reconnection count: %d.", this->reconnection_count_);
|
||||
+
|
||||
+ if (this->reconnection_count_ > MAX_RECONNECTION_NUM)
|
||||
+ {
|
||||
+ KLOG_WARNING("The maximum number of reconnections (%d) has been exceeded. Stop reconnection", MAX_RECONNECTION_NUM);
|
||||
+ this->reconnection_handle_ = 0;
|
||||
+ return G_SOURCE_REMOVE;
|
||||
+ }
|
||||
|
||||
if (this->context_->connect(true))
|
||||
{
|
||||
@@ -168,38 +179,28 @@ void PulseBackend::reset_data()
|
||||
|
||||
void PulseBackend::on_connection_state_changed_cb(PulseConnectionState connection_state)
|
||||
{
|
||||
- KLOG_PROFILE("connection state: %d.", connection_state);
|
||||
+ KLOG_DEBUG("Connection state: %d.", connection_state);
|
||||
|
||||
switch (connection_state)
|
||||
{
|
||||
case PulseConnectionState::PULSE_CONNECTION_DISCONNECTED:
|
||||
{
|
||||
- // 如果之前已经成功连接过一次,此时突然断开了连接,则重新进行连接
|
||||
// 重新连接之前需要清理掉之前的数据,需要测试一下重启pulseaudio服务程序会不会出问题
|
||||
this->reset_data();
|
||||
+ this->set_state(AudioState::AUDIO_STATE_CONNECTING);
|
||||
|
||||
- if (this->connected_once_)
|
||||
+ if (this->reconnection_handle_)
|
||||
{
|
||||
- this->set_state(AudioState::AUDIO_STATE_CONNECTING);
|
||||
-
|
||||
- if (this->reconnection_handle_)
|
||||
- {
|
||||
- KLOG_DEBUG("The reconnection handle is already exist. handle: %d.", this->reconnection_handle_);
|
||||
- break;
|
||||
- }
|
||||
-
|
||||
- if (!this->context_->connect(true))
|
||||
- {
|
||||
- auto timeout_source = Glib::TimeoutSource::create(200);
|
||||
- timeout_source->connect(sigc::mem_fun(this, &PulseBackend::try_reconnection));
|
||||
- auto glib_context = Glib::wrap(g_main_context_get_thread_default());
|
||||
- this->reconnection_handle_ = timeout_source->attach(glib_context);
|
||||
- }
|
||||
+ KLOG_DEBUG("The reconnection handle is already exist. handle: %d.", this->reconnection_handle_);
|
||||
}
|
||||
else
|
||||
{
|
||||
- this->set_state(AudioState::AUDIO_STATE_FAILED);
|
||||
+ auto timeout_source = Glib::TimeoutSource::create(400);
|
||||
+ timeout_source->connect(sigc::mem_fun(this, &PulseBackend::try_reconnection));
|
||||
+ auto glib_context = Glib::wrap(g_main_context_get_thread_default());
|
||||
+ this->reconnection_handle_ = timeout_source->attach(glib_context);
|
||||
}
|
||||
+
|
||||
break;
|
||||
}
|
||||
case PulseConnectionState::PULSE_CONNECTION_CONNECTING:
|
||||
@@ -209,7 +210,8 @@ void PulseBackend::on_connection_state_changed_cb(PulseConnectionState connectio
|
||||
break;
|
||||
case PulseConnectionState::PULSE_CONNECTION_CONNECTED:
|
||||
{
|
||||
- this->connected_once_ = true;
|
||||
+ // 如果连接成功,重连次数清0
|
||||
+ this->reconnection_count_ = 0;
|
||||
this->set_state(AudioState::AUDIO_STATE_READY);
|
||||
break;
|
||||
}
|
||||
diff --git a/plugins/audio/pulse/pulse-backend.h b/plugins/audio/pulse/pulse-backend.h
|
||||
index 5494c32..1d27bf2 100644
|
||||
--- a/plugins/audio/pulse/pulse-backend.h
|
||||
+++ b/plugins/audio/pulse/pulse-backend.h
|
||||
@@ -171,8 +171,8 @@ private:
|
||||
|
||||
// 可用状态
|
||||
AudioState state_;
|
||||
- // 是否成功连接过一次
|
||||
- bool connected_once_;
|
||||
+ // 重新连接次数
|
||||
+ int32_t reconnection_count_;
|
||||
uint32_t reconnection_handle_;
|
||||
|
||||
PulseServerInfo server_info_;
|
||||
diff --git a/plugins/audio/pulse/pulse-context.cpp b/plugins/audio/pulse/pulse-context.cpp
|
||||
index 699b7c6..eb3e8a5 100644
|
||||
--- a/plugins/audio/pulse/pulse-context.cpp
|
||||
+++ b/plugins/audio/pulse/pulse-context.cpp
|
||||
@@ -56,7 +56,7 @@ PulseContext::~PulseContext()
|
||||
|
||||
bool PulseContext::connect(bool wait_for_daemon)
|
||||
{
|
||||
- KLOG_PROFILE("wait for deamon: %d.", wait_for_daemon);
|
||||
+ KLOG_DEBUG("Wait for deamon: %d.", wait_for_daemon);
|
||||
|
||||
RETURN_VAL_IF_FALSE(this->main_loop_ != NULL, false);
|
||||
|
||||
@@ -75,7 +75,6 @@ bool PulseContext::connect(bool wait_for_daemon)
|
||||
pa_context_set_state_callback(this->context_, &PulseContext::on_pulse_state_cb, this);
|
||||
|
||||
pa_context_flags_t flags = wait_for_daemon ? PA_CONTEXT_NOFAIL : PA_CONTEXT_NOFLAGS;
|
||||
-
|
||||
if (pa_context_connect(this->context_, NULL, flags, NULL) == 0)
|
||||
{
|
||||
this->set_connection_state(PulseConnectionState::PULSE_CONNECTION_CONNECTING);
|
||||
@@ -83,6 +82,7 @@ bool PulseContext::connect(bool wait_for_daemon)
|
||||
}
|
||||
else
|
||||
{
|
||||
+ KLOG_WARNING("Failed to connect pulseaudio service.");
|
||||
// on_pulse_state_cb回调函数可能已经进行了释放操作,所以这里需要进一步判断
|
||||
if (this->context_)
|
||||
{
|
||||
@@ -569,6 +569,8 @@ void PulseContext::on_pulse_state_cb(pa_context *context, void *userdata)
|
||||
PulseContext *self = (PulseContext *)(userdata);
|
||||
auto state = pa_context_get_state(self->context_);
|
||||
|
||||
+ KLOG_DEBUG("Pulse state change, state: %d.", state);
|
||||
+
|
||||
if (state == PA_CONTEXT_READY)
|
||||
{
|
||||
if (self->connection_state_ == PULSE_CONNECTION_LOADING || self->connection_state_ == PULSE_CONNECTION_CONNECTED)
|
||||
--
|
||||
2.33.0
|
||||
|
||||
Binary file not shown.
BIN
kiran-cc-daemon-2.3.1.tar.gz
Normal file
BIN
kiran-cc-daemon-2.3.1.tar.gz
Normal file
Binary file not shown.
@ -1,16 +1,12 @@
|
||||
Name: kiran-cc-daemon
|
||||
Version: 2.3.0
|
||||
Release: 2
|
||||
Version: 2.3.1
|
||||
Release: 1
|
||||
Summary: DBus daemon for Kiran Desktop
|
||||
|
||||
License: Mulan PSL v2
|
||||
Source0: %{name}-%{version}.tar.gz
|
||||
|
||||
|
||||
Patch0001: 0001-fix-coredump-Fix-the-coredump-as-failed-to-connect-p.patch
|
||||
Patch0002: 0002-feature-audio-Try-reconnection-if-failed-to-connect-.patch
|
||||
|
||||
|
||||
BuildRequires: cmake >= 3.2
|
||||
BuildRequires: pkgconfig(glibmm-2.4)
|
||||
BuildRequires: pkgconfig(giomm-2.4)
|
||||
@ -51,6 +47,12 @@ Requires: kiran-cc-daemon-common
|
||||
Requires: util-linux
|
||||
Requires: pciutils
|
||||
|
||||
%if 0%{?openEuler}
|
||||
Requires: openeuler-lsb
|
||||
%else
|
||||
Requires: kylin-lsb
|
||||
%endif
|
||||
|
||||
%description -n kiran-system-daemon
|
||||
System DBus daemon for Kiran Desktop
|
||||
|
||||
@ -124,6 +126,8 @@ glib-compile-schemas /usr/share/glib-2.0/schemas &> /dev/nulls || :
|
||||
%{_datadir}/icons/hicolor/scalable/apps/*.svg
|
||||
%{_datadir}/locale/zh_CN/LC_MESSAGES/kiran-power-status-icon.mo
|
||||
%{_datadir}/polkit-1/actions/com.kylinsec.Kiran.SessionDaemon*.policy
|
||||
%dir %{_datadir}/kiran-cc-daemon/keybindings
|
||||
%{_datadir}/kiran-cc-daemon/keybindings/*.xml
|
||||
|
||||
%files common
|
||||
%{_includedir}/kiran-cc-daemon/error-i.h
|
||||
@ -140,6 +144,10 @@ glib-compile-schemas /usr/share/glib-2.0/schemas &> /dev/nulls || :
|
||||
%{_libdir}/pkgconfig/kiran-cc-daemon.pc
|
||||
|
||||
%changelog
|
||||
* Thu Jul 28 2022 tangjie02 <tangjie02@kylinsec.com.cn> - 2.3.1-1
|
||||
- KYOS-B: Fix the problem that system version shows empty content in comunity version. (#I5H4D6)
|
||||
- KYOS-B: Fix the problem that system and sound classes in keybindings aren't shown.(#I5I6OU)
|
||||
|
||||
* Tue Jul 12 2022 tangjie02 <tangjie02@kylinsec.com.cn> - 2.3.0-2
|
||||
- KYOS-B: Try reconnection if failed to connect pulseaudio service firstly.
|
||||
- KYOS-F: Fix the coredump as failed to connect pulaseaudio service.
|
||||
|
||||
4
kiran-cc-daemon.yaml
Normal file
4
kiran-cc-daemon.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
version_control: gitee
|
||||
src_repo: https://gitee.com/openeuler/kiran-cc-daemon.git
|
||||
tag_prefix: "v"
|
||||
seperator: "."
|
||||
Loading…
x
Reference in New Issue
Block a user