Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit ecfb7e9

Browse files
committed
report ProcessAsyncEvent when process finished
Signed-off-by: Lai Jiangshan <jiangshanlai@gmail.com>
1 parent 966ddbc commit ecfb7e9

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

src/api.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,35 @@
11
#ifndef _HYPERSTART_API_H_
22
#define _HYPERSTART_API_H_
33

4-
#define APIVERSION 4242
4+
// when APIVERSION < 1000000, the version MUST be exactly matched on both sides
5+
#define APIVERSION 4243
56

67
// control command id
78
enum {
8-
GETVERSION,
9+
GETVERSION, // 0
910
STARTPOD,
1011
GETPOD_DEPRECATED,
1112
STOPPOD_DEPRECATED,
1213
DESTROYPOD,
13-
RESTARTCONTAINER_DEPRECATED,
14+
RESTARTCONTAINER_DEPRECATED, // 5
1415
EXECCMD,
1516
CMDFINISHED_DEPRECATED,
1617
READY,
1718
ACK,
18-
ERROR,
19+
ERROR, // 10
1920
WINSIZE,
2021
PING,
2122
PODFINISHED_DEPRECATED,
2223
NEXT,
23-
WRITEFILE,
24+
WRITEFILE, // 15
2425
READFILE,
2526
NEWCONTAINER,
2627
KILLCONTAINER,
2728
ONLINECPUMEM,
28-
SETUPINTERFACE,
29+
SETUPINTERFACE, // 20
2930
SETUPROUTE,
3031
REMOVECONTAINER,
32+
PROCESSASYNCEVENT,
3133
};
3234

3335
/*

src/exec.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ static int hyper_send_exec_eof(struct hyper_exec *exec) {
5656
}
5757

5858
static int hyper_send_exec_code(struct hyper_exec *exec) {
59-
return send_exec_finishing(exec->seq, 13, exec->code);
59+
char *pae; // ProcessAsyncEvent
60+
#define PAE "{\"container\":\"%s\",\"process\":\"%s\",\"event\":\"finished\",\"status\":%d}"
61+
if (asprintf(&pae, PAE, exec->container_id, exec->id, exec->code) < 0) {
62+
return -1;
63+
}
64+
#undef PAE
65+
return hyper_ctl_append_msg(&hyper_epoll.ctl, PROCESSASYNCEVENT, (uint8_t *)pae, strlen(pae));
6066
}
6167

6268
static void pts_hup(struct hyper_event *de, int efd, struct hyper_exec *exec)

src/hyper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ int hyper_open_serial(char *tty);
8585
void hyper_cleanup_pod(struct hyper_pod *pod);
8686
int hyper_enter_sandbox(struct hyper_pod *pod, int pidpipe);
8787
void hyper_pod_destroyed(int failed);
88+
int hyper_ctl_append_msg(struct hyper_event *he, uint32_t type, uint8_t *data, uint32_t len);
8889

8990
extern struct hyper_pod global_pod;
9091
extern struct hyper_epoll hyper_epoll;

src/init.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ struct hyper_epoll hyper_epoll;
4242
sigset_t orig_mask;
4343

4444
static 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

4746
static int hyper_set_win_size(struct hyper_pod *pod, char *json, int length)
4847
{
@@ -1060,7 +1059,7 @@ static int hyper_ttyfd_read(struct hyper_event *he, int efd, int events)
10601059
return ret == 0 ? 0 : -1;
10611060
}
10621061

1063-
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)
10641063
{
10651064
int ret = -1;
10661065
fprintf(stdout, "hyper ctl append type %d, len %d\n", type, len);

0 commit comments

Comments
 (0)