Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JBTM-1565 - Use a random port for socketserver and txn_cfg when port 0 i... #387

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion blacktie/btadmin/src/test/resources/btconfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
</SERVERS>
<ORB OPT="-ORBInitRef NameService=corbaloc::${JBOSSAS_IP_ADDR}:3528/NameService -ORBListenEndpoints iiop://${JBOSSAS_IP_ADDR}:0"
TRANS_FACTORY_ID="TransactionManagerService.OTS" />
<SOCKETSERVER PORT="12343" />
<SOCKETSERVER PORT="0" />
<MQ HOST="${JBOSSAS_IP_ADDR}" PORT="61613" USER="guest" PASSWORD="password1@"
RECEIVE_TIMEOUT="10" TIME_TO_LIVE="40"
/>
Expand Down
9 changes: 9 additions & 0 deletions blacktie/core/src/main/cpp/SocketServer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,15 @@ int SocketServer::run() {
return -1;
}

if(apr_socket_addr_get(&localsa, APR_LOCAL, sock) != APR_SUCCESS) {
apr_socket_close(sock);
LOG4CXX_WARN(loggerSocketServer, "could not get address");
apr_thread_cond_signal(this->startup_cond);
return -1;
};

port = localsa->port;

apr_pollset_create(&pollset, DEF_POLLSET_NUM, context, 0);
apr_pollfd_t pfd = { context, APR_POLL_SOCKET, APR_POLLIN, 0, { NULL }, NULL };
pfd.desc.s = sock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ public static synchronized void discardInstance() {

private SocketServer(int port, String addr) throws IOException {
this.shutdown = false;
this.port = port;
this.addr = addr;
serverSocket = new ServerSocket(port);
this.port = serverSocket.getLocalPort();
clients = new ArrayList<Client>();
threads = new ArrayList<Thread>();
contexts = new ArrayList<ClientContext>();
Expand Down
8 changes: 8 additions & 0 deletions blacktie/transport/src/main/cpp/HttpServer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ int HttpServer::run() {
return -1;
}

if(apr_socket_addr_get(&localsa, APR_LOCAL, sock) != APR_SUCCESS) {
apr_socket_close(sock);
LOG4CXX_WARN(loggerHttpServer, "could not get address");
return -1;
}

port = localsa->port;

apr_pollset_create(&pollset, DEF_POLLSET_NUM, pool, 0);
apr_pollfd_t pfd = { pool, APR_POLL_SOCKET, APR_POLLIN, 0, { NULL }, NULL };
pfd.desc.s = sock;
Expand Down