| @@ -95,10 +95,14 @@ send_thread(void *arg __unused) | |||||
| { | { | ||||
| struct g_gate_ctl_io ggio; | struct g_gate_ctl_io ggio; | ||||
| struct g_gate_hdr hdr; | struct g_gate_hdr hdr; | ||||
| char buf[MAXPHYS]; | |||||
| static char *buf; | |||||
| ssize_t data; | ssize_t data; | ||||
| int buflen = 1024*1024; | |||||
| int error; | int error; | ||||
| if (buf == NULL) | |||||
| buf = malloc(buflen); | |||||
| g_gate_log(LOG_NOTICE, "%s: started!", __func__); | g_gate_log(LOG_NOTICE, "%s: started!", __func__); | ||||
| ggio.gctl_version = G_GATE_VERSION; | ggio.gctl_version = G_GATE_VERSION; | ||||
| @@ -106,7 +110,7 @@ send_thread(void *arg __unused) | |||||
| ggio.gctl_data = buf; | ggio.gctl_data = buf; | ||||
| for (;;) { | for (;;) { | ||||
| ggio.gctl_length = sizeof(buf); | |||||
| ggio.gctl_length = buflen; | |||||
| ggio.gctl_error = 0; | ggio.gctl_error = 0; | ||||
| g_gate_ioctl(G_GATE_CMD_START, &ggio); | g_gate_ioctl(G_GATE_CMD_START, &ggio); | ||||
| error = ggio.gctl_error; | error = ggio.gctl_error; | ||||
| @@ -203,9 +207,14 @@ recv_thread(void *arg __unused) | |||||
| { | { | ||||
| struct g_gate_ctl_io ggio; | struct g_gate_ctl_io ggio; | ||||
| struct g_gate_hdr hdr; | struct g_gate_hdr hdr; | ||||
| char buf[MAXPHYS]; | |||||
| static char *buf; | |||||
| int buflen; | |||||
| ssize_t data; | ssize_t data; | ||||
| buflen = 1024*1024; | |||||
| if (buf == NULL) | |||||
| buf = malloc(buflen); | |||||
| g_gate_log(LOG_NOTICE, "%s: started!", __func__); | g_gate_log(LOG_NOTICE, "%s: started!", __func__); | ||||
| ggio.gctl_version = G_GATE_VERSION; | ggio.gctl_version = G_GATE_VERSION; | ||||
| @@ -233,6 +242,13 @@ recv_thread(void *arg __unused) | |||||
| ggio.gctl_length = hdr.gh_length; | ggio.gctl_length = hdr.gh_length; | ||||
| ggio.gctl_error = hdr.gh_error; | ggio.gctl_error = hdr.gh_error; | ||||
| if (ggio.gctl_length > buflen) { | |||||
| g_gate_log(LOG_ERR, "Received too large data, %llu.", ggio.gctl_length); | |||||
| reconnect = 1; | |||||
| pthread_kill(sendtd, SIGUSR1); | |||||
| break; | |||||
| } | |||||
| if (ggio.gctl_error == 0 && ggio.gctl_cmd == GGATE_CMD_READ) { | if (ggio.gctl_error == 0 && ggio.gctl_cmd == GGATE_CMD_READ) { | ||||
| data = g_gate_recv(recvfd, ggio.gctl_data, | data = g_gate_recv(recvfd, ggio.gctl_data, | ||||
| ggio.gctl_length, MSG_WAITALL); | ggio.gctl_length, MSG_WAITALL); | ||||