}
struct xobject_h *obj_h = xseg->request_h;
- void *container = XPTR(&obj_h->container);
- xhash_t *allocated = XPTR_TAKE(obj_h->allocated, container);
- xhash_iter_t it;
- xhash_iter_init(allocated, &it);
- xhashidx key, val;
+ struct xobject_iter it;
+ xobj_iter_init(obj_h, &it);
+
+ struct xseg_request *req;
xlock_acquire(&obj_h->lock, srcport);
- while (xhash_iterate(allocated, &it, &key, &val)){
- void *mem = XPTR_TAKE(val, container);
- struct xseg_request *req = mem, *t;
- for (i = 0; i < xheap_get_chunk_size(mem)/obj_h->obj_size; i++) {
- t = req + i;
- struct xobject *obj = (struct xobject *)t;
- //FIXME. obj->magic is not touched by req->serial...
- /* if (obj->magic != MAGIC_REQ && t->src_portno == portno){ */
- if (isDangling(t)){
- if (action == REPORT)
- report_request(t);
- else if (action == FAIL)
- finish_req(t, action);
- else if (action == COMPLETE)
- finish_req(t, COMPLETE);
- }
+ while (xobj_iterate(obj_h, &it, (void **)&req)){
+ //FIXME this will not work cause obj->magic - req->serial is not
+ //touched when a request is get
+ /* if (obj->magic != MAGIC_REQ && t->src_portno == portno){ */
+ if (isDangling(req) && !__xobj_isFree(obj_h, req)){
+ if (action == REPORT)
+ report_request(req);
+ else if (action == FAIL)
+ finish_req(req, action);
+ else if (action == COMPLETE)
+ finish_req(req, COMPLETE);
}
}
xlock_release(&obj_h->lock);
$(BASE)/xtypes/xpool_exports.h $(BASE)/xtypes/xhash_exports.h\
$(BASE)/xtypes/xobj_exports.h
cat $(BASE)/xtypes/xq_exports.h $(BASE)/xseg/xseg_exports.h \
- $(BASE)/xtypes/xpool_exports.h $(BASE)/xtypes/xhash_exports.h | ./make_symbol_map.sh > $@
+ $(BASE)/xtypes/xpool_exports.h $(BASE)/xtypes/xhash_exports.h \
+ $(BASE)/xtypes/xobj_exports.h | ./make_symbol_map.sh > $@
libxseg.so.$(MAJOR).$(MINOR): xseg.pic.o xseg_user.o libxseg.map \
xq/xq.pic.o xpool/xpool.pic.o xhash/xhash.pic.o \
r = xhash_iterate(allocated, &it->xhash_it, &key, &val);
if (!r)
return 0;
- it->chunk = (void *)key;
+ it->chunk = XPTR_TAKE(key, container);
it->cnt = 0;
}
}
-/* TODO implement lock free versions */
-int xobj_check(struct xobject_h *obj_h, void *ptr)
+int __xobj_check(struct xobject_h *obj_h, void *ptr)
{
- int r = 0;
void *container = XPTR(&obj_h->container);
xhash_iter_t it;
uint64_t i, nr_objs;
-
- xlock_acquire(&obj_h->lock, 1);
-
xhash_t *allocated = XPTR_TAKE(obj_h->allocated, container);
xhash_iter_init(allocated, &it);
xhashidx key, val;
obj = (void *) ((unsigned long) mem +
(unsigned long) i * obj_h->obj_size);
if (obj == ptr) {
- r = 1;
- goto out;
+ return 1;
}
}
}
-out:
- xlock_release(&obj_h->lock);
+ return 0;
+}
+int xobj_check(struct xobject_h *obj_h, void *ptr)
+{
+ int r;
+ xlock_acquire(&obj_h->lock, 1);
+ r = __xobj_check(obj_h, ptr);
+ xlock_release(&obj_h->lock);
return r;
}
-int xobj_isFree(struct xobject_h *obj_h, void *ptr)
+int __xobj_isFree(struct xobject_h *obj_h, void *ptr)
{
int r = 0;
void *container = XPTR(&obj_h->container);
xptr node;
struct xobject *obj;
- xlock_acquire(&obj_h->lock, 1);
node = obj_h->list;
while (node){
obj = XPTR_TAKE(node, container);
if (obj == ptr){
- r = 1;
- goto out;
+ return 1;
}
node = obj->next;
}
-out:
- xlock_release(&obj_h->lock);
+ return 0;
+}
+
+int xobj_isFree(struct xobject_h *obj_h, void *ptr)
+{
+ int r;
+ xlock_acquire(&obj_h->lock, 1);
+ r = __xobj_isFree(obj_h, ptr);
+ xlock_release(&obj_h->lock);
return r;
}
int xobj_handler_init(struct xobject_h *obj_h, void *container,
uint32_t magic, uint64_t size, struct xheap *heap);
-void xobj_init_iter(struct xobject_h *obj_h, struct xobject_iter *it);
+void xobj_iter_init(struct xobject_h *obj_h, struct xobject_iter *it);
int xobj_iterate(struct xobject_h *obj_h, struct xobject_iter *it, void **obj);
int xobj_check(struct xobject_h *obj_h, void *obj);
int xobj_isFree(struct xobject_h *obj_h, void *obj);
+int __xobj_check(struct xobject_h *obj_h, void *obj);
+int __xobj_isFree(struct xobject_h *obj_h, void *obj);
+
//TODO
//xobj_handler_destroy()
//releases allocated pages
EXPORT_SYMBOL(xobj_get_obj);
EXPORT_SYMBOL(xobj_put_obj);
EXPORT_SYMBOL(xobj_handler_init);
+EXPORT_SYMBOL(xobj_iter_init);
+EXPORT_SYMBOL(xobj_iterate);
+EXPORT_SYMBOL(__xobj_check);
+EXPORT_SYMBOL(xobj_check);
+EXPORT_SYMBOL(__xobj_isFree);
+EXPORT_SYMBOL(xobj_isFree);