From: Son Hyunjun Date: Wed, 14 Mar 2012 03:10:20 +0000 (+0900) Subject: add skin server ready X-Git-Tag: TizenStudio_2.0_p2.3~1749 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f829cabf49d43ac280904d767e80323c72a53f1d;p=sdk%2Femulator%2Fqemu.git add skin server ready --- diff --git a/tizen/src/emulator.c b/tizen/src/emulator.c index 7e3da36..7171174 100644 --- a/tizen/src/emulator.c +++ b/tizen/src/emulator.c @@ -30,6 +30,7 @@ */ +#include #include #include "maru_common.h" #include "emulator.h" @@ -73,8 +74,8 @@ static void construct_main_window(int skin_argc, char* skin_argv[]) INFO("construct main window\n"); start_skin_server(11111, 0, 0); #if 1 - if (start_skin_client(skin_argc, skin_argv) == 0) { - //TODO: + if ( 0 > start_skin_client(skin_argc, skin_argv) ) { + exit( -1 ); } #endif diff --git a/tizen/src/skin/maruskin_client.c b/tizen/src/skin/maruskin_client.c index c2b2e5c..cb93d49 100644 --- a/tizen/src/skin/maruskin_client.c +++ b/tizen/src/skin/maruskin_client.c @@ -31,14 +31,21 @@ #include #include #include -#include "maruskin_client.h" #include +#include +#include "maruskin_client.h" +#include "maruskin_server.h" +#include "debug_ch.h" +#define SKIN_SERVER_READY_TIME 3 // second +#define SKIN_SERVER_SLEEP_TIME 10 // milli second #define JAR_SKINFILE_PATH "EmulatorSkin.jar" #define JAVA_EXEFILE_PATH "java" #define JAVA_EXEOPTION "-jar" +MULTI_DEBUG_CHANNEL( qemu, maruskin_client ); + // function modified by caramis // for delivery argv @@ -68,14 +75,40 @@ static void* run_skin_client(void* arg) int start_skin_client(int argc, char* argv[]) { + + int count = 0; + int skin_server_ready = 0; + + while( 1 ) { + + if( 100 * SKIN_SERVER_READY_TIME < count ) { + break; + } + + if( is_ready_skin_server() ) { + skin_server_ready = 1; + break; + }else { + count++; + INFO( "sleep for ready. count:%d\n", count ); + usleep( 1000 * SKIN_SERVER_SLEEP_TIME ); + } + + } + + if( !skin_server_ready ) { + ERR( "skin_server is not ready.\n" ); + return -1; + } + skin_argc = argc; skin_argv = argv; pthread_t thread_id = -1; if (0 != pthread_create(&thread_id, NULL, run_skin_client, NULL)) { - fprintf(stderr, "fail to create skin_client pthread.\n"); - return 0; + ERR( "fail to create skin_client pthread.\n" ); + return -1; } return 1; diff --git a/tizen/src/skin/maruskin_server.c b/tizen/src/skin/maruskin_server.c index 5bfa1a9..6c9eedf 100644 --- a/tizen/src/skin/maruskin_server.c +++ b/tizen/src/skin/maruskin_server.c @@ -73,6 +73,7 @@ static int server_sock = 0; static int client_sock = 0; static int stop_server = 0; static int is_sensord_initialized = 0; +static int ready_server = 0; static int stop_heartbeat = 0; static int recv_heartbeat_count = 0; @@ -128,11 +129,17 @@ void shutdown_skin_server( void ) { void notify_sensor_daemon_start( void ) { INFO( "notify_sensor_daemon_start\n" ); is_sensord_initialized = 1; - if ( 0 > send_skin( client_sock, SEND_SENSOR_DAEMON_START ) ) { - ERR( "fail to send SEND_SENSOR_DAEMON_START to skin.\n" ); + if( client_sock ) { + if ( 0 > send_skin( client_sock, SEND_SENSOR_DAEMON_START ) ) { + ERR( "fail to send SEND_SENSOR_DAEMON_START to skin.\n" ); + } } } +int is_ready_skin_server( void ) { + return ready_server; +} + static void* run_skin_server( void* args ) { uint16_t port; @@ -194,6 +201,9 @@ static void* run_skin_server( void* args ) { INFO( "start accepting socket...\n" ); client_len = sizeof( client_addr ); + + ready_server = 1; + if ( 0 > ( client_sock = accept( server_sock, (struct sockaddr *) &client_addr, &client_len ) ) ) { ERR( "skin_servier accept error\n" ); perror( "skin_servier accept error\n" ); diff --git a/tizen/src/skin/maruskin_server.h b/tizen/src/skin/maruskin_server.h index aa75ac9..c45c931 100644 --- a/tizen/src/skin/maruskin_server.h +++ b/tizen/src/skin/maruskin_server.h @@ -34,7 +34,8 @@ #include pthread_t start_skin_server( uint16_t default_svr_port, int argc, char** argv ); -void shutdown_skin_server(void); -void notify_sensor_daemon_start(void); +void shutdown_skin_server( void ); +void notify_sensor_daemon_start( void ); +int is_ready_skin_server( void ); #endif /* MARUSKIN_SERVER_H_ */