Skip to content

Commit

Permalink
Updated file.c.
Browse files Browse the repository at this point in the history
  • Loading branch information
ax-6 committed Aug 2, 2024
1 parent b107927 commit bd699cf
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions aqvm/base/file/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,24 @@ int AqvmBaseFile_LockStream(struct AqvmBaseFile_File* stream) {
// TODO
return -1;
}
if (stream->file == stdout || stream->file == stderr ||
stream->file == stdin) {
if (AqvmBaseThreadingMutex_LockMutex(&AqvmBaseIo_printMutex) != 0) {
if (stream->file == stdin) {
if (AqvmBaseThreadingMutex_LockMutex(&AqvmBaseIo_inputMutex) != 0) {
// TODO
return -2;
}
}else if (stream->file == stdout || stream->file == stderr) {
if (AqvmBaseThreadingMutex_LockMutex(&AqvmBaseIo_outputMutex) != 0) {
// TODO
return -3;
}
} else {
if (AqvmBaseProcessFileLock_LockFile(stream) != 0) {
// TODO
return -3;
return -4;
}
if (AqvmBaseFile_LockStream(stream) != 0) {
// TODO
return -4;
return -5;
}
}

Expand All @@ -70,20 +74,24 @@ int AqvmBaseFile_UnlockStream(struct AqvmBaseFile_File* stream) {
// TODO
return -1;
}
if (stream->file == stdout || stream->file == stderr ||
stream->file == stdin) {
if (AqvmBaseThreadingMutex_LockMutex(&AqvmBaseIo_printMutex) != 0) {
if (stream->file == stdin) {
if (AqvmBaseThreadingMutex_LockMutex(&AqvmBaseIo_inputMutex) != 0) {
// TODO
return -2;
}
} else if (stream->file == stdout || stream->file == stderr) {
if (AqvmBaseThreadingMutex_LockMutex(&AqvmBaseIo_outputMutex) != 0) {
// TODO
return -3;
}
} else {
if (AqvmBaseProcessFileLock_LockFile(stream) != 0) {
// TODO
return -3;
return -4;
}
if (AqvmBaseFile_LockStream(stream) != 0) {
// TODO
return -4;
return -5;
}
}

Expand Down

0 comments on commit bd699cf

Please sign in to comment.