Skip to content

Commit 3a079d5

Browse files
author
anon
committed
stop generating when the stream is closed
1 parent 7a8104f commit 3a079d5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

examples/server/server.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,12 @@ int main(int argc, char **argv)
860860
data.dump(llama.json_indent, ' ', false,
861861
json::error_handler_t::replace) +
862862
"\n\n";
863-
sink.write(str.data(), str.size());
863+
if (!sink.write(str.data(), str.size())) {
864+
if (llama.verbose) {
865+
fprintf(stderr, "stream closed\n");
866+
}
867+
return false;
868+
}
864869
}
865870

866871
sink.done();

0 commit comments

Comments
 (0)