diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2009-03-20 16:40:09 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2009-03-20 16:40:09 +0100 |
commit | ca202cf464aec82e63be4b2160f394f56b8c195e (patch) | |
tree | 58b432b7d67c5cf3b35a16c7df9b028d39e3b3a5 /source3/libsmb/cliconnect.c | |
parent | 44787565715f0622cc1d049854427d735ca1c14b (diff) | |
parent | 2de464a7658f91d2d01087080b984d52c3483426 (diff) | |
download | samba-ca202cf464aec82e63be4b2160f394f56b8c195e.tar.gz samba-ca202cf464aec82e63be4b2160f394f56b8c195e.tar.bz2 samba-ca202cf464aec82e63be4b2160f394f56b8c195e.zip |
Merge branch 'master' of ssh://git.samba.org/data/git/samba into displaysec
Diffstat (limited to 'source3/libsmb/cliconnect.c')
-rw-r--r-- | source3/libsmb/cliconnect.c | 59 |
1 files changed, 37 insertions, 22 deletions
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index 43326e912c..ebb01c44a6 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -1785,15 +1785,20 @@ bool cli_session_request(struct cli_state *cli, return(True); } -static void smb_sock_connected(struct async_req *req) +struct fd_struct { + int fd; +}; + +static void smb_sock_connected(struct tevent_req *req) { - int *pfd = (int *)req->async.priv; + struct fd_struct *pfd = tevent_req_callback_data( + req, struct fd_struct); int fd; NTSTATUS status; status = open_socket_out_defer_recv(req, &fd); if (NT_STATUS_IS_OK(status)) { - *pfd = fd; + pfd->fd = fd; } } @@ -1801,10 +1806,9 @@ static NTSTATUS open_smb_socket(const struct sockaddr_storage *pss, uint16_t *port, int timeout, int *pfd) { struct event_context *ev; - struct async_req *r139, *r445; - int fd139 = -1; - int fd445 = -1; - NTSTATUS status; + struct tevent_req *r139, *r445; + struct fd_struct *fd139, *fd445; + NTSTATUS status = NT_STATUS_NO_MEMORY; if (*port != 0) { return open_socket_out(pss, *port, timeout, pfd); @@ -1815,43 +1819,54 @@ static NTSTATUS open_smb_socket(const struct sockaddr_storage *pss, return NT_STATUS_NO_MEMORY; } + fd139 = talloc(ev, struct fd_struct); + if (fd139 == NULL) { + goto done; + } + fd139->fd = -1; + + fd445 = talloc(ev, struct fd_struct); + if (fd445 == NULL) { + goto done; + } + fd445->fd = -1; + r445 = open_socket_out_defer_send(ev, ev, timeval_set(0, 0), pss, 445, timeout); r139 = open_socket_out_defer_send(ev, ev, timeval_set(0, 3000), pss, 139, timeout); if ((r445 == NULL) || (r139 == NULL)) { - status = NT_STATUS_NO_MEMORY; goto done; } - r445->async.fn = smb_sock_connected; - r445->async.priv = &fd445; - r139->async.fn = smb_sock_connected; - r139->async.priv = &fd139; + tevent_req_set_callback(r445, smb_sock_connected, fd445); + tevent_req_set_callback(r139, smb_sock_connected, fd139); - while ((fd139 == -1) && (r139->state < ASYNC_REQ_DONE) - && (fd445 == -1) && (r445->state < ASYNC_REQ_DONE)) { + while ((fd139->fd == -1) + && tevent_req_is_in_progress(r139) + && (fd445->fd == -1) + && tevent_req_is_in_progress(r445)) { event_loop_once(ev); } - if ((fd139 != -1) && (fd445 != -1)) { - close(fd139); - fd139 = -1; + if ((fd139->fd != -1) && (fd445->fd != -1)) { + close(fd139->fd); + fd139->fd = -1; } - if (fd445 != -1) { + if (fd445->fd != -1) { *port = 445; - *pfd = fd445; + *pfd = fd445->fd; status = NT_STATUS_OK; goto done; } - if (fd139 != -1) { + if (fd139->fd != -1) { *port = 139; - *pfd = fd139; + *pfd = fd139->fd; status = NT_STATUS_OK; goto done; } - status = open_socket_out_defer_recv(r445, &fd445); + status = open_socket_out_defer_recv(r445, &fd445->fd); done: TALLOC_FREE(ev); return status; |