summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-01-16 01:21:18 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:08:51 -0500
commit8ea26bf2fdad4440d65b020943e19128c34c4ed9 (patch)
treea8f95576fa986e0eb066279471801f4f4e0b931d /source4
parentb5d73bb5c55a8bfb924969ade61c9a513e2558cb (diff)
downloadsamba-8ea26bf2fdad4440d65b020943e19128c34c4ed9.tar.gz
samba-8ea26bf2fdad4440d65b020943e19128c34c4ed9.tar.bz2
samba-8ea26bf2fdad4440d65b020943e19128c34c4ed9.zip
r4765: simplify the async socket code to always go via the event handler
rather than short-circuiting in the unlikely event the OS returns an immediate success on a non-blocking connect (This used to be commit db4380717041485e216f965103f9e803518b45c3)
Diffstat (limited to 'source4')
-rw-r--r--source4/libcli/raw/clisocket.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/source4/libcli/raw/clisocket.c b/source4/libcli/raw/clisocket.c
index d20dc4bf25..851cf67caa 100644
--- a/source4/libcli/raw/clisocket.c
+++ b/source4/libcli/raw/clisocket.c
@@ -85,17 +85,11 @@ static void smbcli_sock_connect_handler(struct event_context *ev, struct fd_even
c->status = smbcli_sock_connect_one(conn->sock,
conn->dest_host,
conn->iports[i]);
- if (NT_STATUS_EQUAL(c->status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
+ if (NT_STATUS_IS_OK(c->status) ||
+ NT_STATUS_EQUAL(c->status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
conn->sock->event.fde->private = c;
return;
}
- if (NT_STATUS_IS_OK(c->status)) {
- c->state = SMBCLI_REQUEST_DONE;
- if (c->async.fn) {
- c->async.fn(c);
- }
- return;
- }
}
c->state = SMBCLI_REQUEST_ERROR;
@@ -153,7 +147,7 @@ static NTSTATUS smbcli_sock_connect_one(struct smbcli_socket *sock,
this is the async send side of the interface
*/
struct smbcli_composite *smbcli_sock_connect_send(struct smbcli_socket *sock,
- struct ipv4_addr *ip, int port)
+ const char *host_addr, int port)
{
struct smbcli_composite *c;
struct clisocket_connect *conn;
@@ -186,7 +180,7 @@ struct smbcli_composite *smbcli_sock_connect_send(struct smbcli_socket *sock,
conn->iports[1] = 0;
}
- conn->dest_host = talloc_strdup(c, sys_inet_ntoa(*ip));
+ conn->dest_host = talloc_strdup(c, host_addr);
if (conn->dest_host == NULL) goto failed;
c->private = conn;
@@ -200,14 +194,11 @@ struct smbcli_composite *smbcli_sock_connect_send(struct smbcli_socket *sock,
c->status = smbcli_sock_connect_one(sock,
conn->dest_host,
conn->iports[i]);
- if (NT_STATUS_EQUAL(c->status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
+ if (NT_STATUS_IS_OK(c->status) ||
+ NT_STATUS_EQUAL(c->status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
sock->event.fde->private = c;
return c;
}
- if (NT_STATUS_IS_OK(c->status)) {
- c->state = SMBCLI_REQUEST_DONE;
- return c;
- }
}
c->state = SMBCLI_REQUEST_ERROR;
@@ -235,11 +226,11 @@ NTSTATUS smbcli_sock_connect_recv(struct smbcli_composite *c)
sync version of the function
*/
-NTSTATUS smbcli_sock_connect(struct smbcli_socket *sock, struct ipv4_addr *ip, int port)
+NTSTATUS smbcli_sock_connect(struct smbcli_socket *sock, const char *host_addr, int port)
{
struct smbcli_composite *c;
- c = smbcli_sock_connect_send(sock, ip, port);
+ c = smbcli_sock_connect_send(sock, host_addr, port);
if (c == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -339,7 +330,7 @@ BOOL smbcli_sock_connect_byname(struct smbcli_socket *sock, const char *host, in
sock->hostname = name;
- status = smbcli_sock_connect(sock, &ip, port);
+ status = smbcli_sock_connect(sock, sys_inet_ntoa(ip), port);
return NT_STATUS_IS_OK(status);
}