diff options
author | Stefan Metzmacher <metze@samba.org> | 2005-09-30 01:55:29 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:39:14 -0500 |
commit | bb77c2aa1e426dff40d8b7507bb562dcf9c779bd (patch) | |
tree | 061c568210cee0e0d008003f88b8d952dcb9a94a /source4 | |
parent | f1c52270785285fcf68e2b22fbc83cbee38910fd (diff) | |
download | samba-bb77c2aa1e426dff40d8b7507bb562dcf9c779bd.tar.gz samba-bb77c2aa1e426dff40d8b7507bb562dcf9c779bd.tar.bz2 samba-bb77c2aa1e426dff40d8b7507bb562dcf9c779bd.zip |
r10638: - add wrepl_socket_merge() function that creates a wrepl_socket on top
of an existing socket, that is needed to handle WREPL_REPL_UPDATE
in the server, because we need to flig the connection and act as client on it
metze
(This used to be commit 131e5dfe695d427e992b840439743f880b14d82d)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/include/structs.h | 2 | ||||
-rw-r--r-- | source4/libcli/wrepl/winsrepl.c | 43 |
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; |