summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-03-08 09:34:35 +0100
committerVolker Lendecke <vl@samba.org>2009-03-08 11:20:59 +0100
commitf5ee31602c7880b11dff82258764eb9a76cdc83b (patch)
tree97d3ca0ec51e8e7e294c2527c833465748a10a6b
parentfe486d7b9f580a17d23dd57582087c7d28cb738d (diff)
downloadsamba-f5ee31602c7880b11dff82258764eb9a76cdc83b.tar.gz
samba-f5ee31602c7880b11dff82258764eb9a76cdc83b.tar.bz2
samba-f5ee31602c7880b11dff82258764eb9a76cdc83b.zip
Add tevent_req wbc helpers
-rw-r--r--source3/include/wbc_async.h3
-rw-r--r--source3/lib/wb_reqtrans.c37
2 files changed, 40 insertions, 0 deletions
diff --git a/source3/include/wbc_async.h b/source3/include/wbc_async.h
index 7a8768029a..0ae6c695f0 100644
--- a/source3/include/wbc_async.h
+++ b/source3/include/wbc_async.h
@@ -40,6 +40,9 @@ bool async_req_is_wbcerr(struct async_req *req, wbcErr *pwbc_err);
wbcErr map_wbc_err_from_errno(int error);
wbcErr async_req_simple_recv_wbcerr(struct async_req *req);
+bool tevent_req_is_wbcerr(struct tevent_req *req, wbcErr *pwbc_err);
+wbcErr tevent_req_simple_recv_wbcerr(struct tevent_req *req);
+
struct async_req *wb_req_read_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
int fd, size_t max_extra_data);
diff --git a/source3/lib/wb_reqtrans.c b/source3/lib/wb_reqtrans.c
index 26dfb783ab..2051696a02 100644
--- a/source3/lib/wb_reqtrans.c
+++ b/source3/lib/wb_reqtrans.c
@@ -81,6 +81,43 @@ wbcErr async_req_simple_recv_wbcerr(struct async_req *req)
return WBC_ERR_SUCCESS;
}
+bool tevent_req_is_wbcerr(struct tevent_req *req, wbcErr *pwbc_err)
+{
+ enum tevent_req_state state;
+ uint64_t error;
+ if (!tevent_req_is_error(req, &state, &error)) {
+ *pwbc_err = WBC_ERR_SUCCESS;
+ return false;
+ }
+
+ switch (state) {
+ case TEVENT_REQ_USER_ERROR:
+ *pwbc_err = error;
+ break;
+ case TEVENT_REQ_TIMED_OUT:
+ *pwbc_err = WBC_ERR_UNKNOWN_FAILURE;
+ break;
+ case TEVENT_REQ_NO_MEMORY:
+ *pwbc_err = WBC_ERR_NO_MEMORY;
+ break;
+ default:
+ *pwbc_err = WBC_ERR_UNKNOWN_FAILURE;
+ break;
+ }
+ return true;
+}
+
+wbcErr tevent_req_simple_recv_wbcerr(struct tevent_req *req)
+{
+ wbcErr wbc_err;
+
+ if (tevent_req_is_wbcerr(req, &wbc_err)) {
+ return wbc_err;
+ }
+
+ return WBC_ERR_SUCCESS;
+}
+
static ssize_t wb_req_more(uint8_t *buf, size_t buflen, void *private_data);
static void wb_req_read_done(struct tevent_req *subreq);