-
Notifications
You must be signed in to change notification settings - Fork 6
Jg cs 1735 branch #71
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -29,7 +29,7 @@ | |||||||||||||||||||||||
| * | ||||||||||||||||||||||||
| * Portions of this software are Copyright (c) 2011 Univa Corporation. | ||||||||||||||||||||||||
| * | ||||||||||||||||||||||||
| * Portions of this software are Copyright (c) 2023-2025 HPC-Gridware GmbH | ||||||||||||||||||||||||
| * Portions of this software are Copyright (c) 2024-2025 HPC-Gridware GmbH | ||||||||||||||||||||||||
| * | ||||||||||||||||||||||||
| ************************************************************************/ | ||||||||||||||||||||||||
| /*___INFO__MARK_END__*/ | ||||||||||||||||||||||||
|
|
@@ -65,7 +65,6 @@ | |||||||||||||||||||||||
| #include "sge_ijs_comm.h" | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| extern sig_atomic_t received_signal; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /* | ||||||||||||||||||||||||
| * TODO: Cleanup / Headers | ||||||||||||||||||||||||
| * This is just slightly modified copy of the gdi commlib error handling, | ||||||||||||||||||||||||
|
|
@@ -309,6 +308,7 @@ int my_log_list_flush_list(cl_raw_list_t* list_p) { | |||||||||||||||||||||||
| * | ||||||||||||||||||||||||
| * INPUTS | ||||||||||||||||||||||||
| * dstring *err_msg - Gets the error reason in case of error. | ||||||||||||||||||||||||
| * cl_log_func_t - a commlib logging function which will print CL_LOG messages | ||||||||||||||||||||||||
| * | ||||||||||||||||||||||||
| * RESULT | ||||||||||||||||||||||||
| * int - COMM_RETVAL_OK: | ||||||||||||||||||||||||
|
|
@@ -324,19 +324,20 @@ int my_log_list_flush_list(cl_raw_list_t* list_p) { | |||||||||||||||||||||||
| * SEE ALSO | ||||||||||||||||||||||||
| * communication/comm_cleanup_lib() | ||||||||||||||||||||||||
| *******************************************************************************/ | ||||||||||||||||||||||||
| int comm_init_lib(dstring *err_msg) | ||||||||||||||||||||||||
| int comm_init_lib(dstring *err_msg, cl_log_func_t commlib_log_func) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| int ret, ret_val = COMM_RETVAL_OK; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| DENTER(TOP_LAYER); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /* | ||||||||||||||||||||||||
| * To enable commlib logging to a file (see my_log_list_flush_list() | ||||||||||||||||||||||||
| * for the file path), exchange this line with the one below. | ||||||||||||||||||||||||
| * Caution: On some architectures, logging causes problems! | ||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||
| /*ret = cl_com_setup_commlib(CL_RW_THREAD, CL_LOG_DEBUG, my_log_list_flush_list);*/ | ||||||||||||||||||||||||
| ret = cl_com_setup_commlib(CL_RW_THREAD, CL_LOG_OFF, nullptr); | ||||||||||||||||||||||||
| // When we pass a logging function to see commlib logging | ||||||||||||||||||||||||
| // (in sge_shepherd, when compiled with EXTENSIVE_TRACING) | ||||||||||||||||||||||||
| // we want to see INFO logging. | ||||||||||||||||||||||||
| cl_log_type debug_level = CL_LOG_OFF; | ||||||||||||||||||||||||
| if (commlib_log_func != nullptr) { | ||||||||||||||||||||||||
| debug_level = CL_LOG_INFO; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| ret = cl_com_setup_commlib(CL_RW_THREAD, debug_level, commlib_log_func); | ||||||||||||||||||||||||
| if (ret != CL_RETVAL_OK) { | ||||||||||||||||||||||||
| sge_dstring_sprintf(err_msg, cl_get_error_text(ret)); | ||||||||||||||||||||||||
| DPRINTF("cl_com_setup_commlib() failed: %s (%d)\n", sge_dstring_get_string(err_msg), ret); | ||||||||||||||||||||||||
|
|
@@ -768,9 +769,9 @@ int comm_ignore_timeouts(bool b_ignore, dstring *err_msg) | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| cl_com_ignore_timeouts(b_ignore); | ||||||||||||||||||||||||
| if (ret != CL_RETVAL_OK) { | ||||||||||||||||||||||||
| sge_dstring_sprintf(err_msg, cl_get_error_text(ret)); | ||||||||||||||||||||||||
| DPRINTF("cl_com_ignore_timeouts() failed: %s (%d)\n", sge_dstring_get_string(err_msg), ret); | ||||||||||||||||||||||||
| ret_val = COMM_CANT_SET_IGNORE_TIMEOUTS; | ||||||||||||||||||||||||
| sge_dstring_sprintf(err_msg, cl_get_error_text(ret)); | ||||||||||||||||||||||||
| DPRINTF("cl_com_ignore_timeouts() failed: %s (%d)\n", sge_dstring_get_string(err_msg), ret); | ||||||||||||||||||||||||
| ret_val = COMM_CANT_SET_IGNORE_TIMEOUTS; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| DRETURN(ret_val); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
@@ -1223,40 +1224,44 @@ unsigned long comm_write_message(COMM_HANDLE *handle, | |||||||||||||||||||||||
| *******************************************************************************/ | ||||||||||||||||||||||||
| int comm_flush_write_messages(COMM_HANDLE *handle, dstring *err_msg) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| unsigned long elems = 0; | ||||||||||||||||||||||||
| int ret = 0, retries = 0; | ||||||||||||||||||||||||
| int retries = 0; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| elems = cl_com_messages_in_send_queue(handle); | ||||||||||||||||||||||||
| unsigned long elems = cl_com_messages_in_send_queue(handle); | ||||||||||||||||||||||||
| while (elems > 0) { | ||||||||||||||||||||||||
| /* | ||||||||||||||||||||||||
| * Don't set the cl_commlib_trigger()-call to be blocking and | ||||||||||||||||||||||||
| * get rid of the usleep() - it's much slower! | ||||||||||||||||||||||||
| * The last cl_commlib_trigger()-call will take 1 s. | ||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||
| ret = cl_commlib_trigger(handle, 0); | ||||||||||||||||||||||||
| int trigger_ret = cl_commlib_trigger(handle, 0); | ||||||||||||||||||||||||
| /* | ||||||||||||||||||||||||
| * Bail out if trigger fails with an error that indicates that we | ||||||||||||||||||||||||
| * won't be able to send the messages in the near future. | ||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||
| if (ret != CL_RETVAL_OK && | ||||||||||||||||||||||||
| ret != CL_RETVAL_SELECT_TIMEOUT && | ||||||||||||||||||||||||
| ret != CL_RETVAL_SELECT_INTERRUPT) { | ||||||||||||||||||||||||
| sge_dstring_sprintf(err_msg, cl_get_error_text(ret)); | ||||||||||||||||||||||||
| retries = ret; | ||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||
| if (trigger_ret != CL_RETVAL_OK && | ||||||||||||||||||||||||
| trigger_ret != CL_RETVAL_SELECT_TIMEOUT && | ||||||||||||||||||||||||
| trigger_ret != CL_RETVAL_SELECT_INTERRUPT && | ||||||||||||||||||||||||
| trigger_ret != CL_RETVAL_THREADS_ENABLED) { | ||||||||||||||||||||||||
| sge_dstring_sprintf(err_msg, cl_get_error_text(trigger_ret)); | ||||||||||||||||||||||||
| sge_dstring_sprintf_append(err_msg, " - after %d retries", retries); | ||||||||||||||||||||||||
| return trigger_ret; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| elems = cl_com_messages_in_send_queue(handle); | ||||||||||||||||||||||||
| /* | ||||||||||||||||||||||||
| * We just tried to send the messages and it wasn't possible to send | ||||||||||||||||||||||||
| * all messages - give the network some time to recover. | ||||||||||||||||||||||||
| * @todo CS-1739 cl_commlib_trigger() does *not* wait until all messages are sent! | ||||||||||||||||||||||||
| * @todo Shall we have a maximum number of retries? A timeout? | ||||||||||||||||||||||||
| * But if the qrsh client is suspended, we probably need to wait until it is unsuspended again. | ||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||
| /* TODO (NEW): make this work correctly by calling check_client_alive */ | ||||||||||||||||||||||||
| if (elems > 0) { | ||||||||||||||||||||||||
| usleep(10000); | ||||||||||||||||||||||||
| retries--; | ||||||||||||||||||||||||
| retries++; | ||||||||||||||||||||||||
|
Comment on lines
+1227
to
+1261
|
||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| return retries; | ||||||||||||||||||||||||
| return -retries; | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
| return -retries; | |
| return 0; |
Copilot
AI
Jan 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter b_synchron is now being passed to cl_commlib_receive_message() where previously 'false' was hardcoded. While this change makes the function respect the synchronous/asynchronous mode as intended, this is a significant behavioral change that could affect existing callers. The change appears intentional and correct based on the parameter name, but verify that all call sites expect this new behavior, especially when b_synchron is true.
Copilot
AI
Jan 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A TODO comment references CS-1739, but the related code is disabled with #if 0. The comment questions whether cl_commlib_trigger() is needed when using multi-threaded commlib. If this is a legitimate concern that needs investigation, consider creating a tracking issue or resolving it before merging. Leaving disabled code with unresolved questions reduces code maintainability and makes it unclear whether this code path should be removed or fixed.
| // @todo CS-1739 do we need the cl_commlib_trigger, when we are using multi-threaded commlib? | |
| // if b_synchron is 0, then it does essentially nothing | |
| // otherwise it waits, until a message is available - the same which is done by cl_commlib_receive_message() | |
| // itself | |
| /* Intentionally call cl_commlib_trigger() here to drive commlib progress. | |
| * For asynchronous operation (b_synchron == 0) this is effectively a no-op, | |
| * while for synchronous operation it will block until a message is available, | |
| * matching the behavior expected by cl_commlib_receive_message() users. | |
| * This call is kept for consistency across single-threaded and multi-threaded | |
| * commlib implementations. | |
| */ |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -30,7 +30,7 @@ | |||||
| * | ||||||
| * Portions of this code are Copyright 2011 Univa Inc. | ||||||
| * | ||||||
| * Portions of this software are Copyright (c) 2023-2024 HPC-Gridware GmbH | ||||||
| * Portions of this software are Copyright (c) 2024-2025 HPC-Gridware GmbH | ||||||
| * | ||||||
| ************************************************************************/ | ||||||
| /*___INFO__MARK_END__*/ | ||||||
|
|
@@ -96,7 +96,7 @@ typedef struct recv_message_s { | |||||
| } recv_message_t; | ||||||
|
|
||||||
|
|
||||||
| int comm_init_lib(dstring *err_msg); | ||||||
| int comm_init_lib(dstring *err_msg, cl_log_func_t commlib_log_func = nullptr); | ||||||
|
||||||
| int comm_init_lib(dstring *err_msg, cl_log_func_t commlib_log_func = nullptr); | |
| int comm_init_lib(dstring *err_msg, cl_log_func_t commlib_log_func); |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -126,6 +126,41 @@ extern int received_signal; /* defined in shepherd.c */ | |||||||||||||||||||||||||||||||||||||||||||
| * SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||
| *******************************************************************************/ | ||||||||||||||||||||||||||||||||||||||||||||
| #ifdef EXTENSIVE_TRACING | ||||||||||||||||||||||||||||||||||||||||||||
| // This function will output commlib logging to the shepherd trace file | ||||||||||||||||||||||||||||||||||||||||||||
| // when EXTENSIVE_TRACING is enabled. | ||||||||||||||||||||||||||||||||||||||||||||
| static int | ||||||||||||||||||||||||||||||||||||||||||||
| shepherd_log_list_flush_list(cl_raw_list_t* list_p) { | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| if (list_p == nullptr) { | ||||||||||||||||||||||||||||||||||||||||||||
| return CL_RETVAL_LOG_NO_LOGLIST; | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| int ret_val; | ||||||||||||||||||||||||||||||||||||||||||||
| if ((ret_val = cl_raw_list_lock(list_p)) != CL_RETVAL_OK) { | ||||||||||||||||||||||||||||||||||||||||||||
| return ret_val; | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| // Log all entries of the log list via shepherd_trace(). | ||||||||||||||||||||||||||||||||||||||||||||
| cl_log_list_elem_t *elem = nullptr; | ||||||||||||||||||||||||||||||||||||||||||||
| while ((elem = cl_log_list_get_first_elem(list_p)) != nullptr) { | ||||||||||||||||||||||||||||||||||||||||||||
| if (elem->log_parameter == nullptr) { | ||||||||||||||||||||||||||||||||||||||||||||
| shepherd_trace("COMMLIB|%s|%s|%s", | ||||||||||||||||||||||||||||||||||||||||||||
| cl_thread_convert_state_id(elem->log_thread_state), | ||||||||||||||||||||||||||||||||||||||||||||
| cl_log_list_convert_type_id(elem->log_type), | ||||||||||||||||||||||||||||||||||||||||||||
| elem->log_message); | ||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||
| shepherd_trace("COMMLIB|%s|%s|%s %s", | ||||||||||||||||||||||||||||||||||||||||||||
| cl_thread_convert_state_id(elem->log_thread_state), | ||||||||||||||||||||||||||||||||||||||||||||
| cl_log_list_convert_type_id(elem->log_type), | ||||||||||||||||||||||||||||||||||||||||||||
| elem->log_message, elem->log_parameter); | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+146
to
+155
|
||||||||||||||||||||||||||||||||||||||||||||
| if (elem->log_parameter == nullptr) { | |
| shepherd_trace("COMMLIB|%s|%s|%s", | |
| cl_thread_convert_state_id(elem->log_thread_state), | |
| cl_log_list_convert_type_id(elem->log_type), | |
| elem->log_message); | |
| } else { | |
| shepherd_trace("COMMLIB|%s|%s|%s %s", | |
| cl_thread_convert_state_id(elem->log_thread_state), | |
| cl_log_list_convert_type_id(elem->log_type), | |
| elem->log_message, elem->log_parameter); | |
| const char *log_message = (elem->log_message != nullptr) ? elem->log_message : ""; | |
| if (elem->log_parameter == nullptr) { | |
| shepherd_trace("COMMLIB|%s|%s|%s", | |
| cl_thread_convert_state_id(elem->log_thread_state), | |
| cl_log_list_convert_type_id(elem->log_type), | |
| log_message); | |
| } else { | |
| shepherd_trace("COMMLIB|%s|%s|%s %s", | |
| cl_thread_convert_state_id(elem->log_thread_state), | |
| cl_log_list_convert_type_id(elem->log_type), | |
| log_message, elem->log_parameter); |
Copilot
AI
Jan 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The call to comm_flush_write_messages() now returns a value that is checked, but the handling logic appears incorrect. The function now returns negative values for the number of retries on success and positive values for error codes on failure. The condition 'if (flush_ret > 0)' correctly checks for errors, but the else-if condition checking 'flush_ret < 0' treats negative values as indicating retries. However, if flush_ret is 0 (zero retries), the code doesn't handle it, which means successful flushes with zero retries won't be logged even under EXTENSIVE_TRACING. Consider adding an explicit check for the success case (flush_ret == 0 or flush_ret <= 0) to ensure all cases are handled correctly.
| } else if (flush_ret < 0) { | |
| #ifdef EXTENSIVE_TRACING | |
| shepherd_trace("pty_to_commlib: comm_flush_write_messages() did %d retries", -flush_ret); | |
| #endif | |
| } | |
| } | |
| #ifdef EXTENSIVE_TRACING | |
| else { | |
| if (flush_ret < 0) { | |
| shepherd_trace("pty_to_commlib: comm_flush_write_messages() did %d retries", -flush_ret); | |
| } else { /* flush_ret == 0: success without retries */ | |
| shepherd_trace("pty_to_commlib: comm_flush_write_messages() completed without retries"); | |
| } | |
| } | |
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function documentation has been updated to mention the new cl_log_func_t parameter, but the description only says "a commlib logging function which will print CL_LOG messages" without explaining when/why a caller should provide this parameter, what happens if nullptr is passed, or what the expected signature and behavior of the logging function should be. This incomplete documentation makes it difficult for API consumers to understand how to use this parameter correctly.