Browse Source

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

Suren A. Chilingaryan 12 years ago
parent
commit
01f2f1126e
1 changed files with 5 additions and 1 deletions
  1. 5 1
      fastwriter.c

+ 5 - 1
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;