@@ -607,7 +607,15 @@ fio_close(int fd)
607607 fio_fdset &= ~(1 << hdr .handle );
608608
609609 IO_CHECK (fio_write_all (fio_stdout , & hdr , sizeof (hdr )), sizeof (hdr ));
610- /* Note, that file is closed without waiting for confirmation */
610+
611+ /* Wait for response */
612+ IO_CHECK (fio_read_all (fio_stdin , & hdr , sizeof (hdr )), sizeof (hdr ));
613+
614+ if (hdr .arg != 0 )
615+ {
616+ errno = hdr .arg ;
617+ return -1 ;
618+ }
611619
612620 return 0 ;
613621 }
@@ -617,6 +625,22 @@ fio_close(int fd)
617625 }
618626}
619627
628+ /* Close remote file implementation */
629+ static void
630+ fio_close_impl (int fd , int out )
631+ {
632+ fio_header hdr ;
633+
634+ hdr .cop = FIO_CLOSE ;
635+ hdr .arg = 0 ;
636+
637+ if (close (fd ) != 0 )
638+ hdr .arg = errno ;
639+
640+ /* send header */
641+ IO_CHECK (fio_write_all (out , & hdr , sizeof (hdr )), sizeof (hdr ));
642+ }
643+
620644/* Truncate stdio file */
621645int
622646fio_ftruncate (FILE * f , off_t size )
@@ -3000,7 +3024,7 @@ fio_communicate(int in, int out)
30003024 IO_CHECK (fio_write_all (out , & hdr , sizeof (hdr )), sizeof (hdr ));
30013025 break ;
30023026 case FIO_CLOSE : /* Close file */
3003- SYS_CHECK ( close ( fd [hdr .handle ]) );
3027+ fio_close_impl ( fd [hdr .handle ], out );
30043028 break ;
30053029 case FIO_WRITE : /* Write to the current position in file */
30063030// IO_CHECK(fio_write_all(fd[hdr.handle], buf, hdr.size), hdr.size);
0 commit comments