[Title] rollback(problem in windows ver) feature related to pthread_create =...
authordongkyun.yun <dk77.yun@samsung.com>
Wed, 7 Dec 2011 10:57:44 +0000 (19:57 +0900)
committerdongkyun.yun <dk77.yun@samsung.com>
Wed, 7 Dec 2011 10:57:44 +0000 (19:57 +0900)
[Type]      // Commit Type: Feature / Bugfix / Enhancement
[Module]    // Module Name - (Main / Sub)
[Priority]  // Importance : Critical / Major / Minor
[CQ#]       // CQ Issue Number
[Redmine#]  // Redmine Isuue Number
[Problem]   // Problem Description
[Cause]     // Cause Description
[Solution]  // Solution Description
[TestCase]  // Executed the test-target (How to)

configure
target-i386/opengl_server.c
tizen/src/emulator.c
tizen/src/qemu_gtk_widget.c
tizen/src/sensor_server.c

index d4bff43..667685c 100755 (executable)
--- a/configure
+++ b/configure
@@ -2634,10 +2634,6 @@ fi
 if test "$xfs" = "yes" ; then
   echo "CONFIG_XFS=y" >> $config_host_mak
 fi
-
-# for qemu_thread_create call in tizen
-echo "CONFIG_THREAD=y" >> $config_host_mak
-
 qemu_version=`head $source_path/VERSION`
 echo "VERSION=$qemu_version" >>$config_host_mak
 echo "PKGVERSION=$pkgversion" >>$config_host_mak
index 2816017..7d16b46 100644 (file)
@@ -800,7 +800,7 @@ static void OGLS_main( OGLS_Opts *pOption )
 {
        int sock;
        fd_set active_fd_set, read_fd_set;
-       sigset_t set, oldset;
+
        socklen_t size;
 
 #ifndef _WIN32
@@ -856,18 +856,12 @@ static void OGLS_main( OGLS_Opts *pOption )
                        continue;
                }
 
-
-               /* Leave signal handling to the iothread.  */
-               sigfillset(&set);
-               pthread_sigmask(SIG_SETMASK, &set, &oldset);
                if( pthread_create( (pthread_t *)&taskid, NULL, (void *(*)(void *))OGLS_loop, (void *)pConn ) )
                {
-                       pthread_sigmask(SIG_SETMASK, &oldset, NULL);
                        perror( "pthread_create" );
                        OGLS_removeConn( pConn );
                        continue;
                }
-               pthread_sigmask(SIG_SETMASK, &oldset, NULL);
        }
 
        closesocket( sock );
index 03c6f59..aa7a4af 100644 (file)
@@ -67,7 +67,6 @@
 #include <sys/shm.h> 
 #endif
 
-#include "qemu-thread.h"
 #include "opengl_server.h"
 #include "sdb.h"
 #include "nbd.h"
@@ -156,7 +155,7 @@ DWORD unfsd_thread;
 #endif
 
 #ifdef ENABLE_OPENGL_SERVER
-QemuThread thread_opengl_id;
+pthread_t thread_opengl_id;
 #endif /* ENABLE_OPENGL_SERVER */
 
 #ifndef _WIN32
@@ -328,7 +327,7 @@ void exit_emulator_post_process( void ) {
        INFO( "Emulator Stop: shutdown qemu system, gtk_main quit complete \n");
 
 #ifdef ENABLE_OPENGL_SERVER
-       pthread_cancel(thread_opengl_id.thread);
+       pthread_cancel(thread_opengl_id);
        INFO( "opengl_server thread is quited.\n");
 #endif /* ENABLE_OPENGL_SERVER */
 
@@ -401,9 +400,11 @@ void exit_emulator(void)
        // If user selects 'Yes' in Power off poup, 'qemu_system_shutdown_request' in vl.c is supposed to be called.
 
        /* 2nd way : send command shutdown to emuld in guest image */
-       QemuThread thread;      
-
-       qemu_thread_create(&thread, graceful_shutdown_ftn, NULL);
+       pthread_t thread_id;
+       if (pthread_create(&thread_id, NULL, graceful_shutdown_ftn, NULL) != 0) { 
+               ERR("pthread_create fail \n");
+               qemu_system_shutdown_request();
+       } 
 
 #else
 
@@ -432,7 +433,7 @@ void exit_emulator(void)
        INFO( "Emulator Stop: shutdown qemu system, gtk_main quit complete \n");
 
 #ifdef ENABLE_OPENGL_SERVER
-       pthread_cancel(thread_opengl_id.thread);
+       pthread_cancel(thread_opengl_id);
        INFO( "opengl_server thread is quited.\n");
 #endif /* ENABLE_OPENGL_SERVER */
 
@@ -889,7 +890,7 @@ int main(int argc, char** argv)
        int i, r;
 
 
-       QemuThread thread;
+       pthread_t thread_gtk_id;
 
        init_emulator(&argc, &argv);
        startup_option_parser(&argc, &argv);
@@ -914,24 +915,27 @@ int main(int argc, char** argv)
        register_sig_handler();
 
 #ifndef _WIN32
-
        construct_main_window();
 
        /* 5.3 create gtk thread  */
-       qemu_thread_create(&thread, run_gtk_main, NULL);
-
+       if (pthread_create(&thread_gtk_id, NULL, run_gtk_main, NULL) != 0) {
+               ERR( "error creating gtk_id thread!!\n");
+               return -1;
+       }
 #else /* _WIN32 */
-
        /* if _WIN32, window creation and gtk main must be run in a thread */
-       qemu_thread_create(&thread, construct_main_window_and_run_gtk_main, NULL);
-
+       if (pthread_create(&thread_gtk_id, NULL, construct_main_window_and_run_gtk_main, NULL) != 0) {
+               ERR( "error creating gtk_id thread!!\n");
+               return -1;
+       }
 #endif
 
 #ifdef ENABLE_OPENGL_SERVER
-
        /* create OPENGL server thread */
-       qemu_thread_create(&thread_opengl_id, init_opengl_server, NULL);
-
+       if (pthread_create(&thread_opengl_id, NULL, init_opengl_server, NULL) != 0) {
+               ERR( "error creating opengl_id thread!!");
+               return -1;
+       }
 #endif /* ENABLE_OPENGL_SERVER */
 
        /* 6. create serial console and vmodem, and other processes */
index 5351acc..8b86412 100644 (file)
@@ -38,7 +38,6 @@
 #include "utils.h"
 #include <pthread.h>
 
-#include "qemu-thread.h"
 #include "debug_ch.h"
 #include "../ui/sdl_rotate.h"
 
@@ -225,9 +224,12 @@ void qemu_display_init (DisplayState *ds)
 #ifdef SDL_THREAD
        if(sdl_thread_initialized == 0 ){
                sdl_thread_initialized = 1;
-               QemuThread thread_id;
+               pthread_t thread_id;
                TRACE( "sdl update thread create \n");
-               qemu_thread_create(&thread_id, run_qemu_update, NULL);
+               if (pthread_create(&thread_id, NULL, run_qemu_update, NULL) != 0) {
+                       ERR( "pthread_create fail \n");
+                       return;
+               }
        }
 #endif
 }
index cd6eafe..dfb8401 100644 (file)
@@ -54,7 +54,6 @@
 #include <pthread.h>
 #include <math.h>
 
-#include "qemu-thread.h"
 #include "sensor_server.h"
 #include "emulator.h"
 #define UDP
@@ -183,6 +182,76 @@ static int send_info_to_sensor_daemon(char *send_buf, int buf_size)
        return 1;
 }
 
+#if 0
+/* Not using sdb port forwarding => Using redir in sdb setup */
+static void *create_fw_rota_init(void *arg)
+{
+       int s;
+       int tries = 0;
+       char fw_buf[64] = {0};
+       char recv_buf[8] = {0};
+       char send_buf[32] = {0};
+
+       while(1)
+       {
+               s = tcp_socket_outgoing("127.0.0.1", SDB_HOST_PORT);
+               if (s < 0) {
+
+                       ERR("[%d] can't create socket to talk to the SDB server \n", ++tries);
+                       usleep(1000000);
+
+                       if(tries > 9)
+                               break;
+                       else
+                               continue;
+               }
+
+               memset(fw_buf, 0, sizeof(fw_buf));
+
+               /* length is hex: 0x35 = 53 */
+               sprintf(fw_buf,"0035host-serial:emulator-%d:forward:tcp:%d;tcp:3577"
+                               ,get_sdb_base_port(),  get_sdb_base_port() + SDB_TCP_SENSOR_INDEX );
+
+               /* Over 53+4 */
+               socket_send(s, fw_buf, 60);
+
+               memset(recv_buf, 0, sizeof(recv_buf));
+               recv( s, recv_buf, 4, 0 );
+
+               /* check OKAY */
+               if(!memcmp(recv_buf, "OKAY", 4)) {
+                       INFO( "create forward [%s] success : [%s] \n", fw_buf, recv_buf);
+
+                       /* send init ratation info */
+                       sprintf(send_buf, "1\n3\n0\n-9.80665\n0\n");
+
+                       if( send_info_to_sensor_daemon(send_buf, 32) <= 0 ) {   
+                               ERR( "[%s][%d] send init rotaion info: error \n", __FUNCTION__, __LINE__);
+                       }else{
+                               INFO( "[%s][%d] send init rotation info: sucess \n", __FUNCTION__, __LINE__);
+                               /* all initialized */
+                               sensord_initialized = 1;
+                       }
+
+                       break;
+               }else{
+                       /* not ready */
+                       //fprintf(stderr, "create forward [%s] fail : [%s] \n", fw_buf, recv_buf);
+                       usleep(1000000);
+               }
+
+#ifdef __WIN32
+               closesocket(s);
+#else
+               close(s);
+#endif
+
+       }
+
+       return NULL;
+}
+#endif
+
 gboolean sensor_server(GIOChannel *channel, GIOCondition condition, gpointer data)
 {
        int parse_result;
@@ -219,6 +288,22 @@ gboolean sensor_server(GIOChannel *channel, GIOCondition condition, gpointer dat
                {
                        parse_result = sensor_parser(recv_buf);
 
+#if 0
+                       /* Not using sdb forwarding => Using redir in sdb setup */
+                       if(sent_start_value == 0) {
+
+                               /* new way with sdb */
+                               pthread_t taskid;
+
+                               INFO( "pthread_create for create_forward : \n");
+                               if( pthread_create( (pthread_t *)&taskid, NULL, (void *(*)(void *))create_fw_rota_init, NULL ) ){
+                                       ERR( "pthread_create for create_forward fail: \n");
+                               }   
+
+                               sent_start_value = 1;
+                       }
+#endif
+
                        if(sensord_initialized)
                        {
                                switch(parse_result)