OSDN Git Service

*** empty log message ***
authorkoinec <>
Sat, 12 Dec 2009 06:19:06 +0000 (06:19 +0000)
committerkoinec <>
Sat, 12 Dec 2009 06:19:06 +0000 (06:19 +0000)
deamon/drd64_marshald_dispatch.c

index 4f502da..333e1d4 100644 (file)
@@ -76,10 +76,6 @@ int
                return -1;
        }
 
-       /*      if( i_socket_new >= i_selects_max )
-               { i_selects_max = i_socket_new + 1; }
-       */
-
        FD_SET( i_socket_new, &g_fds_orig );
 
        p_recv = Drd64_Server_RecvStatus_AllocRecvStatus(
@@ -94,20 +90,6 @@ int
        return i_socket_new;
 }
 
-/*void
-       Drd64_Marshald_Dispatch_InitRecvStatus(
-               Drd64_Server_RecvStatus *p_recv )
-{
-       assert( NULL != p_recv );
-
-       p_recv->i_read_phase    = DRD64_SERVER_RECVSTATUS_PHASE_HEADER;
-       p_recv->b_recv_status   = DRD64_SERVER_RECVSTATUS_STATUS_READ;
-       p_recv->i_remain_bytes  = sizeof( Drd64_PacketHeader );
-       p_recv->pv_resume               = p_recv->pv_buf;
-
-       return;
-}*/
-
 
 int
        Drd64_Marshald_Dispatch_ExecPacket(
@@ -299,7 +281,7 @@ int
        int             i_selects_base;
        int     i_selects_max;
        int             i_selects_last;
-       int             i_socket_server;
+       //int           i_socket_server;
        Drd64_Server_RecvStatus         *p_recv;
        Drd64_Server_RecvStatus         *p_recv_resume;
        struct  timeval                         tmval;
@@ -324,100 +306,69 @@ int
        
                /* Phase 2: Receive Packet */
                if( 0 < i_selects )             {
-                       i_socket_server = -1;
-                       if( FD_ISSET( p_marshald->i_socket_local, &fds_now ) ) 
+                       //i_socket_server       = -1;
+                       /*if( FD_ISSET( p_marshald->i_socket_local, &fds_now ) ) 
                                { i_socket_server       = p_marshald->i_socket_local; }
                        else if( FD_ISSET( p_marshald->i_socket_inet, &fds_now ) ) 
                                { i_socket_server       = p_marshald->i_socket_inet; }
 
                        if( -1 < i_socket_server )      {
                                i_socket_new = Drd64_Marshald_Dispatch_OpenSocket( i_socket_server );
-//                                     if( i_socket_new >= i_selects_max )
-//                                             { i_selects_max = i_socket_new + 1; }
-                               /*
-                               i_socket_new    = accept( i_socket_server, NULL, NULL );
-                               DRD64_DEBUG_SYSCALL("accept(New Comm.)",i_socket_new,errno);
+                       }
+                       else    { */
 
-                               if( -1 != i_socket_new )    {
-       
-                                       if( i_socket_new >= i_selects_max )
-                                               { i_selects_max = i_socket_new + 1; }
+                       //VVVVVVVV
+                       /* Server Socket from Local */
+                       if( FD_ISSET( p_marshald->i_socket_local, &fds_now ))   {
+                               Drd64_Marshald_Dispatch_OpenSocket(
+                                                               p_marshald->i_socket_local );
+                       }
 
-                                       FD_SET( i_socket_new, &g_fds_orig );
+                       /* Server Socket from Local */
+                       if( FD_ISSET( p_marshald->i_socket_inet, &fds_now ))    {
+                               Drd64_Marshald_Dispatch_OpenSocket(
+                                                               p_marshald->i_socket_inet );
+                       }
 
-                                       p_recv = Drd64_Server_RecvStatus_AllocRecvStatus(
-                                                       i_socket_new, DRD64_MARSHALD_RECVSTATUS_UNITS );
+                       i_resume_flag   = 0x00; 
+                       for( i_cnt = 0; i_cnt < i_selects_max; i_cnt++ )    {
 
-                                       if( NULL != p_recv )    {
-                                               //Drd64_Marshald_Dispatch_InitRecvStatus( p_recv );
-                                               Drd64_Server_RecvStatus_InitRecvStatus( p_recv );
-                                       }
-                                        //XXX : Error Proc. 
-                                       else {
-                                       } 
-                               }*/
-                               /* XXX : Error Proc. 
-                               else {
-                               } */
-                       }
-                       else    {
-                               i_resume_flag   = 0x00; 
-                               for( i_cnt = 0; i_cnt < i_selects_max; i_cnt++ )    {
-
-                                       /* Drd64 Clinet & Marshald => No Judge */
-                                       if(( i_cnt == p_marshald->i_socket_local ) ||
-                                                       ( i_cnt == p_marshald->i_socket_inet ))
-                                               { continue; }
-
-                                       p_recv  = Drd64_Server_RecvStatus_GetRecvStatus( i_cnt );
-                                       if( NULL == p_recv )    { continue; }
-
-                                       if( FD_ISSET( i_cnt, &fds_now ) )       {
-                                               /* Read */
-                                               assert( DRD64_SERVER_RECVSTATUS_STATUS_READ
-                                                                                       == p_recv->b_recv_status );
-                       
-                                               /*i_err = Drd64_Server_RecvSocket_SocketRead_Cert(
-                                                                               i_cnt, &i_pid );*/
-                                               i_err = Drd64_Server_RecvSocket_SocketRead( i_cnt );
-                                               DRD64_DEBUG_PRINT("SocketRead",i_err,"FD",i_cnt,"DestPid",i_pid);
-                                               /* Judge Packet */
-                                               i_result = Drd64_Marshald_Dispatch_JudgePacket(
-                                                                       i_cnt, i_err, p_recv, &drd64_marshald_info );
-
-                                               /* 0x00 = Judge 1 : Disconnect ( Others Packet ) */
-                                               if( DRD64_MARSHALD_DISPATCH_RESULT_CLOSE == i_result )  {
-                                                       Drd64_Marshald_Dispatch_CloseSocket( i_cnt );
-                                               }
-                                               else if( DRD64_MARSHALD_DISPATCH_RESULT_RESTART
-                                                                                                                       == i_result )
-                                                       { i_resume_flag = 0x01; }
-                                               /* 0x01 = Judge 1 : Reading Next */
-                                       }
+                               /* Drd64 Clinet & Marshald => No Judge */
+                               if(( i_cnt == p_marshald->i_socket_local ) ||
+                                               ( i_cnt == p_marshald->i_socket_inet ))
+                                       { continue; }
 
-                                       /* Check TimeOut RecvStat */
-                                       /*if( DRD64_SERVER_RECVSTATUS_STATUS_RESUME
-                                                                                       == p_recv->b_recv_status )      {
-                                               i_result = Drd64_Marshald_Dispatch_ExecPacket(
-                                                                               i_cnt, p_recv, &drd64_marshald_info );
-                                               if( DRD64_MARSHALD_DISPATCH_RESULT_CLOSE == i_result )  {
-                                                       Drd64_Marshald_Dispatch_CloseSocket( i_cnt );
-                                               }
-                                       }*/
-                               }
+                               p_recv  = Drd64_Server_RecvStatus_GetRecvStatus( i_cnt );
+                               if( NULL == p_recv )    { continue; }
 
-                               /* Check Restart Packet (RecvStatus) */
-                               if( 0x00 != i_resume_flag )             {
-                                       Drd64_Marshald_Dispatch_ExecResumeRecvStatus(
-                                                                                       &drd64_marshald_info );
+                               if( FD_ISSET( i_cnt, &fds_now ) )       {
+                                       /* Read */
+                                       assert( DRD64_SERVER_RECVSTATUS_STATUS_READ
+                                                                               == p_recv->b_recv_status );
+               
+                                       /*i_err = Drd64_Server_RecvSocket_SocketRead_Cert(
+                                                                       i_cnt, &i_pid );*/
+                                       i_err = Drd64_Server_RecvSocket_SocketRead( i_cnt );
+                                       DRD64_DEBUG_PRINT("SocketRead",i_err,"FD",i_cnt,"DestPid",i_pid);
+                                       /* Judge Packet */
+                                       i_result = Drd64_Marshald_Dispatch_JudgePacket(
+                                                               i_cnt, i_err, p_recv, &drd64_marshald_info );
+
+                                       /* 0x00 = Judge 1 : Disconnect ( Others Packet ) */
+                                       if( DRD64_MARSHALD_DISPATCH_RESULT_CLOSE == i_result )  {
+                                                       Drd64_Marshald_Dispatch_CloseSocket( i_cnt );
+                                       }
+                                       else if( DRD64_MARSHALD_DISPATCH_RESULT_RESTART
+                                                                                                                       == i_result )
+                                               { i_resume_flag = 0x01; }
+                                       /* 0x01 = Judge 1 : Reading Next */
                                }
+                       }
 
-                               /* Set Max fd */
-                               /*i_selects_last        = Drd64_Server_RecvStatus_GetRecvStatMax();
-                               if( i_selects_last > i_selects_base )
-                                       { i_selects_max = i_selects_last; }
-                               else
-                                       { i_selects_max = i_selects_base; }*/
+                       /* Check Restart Packet (RecvStatus) */
+                       if( 0x00 != i_resume_flag )             {
+                               Drd64_Marshald_Dispatch_ExecResumeRecvStatus(
+                                                                               &drd64_marshald_info );
                        }
 
                        /* Set Max fd */
@@ -426,6 +377,7 @@ int
                                { i_selects_max = i_selects_last; }
                        else
                                { i_selects_max = i_selects_base; }
+                       printf("%d\n", i_selects_max );
                }
 
                /* Phase 3: Check TimeOut Resume Packet */