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

[CBRD-24523] Fix invalid port number is passed to Java SP Server on Windows (#3906) #3907

Merged
merged 1 commit into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/base/system_parameter.c
Original file line number Diff line number Diff line change
Expand Up @@ -10824,7 +10824,6 @@ prm_tune_parameters (void)
ha_check_disk_failure_interval_prm = prm_find (PRM_NAME_HA_CHECK_DISK_FAILURE_INTERVAL_IN_SECS, NULL);
test_mode_prm = prm_find (PRM_NAME_TEST_MODE, NULL);
tz_leap_second_support_prm = prm_find (PRM_NAME_TZ_LEAP_SECOND_SUPPORT, NULL);
java_stored_procedure_uds_prm = prm_find (PRM_NAME_JAVA_STORED_PROCEDURE_UDS, NULL);

assert (max_plan_cache_entries_prm != NULL);
if (max_plan_cache_entries_prm == NULL)
Expand Down Expand Up @@ -10865,10 +10864,6 @@ prm_tune_parameters (void)
}
}

#if defined (WINDOWS)
(void) prm_set (java_stored_procedure_uds_prm, "no", false);
#endif

/* disable them temporarily */

if (ha_node_list_prm == NULL || PRM_DEFAULT_VAL_USED (*ha_node_list_prm->dynamic_flag))
Expand Down
31 changes: 17 additions & 14 deletions src/executables/javasp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ static int javasp_get_server_info (const std::string &db_name, JAVASP_SERVER_INF
static int javasp_check_argument (int argc, char *argv[], std::string &command, std::string &db_name);
static int javasp_check_database (const std::string &db_name, std::string &db_path);

static int javasp_get_port_param ();

/*
* main() - javasp main function
*/
Expand Down Expand Up @@ -280,6 +282,19 @@ main (int argc, char *argv[])
return status;
}

static int
javasp_get_port_param ()
{
int prm_port = 0;
#if defined (WINDOWS)
const bool is_uds_mode = false;
#else
const bool is_uds_mode = prm_get_bool_value (PRM_ID_JAVA_STORED_PROCEDURE_UDS);
#endif
prm_port = (is_uds_mode) ? JAVASP_PORT_UDS_MODE : prm_get_integer_value (PRM_ID_JAVA_STORED_PROCEDURE_PORT);
return prm_port;
}

static int
javasp_start_server (const JAVASP_SERVER_INFO jsp_info, const std::string &db_name, const std::string &path)
{
Expand All @@ -291,28 +306,16 @@ javasp_start_server (const JAVASP_SERVER_INFO jsp_info, const std::string &db_na
}
else
{
int prm_port = -1;
const bool is_uds_mode = prm_get_bool_value (PRM_ID_JAVA_STORED_PROCEDURE_UDS);
if (is_uds_mode)
{
prm_port = JAVASP_PORT_UDS_MODE;
}
else
{
prm_port = prm_get_integer_value (PRM_ID_JAVA_STORED_PROCEDURE_PORT);
}

#if !defined(WINDOWS)
/* create a new session */
setsid ();
#endif
er_clear (); // clear error before string JVM
status = jsp_start_server (db_name.c_str (), path.c_str (), prm_port);
status = jsp_start_server (db_name.c_str (), path.c_str (), javasp_get_port_param ());

if (status == NO_ERROR)
{
int port_number = prm_get_bool_value (PRM_ID_JAVA_STORED_PROCEDURE_UDS) ? JAVASP_PORT_UDS_MODE : jsp_server_port ();
JAVASP_SERVER_INFO jsp_new_info { getpid(), port_number };
JAVASP_SERVER_INFO jsp_new_info { getpid(), jsp_server_port () };

javasp_unlink_info (db_name.c_str ());
if ((javasp_open_info_dir () && javasp_write_info (db_name.c_str (), jsp_new_info)))
Expand Down