summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-05-06 15:10:00 +0200
committerVolker Lendecke <vl@samba.org>2009-05-07 22:52:33 +0200
commitb475a1e7ebfcc1e1e11800bf93893eae11966d05 (patch)
tree4e9abc90cfa71c7dc1e7ca94810aa36606640a87 /source3
parent6f320d0208be9e460af1bd10c0e42e78e17d53dc (diff)
downloadsamba-b475a1e7ebfcc1e1e11800bf93893eae11966d05.tar.gz
samba-b475a1e7ebfcc1e1e11800bf93893eae11966d05.tar.bz2
samba-b475a1e7ebfcc1e1e11800bf93893eae11966d05.zip
Convert lib/wb_reqtrans.c to unix calling conventions
Diffstat (limited to 'source3')
-rw-r--r--source3/include/wbc_async.h12
-rw-r--r--source3/lib/wb_reqtrans.c129
-rw-r--r--source3/lib/wbclient.c69
3 files changed, 113 insertions, 97 deletions
diff --git a/source3/include/wbc_async.h b/source3/include/wbc_async.h
index eaec0d11da..57b0cb83ab 100644
--- a/source3/include/wbc_async.h
+++ b/source3/include/wbc_async.h
@@ -41,24 +41,24 @@ wbcErr tevent_req_simple_recv_wbcerr(struct tevent_req *req);
struct tevent_req *wb_req_read_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
int fd, size_t max_extra_data);
-wbcErr wb_req_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
- struct winbindd_request **preq);
+ssize_t wb_req_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
+ struct winbindd_request **preq, int *err);
struct tevent_req *wb_req_write_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct tevent_queue *queue, int fd,
struct winbindd_request *wb_req);
-wbcErr wb_req_write_recv(struct tevent_req *req);
+ssize_t wb_req_write_recv(struct tevent_req *req, int *err);
struct tevent_req *wb_resp_read_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev, int fd);
-wbcErr wb_resp_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
- struct winbindd_response **presp);
+ssize_t wb_resp_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
+ struct winbindd_response **presp, int *err);
struct tevent_req *wb_resp_write_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct tevent_queue *queue, int fd,
struct winbindd_response *wb_resp);
-wbcErr wb_resp_write_recv(struct tevent_req *req);
+ssize_t wb_resp_write_recv(struct tevent_req *req, int *err);
#endif /*_WBC_ASYNC_H_*/
diff --git a/source3/lib/wb_reqtrans.c b/source3/lib/wb_reqtrans.c
index b64efecef3..d7ec17b58b 100644
--- a/source3/lib/wb_reqtrans.c
+++ b/source3/lib/wb_reqtrans.c
@@ -25,60 +25,10 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_WINBIND
-wbcErr map_wbc_err_from_errno(int error)
-{
- switch(error) {
- case EPERM:
- case EACCES:
- return WBC_ERR_AUTH_ERROR;
- case ENOMEM:
- return WBC_ERR_NO_MEMORY;
- case EIO:
- default:
- return WBC_ERR_UNKNOWN_FAILURE;
- }
-}
-
-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;
-}
-
struct req_read_state {
struct winbindd_request *wb_req;
size_t max_extra_data;
+ ssize_t ret;
};
static ssize_t wb_req_more(uint8_t *buf, size_t buflen, void *private_data);
@@ -139,13 +89,12 @@ static void wb_req_read_done(struct tevent_req *subreq)
struct req_read_state *state = tevent_req_data(
req, struct req_read_state);
int err;
- ssize_t ret;
uint8_t *buf;
- ret = read_packet_recv(subreq, state, &buf, &err);
+ state->ret = read_packet_recv(subreq, state, &buf, &err);
TALLOC_FREE(subreq);
- if (ret == -1) {
- tevent_req_error(req, map_wbc_err_from_errno(err));
+ if (state->ret == -1) {
+ tevent_req_error(req, err);
return;
}
@@ -160,22 +109,22 @@ static void wb_req_read_done(struct tevent_req *subreq)
tevent_req_done(req);
}
-wbcErr wb_req_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
- struct winbindd_request **preq)
+ssize_t wb_req_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
+ struct winbindd_request **preq, int *err)
{
struct req_read_state *state = tevent_req_data(
req, struct req_read_state);
- wbcErr wbc_err;
- if (tevent_req_is_wbcerr(req, &wbc_err)) {
- return wbc_err;
+ if (tevent_req_is_unix_error(req, err)) {
+ return -1;
}
*preq = talloc_move(mem_ctx, &state->wb_req);
- return WBC_ERR_SUCCESS;
+ return state->ret;
}
struct req_write_state {
struct iovec iov[2];
+ ssize_t ret;
};
static void wb_req_write_done(struct tevent_req *subreq);
@@ -215,25 +164,33 @@ static void wb_req_write_done(struct tevent_req *subreq)
{
struct tevent_req *req = tevent_req_callback_data(
subreq, struct tevent_req);
+ struct req_write_state *state = tevent_req_data(
+ req, struct req_write_state);
int err;
- ssize_t ret;
- ret = writev_recv(subreq, &err);
+ state->ret = writev_recv(subreq, &err);
TALLOC_FREE(subreq);
- if (ret < 0) {
- tevent_req_error(req, map_wbc_err_from_errno(err));
+ if (state->ret < 0) {
+ tevent_req_error(req, err);
return;
}
tevent_req_done(req);
}
-wbcErr wb_req_write_recv(struct tevent_req *req)
+ssize_t wb_req_write_recv(struct tevent_req *req, int *err)
{
- return tevent_req_simple_recv_wbcerr(req);
+ struct req_write_state *state = tevent_req_data(
+ req, struct req_write_state);
+
+ if (tevent_req_is_unix_error(req, err)) {
+ return -1;
+ }
+ return state->ret;
}
struct resp_read_state {
struct winbindd_response *wb_resp;
+ ssize_t ret;
};
static ssize_t wb_resp_more(uint8_t *buf, size_t buflen, void *private_data);
@@ -282,12 +239,11 @@ static void wb_resp_read_done(struct tevent_req *subreq)
req, struct resp_read_state);
uint8_t *buf;
int err;
- ssize_t ret;
- ret = read_packet_recv(subreq, state, &buf, &err);
+ state->ret = read_packet_recv(subreq, state, &buf, &err);
TALLOC_FREE(subreq);
- if (ret == -1) {
- tevent_req_error(req, map_wbc_err_from_errno(err));
+ if (state->ret == -1) {
+ tevent_req_error(req, err);
return;
}
@@ -302,22 +258,22 @@ static void wb_resp_read_done(struct tevent_req *subreq)
tevent_req_done(req);
}
-wbcErr wb_resp_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
- struct winbindd_response **presp)
+ssize_t wb_resp_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
+ struct winbindd_response **presp, int *err)
{
struct resp_read_state *state = tevent_req_data(
req, struct resp_read_state);
- wbcErr wbc_err;
- if (tevent_req_is_wbcerr(req, &wbc_err)) {
- return wbc_err;
+ if (tevent_req_is_unix_error(req, err)) {
+ return -1;
}
*presp = talloc_move(mem_ctx, &state->wb_resp);
- return WBC_ERR_SUCCESS;
+ return state->ret;
}
struct resp_write_state {
struct iovec iov[2];
+ ssize_t ret;
};
static void wb_resp_write_done(struct tevent_req *subreq);
@@ -358,19 +314,26 @@ static void wb_resp_write_done(struct tevent_req *subreq)
{
struct tevent_req *req = tevent_req_callback_data(
subreq, struct tevent_req);
+ struct resp_write_state *state = tevent_req_data(
+ req, struct resp_write_state);
int err;
- ssize_t ret;
- ret = writev_recv(subreq, &err);
+ state->ret = writev_recv(subreq, &err);
TALLOC_FREE(subreq);
- if (ret < 0) {
- tevent_req_error(req, map_wbc_err_from_errno(err));
+ if (state->ret < 0) {
+ tevent_req_error(req, err);
return;
}
tevent_req_done(req);
}
-wbcErr wb_resp_write_recv(struct tevent_req *req)
+ssize_t wb_resp_write_recv(struct tevent_req *req, int *err)
{
- return tevent_req_simple_recv_wbcerr(req);
+ struct resp_write_state *state = tevent_req_data(
+ req, struct resp_write_state);
+
+ if (tevent_req_is_unix_error(req, err)) {
+ return -1;
+ }
+ return state->ret;
}
diff --git a/source3/lib/wbclient.c b/source3/lib/wbclient.c
index c22e168454..abe5b50c43 100644
--- a/source3/lib/wbclient.c
+++ b/source3/lib/wbclient.c
@@ -20,6 +20,57 @@
#include "includes.h"
#include "wbc_async.h"
+wbcErr map_wbc_err_from_errno(int error)
+{
+ switch(error) {
+ case EPERM:
+ case EACCES:
+ return WBC_ERR_AUTH_ERROR;
+ case ENOMEM:
+ return WBC_ERR_NO_MEMORY;
+ case EIO:
+ default:
+ return WBC_ERR_UNKNOWN_FAILURE;
+ }
+}
+
+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;
+}
+
struct wb_context {
struct tevent_queue *queue;
int fd;
@@ -320,12 +371,13 @@ static void wb_int_trans_write_done(struct tevent_req *subreq)
subreq, struct tevent_req);
struct wb_int_trans_state *state = tevent_req_data(
req, struct wb_int_trans_state);
- wbcErr wbc_err;
+ ssize_t ret;
+ int err;
- wbc_err = wb_req_write_recv(subreq);
+ ret = wb_req_write_recv(subreq, &err);
TALLOC_FREE(subreq);
- if (!WBC_ERROR_IS_OK(wbc_err)) {
- tevent_req_error(req, wbc_err);
+ if (ret == -1) {
+ tevent_req_error(req, map_wbc_err_from_errno(err));
return;
}
@@ -342,12 +394,13 @@ static void wb_int_trans_read_done(struct tevent_req *subreq)
subreq, struct tevent_req);
struct wb_int_trans_state *state = tevent_req_data(
req, struct wb_int_trans_state);
- wbcErr wbc_err;
+ ssize_t ret;
+ int err;
- wbc_err = wb_resp_read_recv(subreq, state, &state->wb_resp);
+ ret = wb_resp_read_recv(subreq, state, &state->wb_resp, &err);
TALLOC_FREE(subreq);
- if (!WBC_ERROR_IS_OK(wbc_err)) {
- tevent_req_error(req, wbc_err);
+ if (ret == -1) {
+ tevent_req_error(req, map_wbc_err_from_errno(err));
return;
}