Wait remote agent to complete its work

This commit is contained in:
Konstantin Knizhnik
2020-03-13 19:57:15 +03:00
parent da283d3ead
commit 9bd2bea0b7
2 changed files with 14 additions and 2 deletions
+11 -1
View File
@@ -368,6 +368,12 @@ fio_disconnect(void)
{
if (fio_stdin)
{
fio_header hdr;
hdr.cop = FIO_DISCONNECT;
hdr.size = 0;
IO_CHECK(fio_write_all(fio_stdout, &hdr, sizeof(hdr)), sizeof(hdr));
IO_CHECK(fio_read_all(fio_stdin, &hdr, sizeof(hdr)), sizeof(hdr));
Assert(hdr.cop == FIO_DISCONNECTED);
SYS_CHECK(close(fio_stdin));
SYS_CHECK(close(fio_stdout));
fio_stdin = 0;
@@ -1492,7 +1498,7 @@ void fio_communicate(int in, int out)
SYS_CHECK(setmode(out, _O_BINARY));
#endif
/* Main loop until command of processing master command */
/* Main loop until end of processing all master commands */
while ((rc = fio_read_all(in, &hdr, sizeof hdr)) == sizeof(hdr)) {
if (hdr.size != 0) {
if (hdr.size > buf_size) {
@@ -1632,6 +1638,10 @@ void fio_communicate(int in, int out)
crc = pgFileGetCRC(buf, true, true);
IO_CHECK(fio_write_all(out, &crc, sizeof(crc)), sizeof(crc));
break;
case FIO_DISCONNECT:
hdr.cop = FIO_DISCONNECTED;
IO_CHECK(fio_write_all(out, &hdr, sizeof(hdr)), sizeof(hdr));
break;
default:
Assert(false);
}
+3 -1
View File
@@ -36,7 +36,9 @@ typedef enum
FIO_SEND_PAGES,
FIO_PAGE,
FIO_WRITE_COMPRESSED,
FIO_GET_CRC32
FIO_GET_CRC32,
FIO_DISCONNECT,
FIO_DISCONNECTED,
} fio_operations;
typedef enum