summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2011-07-21 17:43:16 +0200
committerAlon Levy <alevy@redhat.com>2011-07-21 19:02:10 +0300
commit3f8d7e59dbd94b1837503f37b5065698df3ffbc7 (patch)
tree10f4fb37a01ef0f16fc16b8acdb9aa4aafcaf8c4
parent858596bb483c495998d738f394d39104e14931be (diff)
downloadspice-3f8d7e59dbd94b1837503f37b5065698df3ffbc7.tar.gz
spice-3f8d7e59dbd94b1837503f37b5065698df3ffbc7.tar.xz
spice-3f8d7e59dbd94b1837503f37b5065698df3ffbc7.zip
client: only send one SPICE_MSGC_MAIN_ATTACH_CHANNELS messages
492f7a9b fixed unwanted timeouts during initial client startup, but it also caused a bad regression when connecting to RHEL6+agent guests: the SPICE_MSGS_MAIN_ATTACH_CHANNELS message was sent multiple times, once in RedClient::handle_init, then once again in RedClient::on_agent_announce_capabilities (which can even be triggered multiple times). Sending this message multiple times is a big NO and causes the server to close the client connection, and the client to die. Add a _msg_attach_message_sent boolean to make sure we only send this message once. rhbz #712938
-rw-r--r--client/red_client.cpp22
-rw-r--r--client/red_client.h2
2 files changed, 16 insertions, 8 deletions
diff --git a/client/red_client.cpp b/client/red_client.cpp
index 5b757b83..230e619e 100644
--- a/client/red_client.cpp
+++ b/client/red_client.cpp
@@ -357,6 +357,7 @@ RedClient::RedClient(Application& application)
, _auto_display_res (false)
, _agent_reply_wait_type (-1)
, _aborting (false)
+ , _msg_attach_channels_sent(false)
, _agent_connected (false)
, _agent_mon_config_sent (false)
, _agent_disp_config_sent (false)
@@ -967,16 +968,12 @@ void RedClient::handle_init(RedPeer::InMessage* message)
if (_auto_display_res) {
send_agent_monitors_config();
}
- if (_auto_display_res || !_display_setting.is_empty()) {
- _application.activate_interval_timer(*_agent_timer, AGENT_TIMEOUT);
- } else {
- post_message(new Message(SPICE_MSGC_MAIN_ATTACH_CHANNELS));
- }
+ _application.activate_interval_timer(*_agent_timer, AGENT_TIMEOUT);
} else {
if (_auto_display_res || !_display_setting.is_empty()) {
LOG_WARN("no agent running, display options have been ignored");
}
- post_message(new Message(SPICE_MSGC_MAIN_ATTACH_CHANNELS));
+ send_main_attach_channels();
}
}
@@ -1023,6 +1020,15 @@ void RedClient::handle_agent_disconnected(RedPeer::InMessage* message)
_agent_connected = false;
}
+void RedClient::send_main_attach_channels(void)
+{
+ if (_msg_attach_channels_sent)
+ return;
+
+ post_message(new Message(SPICE_MSGC_MAIN_ATTACH_CHANNELS));
+ _msg_attach_channels_sent = true;
+}
+
void RedClient::on_agent_announce_capabilities(
VDAgentAnnounceCapabilities* caps, uint32_t msg_size)
{
@@ -1053,7 +1059,7 @@ void RedClient::on_agent_announce_capabilities(
if (!_display_setting.is_empty()) {
LOG_WARN("display options have been requested, but the agent doesn't support these options");
}
- post_message(new Message(SPICE_MSGC_MAIN_ATTACH_CHANNELS));
+ send_main_attach_channels();
_application.deactivate_interval_timer(*_agent_timer);
}
}
@@ -1073,7 +1079,7 @@ void RedClient::on_agent_reply(VDAgentReply* reply)
case VD_AGENT_MONITORS_CONFIG:
case VD_AGENT_DISPLAY_CONFIG:
if (_agent_reply_wait_type == reply->type) {
- post_message(new Message(SPICE_MSGC_MAIN_ATTACH_CHANNELS));
+ send_main_attach_channels();
_application.deactivate_interval_timer(*_agent_timer);
_agent_reply_wait_type = -1;
}
diff --git a/client/red_client.h b/client/red_client.h
index ae52d9f2..4cb8e1a9 100644
--- a/client/red_client.h
+++ b/client/red_client.h
@@ -262,6 +262,7 @@ public:
void set_mm_time(uint32_t time);
uint32_t get_mm_time();
+ void send_main_attach_channels(void);
protected:
virtual void on_connecting();
@@ -321,6 +322,7 @@ private:
int _agent_reply_wait_type;
bool _aborting;
+ bool _msg_attach_channels_sent;
bool _agent_connected;
bool _agent_mon_config_sent;