struct packet *packet;
int (*recv_cb)(pid_t pid, int handle, const struct packet *packet, void *data);
void *data;
+
+ int in_recv;
};
struct recv_ctx {
ctx->packet = NULL;
ctx->recv_cb = NULL;
ctx->data = NULL;
+ ctx->in_recv = 0;
s_info.request_list = dlist_append(s_info.request_list, ctx);
return ctx;
break;
}
- if (request->recv_cb)
+ if (request->recv_cb) {
+ request->in_recv = 1;
request->recv_cb(receive->pid, handle, receive->packet, request->data);
+ request->in_recv = 0;
+ }
destroy_request_ctx(request);
break;
struct dlist *l;
struct dlist *n;
pid_t pid = (pid_t)-1;
+ int referred = 0;
receive = find_recv_ctx(handle);
- if (receive) {
+ if (receive)
pid = receive->pid;
- destroy_recv_ctx(receive);
- }
DbgPrint("Clean up all requests and a receive context for handle(%d) for pid(%d)\n", handle, pid);
if (request->handle != handle)
continue;
+ if (request->in_recv) {
+ referred = 1;
+ continue;
+ }
+
if (request->recv_cb)
request->recv_cb(pid, handle, NULL, request->data);
destroy_request_ctx(request);
}
+ if (receive && !referred)
+ destroy_recv_ctx(receive);
+
return 0;
}