From: Son Hyunjun Date: Fri, 27 Apr 2012 02:16:53 +0000 (+0900) Subject: [Title] enhance send queue logic / change log level from WARN to INFO / increate... X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~1620 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f2adadc11852b6f203450aceda723e4ba1bae71b;p=sdk%2Femulator%2Fqemu.git [Title] enhance send queue logic / change log level from WARN to INFO / increate hearbeat time from 5 sec to 10 sec [Type] Enhancement [Module] Skin [Priority] Minor [CQ#] [Redmine#] [Problem] [Cause] [Solution] Change-Id: I5ce9de0594d66c1334c190773ea77da3682908b0 --- diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/SocketCommunicator.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/SocketCommunicator.java index 3d5658b10c..51c49499cc 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/SocketCommunicator.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/SocketCommunicator.java @@ -36,9 +36,11 @@ import java.io.DataOutputStream; import java.io.IOException; import java.net.Socket; import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; import java.util.Timer; import java.util.TimerTask; -import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -84,15 +86,15 @@ public class SocketCommunicator implements ICommunicator { } public static final int HEART_BEAT_INTERVAL = 1; //second - public static final int HEART_BEAT_EXPIRE = 5; - - public final static int SEND_QUEUE_WAIT_INTERVAL = 10; // milli-seconds + public static final int HEART_BEAT_EXPIRE = 10; public final static int SCREENSHOT_WAIT_INTERVAL = 3; // milli-seconds public final static int SCREENSHOT_WAIT_LIMIT = 3000; // milli-seconds public final static int DETAIL_INFO_WAIT_INTERVAL = 1; // milli-seconds public final static int DETAIL_INFO_WAIT_LIMIT = 3000; // milli-seconds + public final static int MAX_SEND_QUEUE_SIZE = 100000; + private static int reqId; private Logger logger = SkinLogger.getSkinLogger( SocketCommunicator.class ).getLogger(); @@ -115,7 +117,7 @@ public class SocketCommunicator implements ICommunicator { private DataTranfer detailInfoTransfer; private Thread sendThread; - private ConcurrentLinkedQueue sendQueue; + private LinkedList sendQueue; public SocketCommunicator( EmulatorConfig config, int uId, int windowHandleId, EmulatorSkin skin ) { @@ -152,19 +154,22 @@ public class SocketCommunicator implements ICommunicator { @Override public void run() { - try { + sendQueue = new LinkedList(); - sendQueue = new ConcurrentLinkedQueue(); + sendThread = new Thread() { - sendThread = new Thread() { - @Override - public void run() { + List list = new ArrayList(); + + @Override + public void run() { - while ( true ) { + while ( true ) { - synchronized ( sendThread ) { + synchronized ( sendQueue ) { + + if ( sendQueue.isEmpty() ) { try { - sendThread.wait( SEND_QUEUE_WAIT_INTERVAL ); + sendQueue.wait(); } catch ( InterruptedException e ) { logger.log( Level.SEVERE, e.getMessage(), e ); } @@ -174,22 +179,32 @@ public class SocketCommunicator implements ICommunicator { while ( true ) { sendData = sendQueue.poll(); if ( null != sendData ) { - sendToQEMUInternal( sendData ); + list.add( sendData ); } else { break; } } - if ( isTerminated ) { - break; - } + } + + for ( SkinSendData data : list ) { + sendToQEMUInternal( data ); + } + list.clear(); + + if ( isTerminated ) { + break; } } - }; - sendThread.start(); + } + }; + + sendThread.start(); + + try { dis = new DataInputStream( socket.getInputStream() ); dos = new DataOutputStream( socket.getOutputStream() ); @@ -423,11 +438,14 @@ public class SocketCommunicator implements ICommunicator { @Override public void sendToQEMU( SendCommand command, ISendData data ) { - - sendQueue.add( new SkinSendData( command, data ) ); - - synchronized ( sendThread ) { - sendThread.notifyAll(); + + synchronized ( sendQueue ) { + if ( MAX_SEND_QUEUE_SIZE < sendQueue.size() ) { + logger.warning( "Send queue size exceeded max value, do not push data into send queue." ); + } else { + sendQueue.add( new SkinSendData( command, data ) ); + sendQueue.notifyAll(); + } } } @@ -559,9 +577,9 @@ public class SocketCommunicator implements ICommunicator { heartbeatExecutor.shutdownNow(); } - if( null != sendThread ) { - synchronized ( sendThread ) { - sendThread.notifyAll(); + if( null != sendQueue ) { + synchronized ( sendQueue ) { + sendQueue.notifyAll(); } } diff --git a/tizen/src/skin/maruskin_operation.c b/tizen/src/skin/maruskin_operation.c index 80e43f392a..b98fb23dca 100644 --- a/tizen/src/skin/maruskin_operation.c +++ b/tizen/src/skin/maruskin_operation.c @@ -405,7 +405,7 @@ static void* run_timed_shutdown_thread( void* args ) { fprintf( stdout, "Wait for shutdown qemu...%d\n", ( i + 1 ) ); } - WARN( "Shutdown qemu !!!\n" ); + INFO( "Shutdown qemu !!!\n" ); qemu_system_shutdown_request(); return NULL; diff --git a/tizen/src/skin/maruskin_server.c b/tizen/src/skin/maruskin_server.c index 975b982aec..d5b14e4b96 100644 --- a/tizen/src/skin/maruskin_server.c +++ b/tizen/src/skin/maruskin_server.c @@ -63,8 +63,8 @@ MULTI_DEBUG_CHANNEL( qemu, skin_server ); #define SEND_BUF_SIZE 512 #define HEART_BEAT_INTERVAL 1 -#define HEART_BEAT_FAIL_COUNT 5 -#define HEART_BEAT_EXPIRE_COUNT 5 +#define HEART_BEAT_FAIL_COUNT 10 +#define HEART_BEAT_EXPIRE_COUNT 10 #if 0 // do not restarting skin process ( prevent from abnormal behavior killing a skin process in Windows ) #define RESTART_CLIENT_MAX_COUNT 1 @@ -216,7 +216,7 @@ void shutdown_skin_server( void ) { } if ( close_server_socket ) { - WARN( "skin client did not send normal shutdown response.\n" ); + INFO( "skin client did not send normal shutdown response.\n" ); if ( server_sock ) { #ifdef _WIN32 closesocket( server_sock ); @@ -272,7 +272,7 @@ static void parse_skinconfig_prop( void ) { rewind( fp ); if ( 0 >= buf_size ) { - WARN( "%s contents is empty.\n", SKIN_CONFIG_PROP ); + INFO( "%s contents is empty.\n", SKIN_CONFIG_PROP ); fclose( fp ); return; } @@ -459,7 +459,7 @@ static void* run_skin_server( void* args ) { if ( 0 > read_cnt ) { if( is_force_close_client ) { - WARN( "force close client socket.\n" ); + INFO( "force close client socket.\n" ); is_force_close_client = 0; }else { ERR( "skin_server read error:%d\n", read_cnt ); @@ -1020,9 +1020,9 @@ static void* do_heart_beat( void* args ) { need_restart_skin_client = 0; restart_client_count++; - WARN( "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" ); - WARN( "!!! restart skin client process !!!\n" ); - WARN( "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" ); + INFO( "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" ); + INFO( "!!! restart skin client process !!!\n" ); + INFO( "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" ); is_force_close_client = 1; if ( client_sock ) {