Skip to content

Commit 9d074e5

Browse files
committed
avoid dead-loop in case of no iouring
1 parent 0d23ac5 commit 9d074e5

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

io/test/test-fork.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ int fork_child_process() {
121121

122122
LOG_INFO("child hello, pid `", getpid());
123123
while (!exit_flag) {
124-
photon::thread_usleep(200 * 1000);
124+
int ret = photon::thread_usleep(200 * 1000);
125+
if (ret < 0) return ret;
125126
}
126127
photon::fini();
127128
LOG_INFO("child exited, pid `", getpid());
@@ -144,7 +145,8 @@ int fork_parent_process(uint64_t event_engine) {
144145
return m_pid;
145146
}
146147
photon::fini();
147-
photon::init(event_engine, k_init_io_engine);
148+
int ret = photon::init(event_engine, k_init_io_engine);
149+
if (ret < 0) LOG_ERRNO_RETURN(0, -1, "failed to init event engine");
148150

149151
photon::block_all_signal();
150152
photon::sync_signal(SIGINT, &sigint_handler);
@@ -289,7 +291,7 @@ TEST(ForkTest, LIBAIO) {
289291
std::unique_ptr<photon::fs::IFileSystem> fs(
290292
photon::fs::new_localfs_adaptor("/tmp/", photon::fs::ioengine_libaio));
291293
std::unique_ptr<photon::fs::IFile> lf(
292-
fs->open("test_local_fs_fork_parent", O_RDWR | O_CREAT, 0755));
294+
fs->open("test_local_fs_fork_parent", O_RDWR | O_CREAT, 0644));
293295
void* buf = nullptr;
294296
::posix_memalign(&buf, 4096, 4096);
295297
DEFER(free(buf));

0 commit comments

Comments
 (0)