summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/include/structs.h2
-rw-r--r--source4/libcli/wrepl/winsrepl.c43
2 files changed, 45 insertions, 0 deletions
diff --git a/source4/include/structs.h b/source4/include/structs.h
index 9d30e64dbc..ea90420753 100644
--- a/source4/include/structs.h
+++ b/source4/include/structs.h
@@ -298,3 +298,5 @@ struct ldb_map_objectclass;
struct param_context;
struct param_section;
struct param;
+
+struct socket_context;
diff --git a/source4/libcli/wrepl/winsrepl.c b/source4/libcli/wrepl/winsrepl.c
index aae77feb29..aba3fc817e 100644
--- a/source4/libcli/wrepl/winsrepl.c
+++ b/source4/libcli/wrepl/winsrepl.c
@@ -327,10 +327,53 @@ struct wrepl_socket *wrepl_socket_init(TALLOC_CTX *mem_ctx,
socket_get_fd(wrepl_socket->sock),
EVENT_FD_WRITE,
wrepl_connect_handler, wrepl_socket);
+ if (wrepl_socket->fde == NULL) {
+ goto failed;
+ }
set_blocking(socket_get_fd(wrepl_socket->sock), False);
talloc_set_destructor(wrepl_socket, wrepl_socket_destructor);
+
+ return wrepl_socket;
+
+failed:
+ talloc_free(wrepl_socket);
+ return NULL;
+}
+
+/*
+ initialise a wrepl_socket from an already existing connection
+*/
+struct wrepl_socket *wrepl_socket_merge(TALLOC_CTX *mem_ctx,
+ struct event_context *event_ctx,
+ struct socket_context *socket)
+{
+ struct wrepl_socket *wrepl_socket;
+
+ wrepl_socket = talloc(mem_ctx, struct wrepl_socket);
+ if (wrepl_socket == NULL) goto failed;
+
+ wrepl_socket->event_ctx = talloc_reference(wrepl_socket, event_ctx);
+ if (wrepl_socket->event_ctx == NULL) goto failed;
+
+ wrepl_socket->sock = socket;
+ talloc_steal(wrepl_socket, wrepl_socket->sock);
+
+ wrepl_socket->send_queue = NULL;
+ wrepl_socket->recv_queue = NULL;
+ wrepl_socket->request_timeout = WREPL_SOCKET_REQUEST_TIMEOUT;
+ wrepl_socket->dead = False;
+
+ wrepl_socket->fde = event_add_fd(wrepl_socket->event_ctx, wrepl_socket,
+ socket_get_fd(wrepl_socket->sock),
+ 0,
+ wrepl_handler, wrepl_socket);
+ if (wrepl_socket->fde == NULL) {
+ goto failed;
+ }
+
+ talloc_set_destructor(wrepl_socket, wrepl_socket_destructor);
return wrepl_socket;