summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2010-09-28 02:33:23 +0200
committerStefan Metzmacher <metze@samba.org>2010-09-28 03:48:10 +0200
commitd6c48b4a5fb667b0fba91af5d9113209ae72eede (patch)
tree238d94c69873b6e8241b9efad1abc5c0600e2665 /source4
parent9d8b886b3e631e073b12c559948f53bdbba87339 (diff)
downloadsamba-d6c48b4a5fb667b0fba91af5d9113209ae72eede.tar.gz
s4:wrepl_server: use SOCKET_FLAG_NOCLOSE instead of a dup()
The key thing is that we might have to turn the incomming connection into a outgoing connection. This change makes sense anyway, because we donate the fd to tstream. metze
Diffstat (limited to 'source4')
-rw-r--r--source4/wrepl_server/wrepl_in_connection.c21
1 files changed, 3 insertions, 18 deletions
diff --git a/source4/wrepl_server/wrepl_in_connection.c b/source4/wrepl_server/wrepl_in_connection.c
index 5fd24351104..a32b842e04a 100644
--- a/source4/wrepl_server/wrepl_in_connection.c
+++ b/source4/wrepl_server/wrepl_in_connection.c
@@ -104,7 +104,7 @@ static void wreplsrv_accept(struct stream_connection *conn)
struct tsocket_address *peer_addr;
char *peer_ip;
struct tevent_req *subreq;
- int rc, fd;
+ int rc;
wrepl_conn = talloc_zero(conn, struct wreplsrv_in_connection);
if (wrepl_conn == NULL) {
@@ -122,30 +122,15 @@ static void wreplsrv_accept(struct stream_connection *conn)
TALLOC_FREE(conn->event.fde);
- /*
- * Clone the fd that the connection isn't closed if we create a client
- * connection.
- */
- fd = dup(socket_get_fd(conn->socket));
- if (fd == -1) {
- char *reason;
-
- reason = talloc_asprintf(conn,
- "wrepl_accept: failed to duplicate the file descriptor - %s",
- strerror(errno));
- if (reason == NULL) {
- reason = strerror(errno);
- }
- stream_terminate_connection(conn, reason);
- }
rc = tstream_bsd_existing_socket(wrepl_conn,
- fd,
+ socket_get_fd(conn->socket),
&wrepl_conn->tstream);
if (rc < 0) {
stream_terminate_connection(conn,
"wrepl_accept: out of memory");
return;
}
+ socket_set_flags(conn->socket, SOCKET_FLAG_NOCLOSE);
wrepl_conn->conn = conn;
wrepl_conn->service = service;