--- scim-bridge-0.4.5/agent/utils/scim-bridge-agent-panel-client.cpp.5-hanging 2006-08-28 20:42:47.000000000 +1000 +++ scim-bridge-0.4.5/agent/utils/scim-bridge-agent-panel-client.cpp 2006-12-05 18:39:13.000000000 +1000 @@ -134,7 +134,7 @@ ScimBridgeAgentPanelClientSignalVoid signal_request_factory_menu; ScimBridgeAgentPanelClientSignalString signal_change_factory; - void launch_panel () const; + retval_t launch_panel (); }; @@ -165,11 +165,12 @@ ScimBridgeAgentPanelClientImpl::~ScimBridgeAgentPanelClientImpl () { + if (socket_client.is_connected ()) close_connection (); scim_bridge_free_display (display); } -void ScimBridgeAgentPanelClientImpl::launch_panel () const +retval_t ScimBridgeAgentPanelClientImpl::launch_panel () { scim_bridge_pdebugln (7, "launch_panel ()"); @@ -194,51 +195,53 @@ scim_bridge_perrorln ("Failed to forking for a panel process: %s", errno == 0 ? "Unknown reason":strerror (errno)); abort (); } + return RETVAL_FAILED; } else if (retval > 0) { waitpid (retval, NULL, 0); + return RETVAL_SUCCEEDED; } else { scim_bridge_perrorln ("Failed to launch a panel: %s", errno == 0 ? "Unknown reason":strerror (errno)); + return RETVAL_FAILED; } } else { - scim_bridge_println ("Not yet supported!"); - abort (); + scim_bridge_println ("No display for the panel"); + return RETVAL_FAILED; } } int ScimBridgeAgentPanelClientImpl::open_connection () { - SocketAddress address (scim_get_default_panel_socket_address (scim_bridge_display_get_name (display))); if (socket_client.is_connected ()) close_connection (); + SocketAddress address (scim_get_default_panel_socket_address (scim_bridge_display_get_name (display))); - bool retval; - int count = 0; - // Try three times. - while (true) { - if ((retval = socket_client.connect (address)) == false) { + for (int i = 0; i < 6; ++i) { + bool connected = socket_client.connect (address); + if (!connected) { usleep (100000); - launch_panel (); - for (int i = 0; i < 200; ++i) { - if (socket_client.connect (address)) { - retval = true; - break; + if ((i >= 3) && (launch_panel ())) { + for (int j = 0; j < 10; ++j) { + if (socket_client.connect (address)) { + connected = true; + break; + } + usleep (100000); } - usleep (100000); } } - if (retval && scim_socket_open_connection (socket_magic_key, String ("FrontEnd"), String ("Panel"), socket_client, socket_timeout)) - break; + if (connected) { + if (scim_socket_open_connection (socket_magic_key, String ("FrontEnd"), String ("Panel"), socket_client, socket_timeout)) { + return socket_client.get_id (); + } + } socket_client.close (); - - if (count++ >= 3) break; - usleep (100000); } - return socket_client.get_id (); + return -1; } --- scim-bridge-0.4.5/agent/scim-bridge-agent.cpp.5-hanging 2006-09-12 08:44:09.000000000 +1000 +++ scim-bridge-0.4.5/agent/scim-bridge-agent.cpp 2006-12-05 18:39:13.000000000 +1000 @@ -246,11 +246,10 @@ const scim_bridge_agent_event_type_t triggers = client->get_trigger_events (); const int socket_fd = client->get_socket_fd (); if (socket_fd < 0) { - if (triggers & SCIM_BRIDGE_AGENT_EVENT_ERROR) { - if (!client->handle_event (SCIM_BRIDGE_AGENT_EVENT_ERROR)) { - i = clients.erase (i); - delete client; - } + if (triggers & SCIM_BRIDGE_AGENT_EVENT_ERROR && !client->handle_event (SCIM_BRIDGE_AGENT_EVENT_ERROR)) { + i = clients.erase (i); + delete client; + continue; } } else { if (socket_fd > max_fd) max_fd = socket_fd; @@ -266,8 +265,8 @@ FD_SET (socket_fd, &error_set); scim_bridge_pdebugln (1, "FD (%d) is registred as a error socket", socket_fd); } - ++i; } + ++i; } timeval current_time;