summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2012-05-12 06:33:32 +0200
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2012-05-12 06:33:32 +0200
commit01f2f1126eae05c9c1bd4b0560fd154e475b3bda (patch)
tree051fed222b98fa00c4608a5a8a303f74371e7e8b
parent0af5dbbe4edec6a25cc4a66248bee38f570d131e (diff)
downloadfastwriter-01f2f1126eae05c9c1bd4b0560fd154e475b3bda.tar.gz
fastwriter-01f2f1126eae05c9c1bd4b0560fd154e475b3bda.tar.bz2
fastwriter-01f2f1126eae05c9c1bd4b0560fd154e475b3bda.tar.xz
fastwriter-01f2f1126eae05c9c1bd4b0560fd154e475b3bda.zip
Report with different error codes if library will block until buffer is free or if the supplied block is too big to fit into the buffer
-rw-r--r--fastwriter.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/fastwriter.c b/fastwriter.c
index 84ef022..e812681 100644
--- a/fastwriter.c
+++ b/fastwriter.c
@@ -241,9 +241,13 @@ static void *fastwriter_writer_thread(void *user) {
int fastwriter_push(fastwriter_t *ctx, size_t size, const void *data) {
size_t part1, end;
size_t free = fastwriter_compute_free_space(ctx);
-
+
if (free < size) {
ctx->max_usage = ctx->size;
+
+ if (size > ctx->size) {
+ return EOVERFLOW;
+ }
if ((ctx->flags&FASTWRITER_FLAGS_BLOCK)==0)
return EWOULDBLOCK;