summaryrefslogtreecommitdiff
path: root/source4/smbd
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2004-10-09 22:34:18 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:59:42 -0500
commit6ac94532bc3adc3473c9a6411a1e7d4cdcbed7f5 (patch)
treeb16de9dde35512d6f05a992dd0aff208c95ba6fa /source4/smbd
parentc4005997b9e286f8601a22ad853354a5ec2f9c66 (diff)
downloadsamba-6ac94532bc3adc3473c9a6411a1e7d4cdcbed7f5.tar.gz
samba-6ac94532bc3adc3473c9a6411a1e7d4cdcbed7f5.tar.bz2
samba-6ac94532bc3adc3473c9a6411a1e7d4cdcbed7f5.zip
r2882: fix mistake that caused a failure on a bind to a dynamic tcp port
metze (This used to be commit 9fb1b0e2d21e1724723360d062a4a64f185fc6e3)
Diffstat (limited to 'source4/smbd')
-rw-r--r--source4/smbd/service.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/source4/smbd/service.c b/source4/smbd/service.c
index 1f6033c238..5aae84b2c9 100644
--- a/source4/smbd/service.c
+++ b/source4/smbd/service.c
@@ -97,18 +97,7 @@ struct server_socket *service_setup_socket(struct server_service *service,
struct fd_event fde;
int i;
- if (*port == 0) {
- for (i=SERVER_TCP_LOW_PORT;i<= SERVER_TCP_HIGH_PORT;i++) {
- status = socket_create("ipv4", SOCKET_TYPE_STREAM, &socket_ctx, 0);
- if (NT_STATUS_IS_OK(status)) {
- *port = i;
- break;
- }
- }
- } else {
- status = socket_create("ipv4", SOCKET_TYPE_STREAM, &socket_ctx, 0);
- }
-
+ status = socket_create("ipv4", SOCKET_TYPE_STREAM, &socket_ctx, 0);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("Failed to open socket on %s:%u - %s\n",
sock_addr, *port, nt_errstr(status)));
@@ -135,7 +124,18 @@ struct server_socket *service_setup_socket(struct server_service *service,
/* TODO: set socket ACL's here when they're implemented */
- status = socket_listen(socket_ctx, sock_addr, *port, SERVER_LISTEN_BACKLOG, 0);
+ if (*port == 0) {
+ for (i=SERVER_TCP_LOW_PORT;i<= SERVER_TCP_HIGH_PORT;i++) {
+ status = socket_listen(socket_ctx, sock_addr, i, SERVER_LISTEN_BACKLOG, 0);
+ if (NT_STATUS_IS_OK(status)) {
+ *port = i;
+ break;
+ }
+ }
+ } else {
+ status = socket_listen(socket_ctx, sock_addr, *port, SERVER_LISTEN_BACKLOG, 0);
+ }
+
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("Failed to listen on %s:%u - %s\n",
sock_addr, *port, nt_errstr(status)));