t/io_uring: stop when max number of files is reached
authorJens Axboe <axboe@kernel.dk>
Wed, 6 Mar 2019 15:24:38 +0000 (08:24 -0700)
committerJens Axboe <axboe@kernel.dk>
Wed, 6 Mar 2019 15:24:38 +0000 (08:24 -0700)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
t/io_uring.c

index 7c75c88..c7139f8 100644 (file)
@@ -501,13 +501,19 @@ int main(int argc, char *argv[])
 
        i = 1;
        while (!do_nop && i < argc) {
-               struct file *f = &s->files[s->nr_files];
+               struct file *f;
 
+               if (s->nr_files == MAX_FDS) {
+                       printf("Max number of files (%d) reached\n", MAX_FDS);
+                       break;
+               }
                fd = open(argv[i], flags);
                if (fd < 0) {
                        perror("open");
                        return 1;
                }
+
+               f = &s->files[s->nr_files];
                f->real_fd = fd;
                if (get_file_size(f)) {
                        printf("failed getting size of device/file\n");