Use the same open semantics regardless of blocking or non so that we always have an fd to lock. Fixes logging of unable to lock jpeg in streaming with buffering
parent
03155da5b6
commit
4b20109b69
|
@ -1164,19 +1164,17 @@ bool Image::WriteJpeg(const std::string &filename,
|
|||
}
|
||||
|
||||
if (!on_blocking_abort) {
|
||||
if ((outfile = fopen(filename.c_str(), "wb")) == nullptr) {
|
||||
Error("Can't open %s for writing: %s", filename.c_str(), strerror(errno));
|
||||
return false;
|
||||
}
|
||||
raw_fd = open(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||
} else {
|
||||
raw_fd = open(filename.c_str(), O_WRONLY | O_NONBLOCK | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||
if (raw_fd < 0)
|
||||
return false;
|
||||
outfile = fdopen(raw_fd, "wb");
|
||||
if (outfile == nullptr) {
|
||||
close(raw_fd);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (raw_fd < 0)
|
||||
return false;
|
||||
outfile = fdopen(raw_fd, "wb");
|
||||
if (outfile == nullptr) {
|
||||
close(raw_fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
struct flock fl = { F_WRLCK, SEEK_SET, 0, 0, 0 };
|
||||
|
|
Loading…
Reference in New Issue