Explicit tying by fb_tie() should be used instead.
the flushed buffer, which is not necessarily the same as after the data you've
really read.
-Most fastbuf back-ends also participate in the libucw resource management system.
-If you have a resource pool active, newly created fastbufs are automatically tied
-to resources in the pool, so when the pool gets cleaned up, the fastbufs are
-freed, too. The bclose() function is still available and it removes the tie
-as needed.
+Fastbufs can also participate in the libucw resource management system.
+You can tie a fastbuf to a resource in the current resource pool by @fb_tie().
+When the pool gets cleaned up, the fastbuf is automatically closed. If you call
+@bclose() explicitly, the resource is removed, too.
.Back-ends:
- <<fbparam,Files (parametrized)>>
if (f)
{
bflush(f);
- if (f->res)
- {
- res_drop(f->res);
- f->res = NULL;
- }
+ res_detach(f->res);
DBG("FB: closing", f);
if (f->close)
f->close(f); /* Should always free all internal resources, even if it throws an exception */
struct resource *res; /* The fastbuf can be tied to a resource pool */
};
-struct fastbuf *fb_tie(struct fastbuf *b); /* Tie fastbuf to a resource if there is an active pool */
-
/**
* Fastbuf flags
*/
FB_DIE_ON_EOF = 0x2, /* Most of read operations throw "fb.eof" on EOF */
};
+/** Tie a fastbuf to a resource in the current resource pool. Returns the pointer to the same fastbuf. **/
+struct fastbuf *fb_tie(struct fastbuf *b);
+
/***
* === Fastbuf on files [[fbparam]]
*
f->name = af->name;
f->spout = fbatomic_spout;
f->close = fbatomic_close;
- return fb_tie(f);
+ return f;
}
#ifdef TEST
f->close = fbdir_close;
f->config = fbdir_config;
f->can_overwrite_buffer = 2;
- return fb_tie(f);
+ return f;
}
#ifdef TEST
f->close = bfd_close;
f->config = bfd_config;
f->can_overwrite_buffer = 2;
- return fb_tie(f);
+ return f;
}
void
b->spout = fbgrow_spout;
b->seek = fbgrow_seek;
b->can_overwrite_buffer = 1;
- return fb_tie(b);
+ return b;
}
struct fastbuf *fbgrow_create(unsigned basic_size)
f->refill = bfl_refill;
f->close = bfl_close;
f->can_overwrite_buffer = 2;
- return fb_tie(f);
+ return f;
}
#ifdef TEST
f->name = "<fbmem-write>";
f->spout = fbmem_spout;
f->close = fbmem_close;
- return fb_tie(f);
+ return f;
}
struct fastbuf *
f->seek = fbmem_seek;
f->close = fbmem_close;
f->can_overwrite_buffer = 1;
- return fb_tie(f);
+ return f;
}
#ifdef TEST
f->seek = bfmm_seek;
f->close = bfmm_close;
f->config = bfmm_config;
- return fb_tie(f);
+ return f;
}
#ifdef TEST
f->spout = fbs_spout;
f->close = fbs_close;
f->can_overwrite_buffer = 1;
- return fb_tie(f);
+ return f;
}
#ifdef TEST