From 7718a89222549d3d38f58193374d7b5d6b0e79fa Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 4 Jul 2008 19:52:23 +0200 Subject: libcli/raw: add a recv_helper hook infrastructure The recv helper will be called when a response comes and the recv helper can decide to let the request on the SMBCLI_REQUEST_RECV when more reponse packets are expected. It's up to the helper function to keep a reference to the in buffers, each incoming response overwrites req->in. metze (This used to be commit 6d84af89ba96627abe142ba7080c24ae2421ed6c) --- source4/libcli/raw/clitransport.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'source4/libcli/raw/clitransport.c') diff --git a/source4/libcli/raw/clitransport.c b/source4/libcli/raw/clitransport.c index 34fb96230d..e95ae3271e 100644 --- a/source4/libcli/raw/clitransport.c +++ b/source4/libcli/raw/clitransport.c @@ -480,8 +480,22 @@ async: /* if this request has an async handler then call that to notify that the reply has been received. This might destroy the request so it must happen last */ - DLIST_REMOVE(transport->pending_recv, req); + req->state = SMBCLI_REQUEST_DONE; + + if (req->recv_helper.fn) { + /* + * let the recv helper decide in + * what state the request really is + */ + req->state = req->recv_helper.fn(req); + + /* if more parts are needed, wait for them */ + if (req->state <= SMBCLI_REQUEST_RECV) { + return NT_STATUS_OK; + } + } + DLIST_REMOVE(transport->pending_recv, req); if (req->async.fn) { req->async.fn(req); } -- cgit