Module: wine Branch: master Commit: 0345a578b560ffd427ee8b990cf01b8cfe08fd27 URL: http://source.winehq.org/git/wine.git/?a=commit;h=0345a578b560ffd427ee8b990c...
Author: Rob Shearman rob@codeweavers.com Date: Wed Nov 8 20:47:08 2006 +0000
rpcrt4: For TCP endpoints, bind to all the address and ports that getaddrinfo for the machine.
---
dlls/rpcrt4/rpc_transport.c | 41 +++++++++++++++++++++++++++++------------ 1 files changed, 29 insertions(+), 12 deletions(-)
diff --git a/dlls/rpcrt4/rpc_transport.c b/dlls/rpcrt4/rpc_transport.c index 66d2811..ac6c5c2 100644 --- a/dlls/rpcrt4/rpc_transport.c +++ b/dlls/rpcrt4/rpc_transport.c @@ -736,6 +736,7 @@ static RPC_STATUS rpcrt4_protseq_ncacn_i struct addrinfo *ai; struct addrinfo *ai_cur; struct addrinfo hints; + RpcConnection *first_connection = NULL;
TRACE("(%p, %s)\n", protseq, endpoint);
@@ -761,6 +762,8 @@ static RPC_STATUS rpcrt4_protseq_ncacn_i for (ai_cur = ai; ai_cur; ai_cur = ai_cur->ai_next) { RpcConnection_tcp *tcpc; + RPC_STATUS create_status; + if (TRACE_ON(rpc)) { char host[256]; @@ -790,20 +793,22 @@ static RPC_STATUS rpcrt4_protseq_ncacn_i status = RPC_S_CANT_CREATE_ENDPOINT; continue; } - status = RPCRT4_CreateConnection((RpcConnection **)&tcpc, TRUE, - protseq->Protseq, NULL, endpoint, NULL, - NULL, NULL); - if (status != RPC_S_OK) + create_status = RPCRT4_CreateConnection((RpcConnection **)&tcpc, TRUE, + protseq->Protseq, NULL, + endpoint, NULL, NULL, NULL); + if (create_status != RPC_S_OK) { close(sock); + status = create_status; continue; }
+ tcpc->sock = sock; ret = listen(sock, protseq->MaxCalls); if (ret < 0) { WARN("listen failed: %s\n", strerror(errno)); - close(sock); + RPCRT4_DestroyConnection(&tcpc->common); status = RPC_S_OUT_OF_RESOURCES; continue; } @@ -815,24 +820,36 @@ static RPC_STATUS rpcrt4_protseq_ncacn_i if (ret < 0) { WARN("couldn't make socket non-blocking, error %d\n", ret); - close(sock); + RPCRT4_DestroyConnection(&tcpc->common); status = RPC_S_OUT_OF_RESOURCES; continue; } - tcpc->sock = sock;
- freeaddrinfo(ai); + tcpc->common.Next = first_connection; + first_connection = &tcpc->common; + } + + freeaddrinfo(ai); + + /* if at least one connection was created for an endpoint then + * return success */ + if (first_connection) + { + RpcConnection *conn; + + /* find last element in list */ + for (conn = first_connection; conn->Next; conn = conn->Next) + ;
EnterCriticalSection(&protseq->cs); - tcpc->common.Next = protseq->conn; - protseq->conn = &tcpc->common; + conn->Next = protseq->conn; + protseq->conn = first_connection; LeaveCriticalSection(&protseq->cs); - + TRACE("listening on %s\n", endpoint); return RPC_S_OK; }
- freeaddrinfo(ai); ERR("couldn't listen on port %s\n", endpoint); return status; }