@@ -42,50 +42,40 @@ struct hyper_epoll hyper_epoll;
4242sigset_t orig_mask ;
4343
4444static int hyper_handle_exit (struct hyper_pod * pod );
45- static int hyper_ctl_append_msg (struct hyper_event * he , uint32_t type , uint8_t * data , uint32_t len );
4645
47- int hyper_send_pod_finished (struct hyper_pod * pod )
48- {
49- struct hyper_container * c ;
50- uint8_t * data = NULL , * new ;
51- int c_num = 0 ;
52-
53- list_for_each_entry (c , & pod -> containers , list ) {
54- c_num ++ ;
55- new = realloc (data , c_num * 4 );
56- if (new == NULL ) {
57- free (data );
58- return -1 ;
59- }
60-
61- hyper_set_be32 (new + ((c_num - 1 ) * 4 ), c -> exec .code );
62- data = new ;
63- }
64-
65- return hyper_ctl_append_msg (& hyper_epoll .ctl , PODFINISHED , data , c_num * 4 );
66- }
67-
68- static int hyper_set_win_size (char * json , int length )
46+ static int hyper_set_win_size (struct hyper_pod * pod , char * json , int length )
6947{
7048 struct winsize size ;
7149 struct hyper_exec * exec ;
72- int ret ;
50+ int ret = -1 ;
7351
74- fprintf (stdout , "call hyper_win_size , json %s, len %d\n" , json , length );
52+ fprintf (stdout , "call hyper_set_win_size , json %s, len %d\n" , json , length );
7553 JSON_Value * value = hyper_json_parse (json , length );
7654 if (value == NULL ) {
7755 fprintf (stderr , "set term size failed\n" );
78- ret = -1 ;
7956 goto out ;
8057 }
81- const uint64_t seq = (uint64_t )json_object_get_number (json_object (value ), "seq" );
58+ const char * container = json_object_get_string (json_object (value ), "container" );
59+ const char * process = json_object_get_string (json_object (value ), "process" );
60+ if (!container || !process ) {
61+ fprintf (stderr , "call hyper_set_win_size, invalid config" );
62+ goto out ;
63+ }
8264
83- exec = hyper_find_exec_by_seq (& global_pod , seq );
84- if (exec == NULL ) {
85- fprintf (stdout , "can not find exec whose seq is %" PRIu64 "\n" , seq );
86- ret = 0 ;
65+ struct hyper_container * c = hyper_find_container (pod , container );
66+ if (!c ) {
67+ fprintf (stderr , "call hyper_set_win_size, can not find the container: %s\n" , container );
8768 goto out ;
8869 }
70+ if (strcmp (c -> exec .id , process ) == 0 ) {
71+ exec = & c -> exec ;
72+ } else {
73+ exec = hyper_find_exec_by_name (pod , process );
74+ if (!exec ) {
75+ fprintf (stderr , "call hyper_set_win_size, can not find the process: %s\n" , process );
76+ goto out ;
77+ }
78+ }
8979
9080 size .ws_row = (int )json_object_get_number (json_object (value ), "row" );
9181 size .ws_col = (int )json_object_get_number (json_object (value ), "column" );
@@ -1069,7 +1059,7 @@ static int hyper_ttyfd_read(struct hyper_event *he, int efd, int events)
10691059 return ret == 0 ? 0 : -1 ;
10701060}
10711061
1072- static int hyper_ctl_append_msg (struct hyper_event * he , uint32_t type , uint8_t * data , uint32_t len )
1062+ int hyper_ctl_append_msg (struct hyper_event * he , uint32_t type , uint8_t * data , uint32_t len )
10731063{
10741064 int ret = -1 ;
10751065 fprintf (stdout , "hyper ctl append type %d, len %d\n" , type , len );
@@ -1118,10 +1108,6 @@ static int hyper_ctlmsg_handle(struct hyper_event *he, uint32_t len)
11181108 ret = hyper_start_pod ((char * )buf -> data + 8 , len - 8 );
11191109 hyper_print_uptime ();
11201110 break ;
1121- case STOPPOD_DEPRECATED :
1122- fprintf (stderr , "get abandoned STOPPOD message\n" );
1123- ret = -1 ;
1124- break ;
11251111 case DESTROYPOD :
11261112 pod -> req_destroy = 1 ;
11271113 fprintf (stdout , "get DESTROYPOD message\n" );
@@ -1137,13 +1123,12 @@ static int hyper_ctlmsg_handle(struct hyper_event *he, uint32_t len)
11371123 ret = hyper_cmd_rw_file ((char * )buf -> data + 8 , len - 8 , & datalen , & data , READFILE );
11381124 break ;
11391125 case PING :
1140- case GETPOD :
11411126 break ;
11421127 case READY :
11431128 ret = hyper_rescan ();
11441129 break ;
11451130 case WINSIZE :
1146- ret = hyper_set_win_size ((char * )buf -> data + 8 , len - 8 );
1131+ ret = hyper_set_win_size (pod , (char * )buf -> data + 8 , len - 8 );
11471132 break ;
11481133 case NEWCONTAINER :
11491134 ret = hyper_new_container ((char * )buf -> data + 8 , len - 8 );
@@ -1163,6 +1148,14 @@ static int hyper_ctlmsg_handle(struct hyper_event *he, uint32_t len)
11631148 case SETUPROUTE :
11641149 ret = hyper_cmd_setup_route ((char * )buf -> data + 8 , len - 8 );
11651150 break ;
1151+ case GETPOD_DEPRECATED :
1152+ case STOPPOD_DEPRECATED :
1153+ case RESTARTCONTAINER_DEPRECATED :
1154+ case CMDFINISHED_DEPRECATED :
1155+ case PODFINISHED_DEPRECATED :
1156+ fprintf (stderr , "get abandoned command\n" );
1157+ ret = -1 ;
1158+ break ;
11661159 default :
11671160 ret = -1 ;
11681161 break ;
0 commit comments