diff --git a/src/common/slurm_protocol_api.c b/src/common/slurm_protocol_api.c index 632726b56f0550538ac1e0e2bf02a8bf3026b992..170493105bf574fc724d9ce92e97b72e279d86d3 100644 --- a/src/common/slurm_protocol_api.c +++ b/src/common/slurm_protocol_api.c @@ -90,15 +90,15 @@ int read_slurm_port_config ( ) slurm_spec_file = fopen (SLURM_CONFIG_FILE, "r"); if (slurm_spec_file == NULL) { - error ( "read_slurm_conf error %d opening file %s", + debug ( "read_slurm_conf error %d opening file %s", errno, SLURM_CONFIG_FILE); - exit (1); + return SLURM_ERROR ; } while (fgets (in_line, BUF_SIZE, slurm_spec_file) != NULL) { line_num++; if (strlen (in_line) >= (BUF_SIZE - 1)) { - error ("read_slurm_conf line %d, of input file %s too long\n", + debug ("read_slurm_conf line %d, of input file %s too long\n", line_num, SLURM_CONFIG_FILE); fclose (slurm_spec_file); return E2BIG; @@ -223,11 +223,13 @@ slurm_fd slurm_open_controller_conn ( ) /* try to send to primary first then secondary */ if ( ( connection_fd = slurm_open_msg_conn ( & proto_conf -> primary_controller ) ) == SLURM_SOCKET_ERROR ) { - error ( "Send message to primary controller failed" ) ; + int local_errno = errno ; + debug ( "Open connection to primary controller failed errno: %i", local_errno ) ; if ( ( connection_fd = slurm_open_msg_conn ( & proto_conf -> secondary_controller ) ) == SLURM_SOCKET_ERROR ) { - error ( "Send messge to secondary controller failed" ) ; + int local_errno = errno ; + debug ( "Open connection to secondary controller failed errno: %i", local_errno ) ; } } return connection_fd ; @@ -272,7 +274,8 @@ int slurm_receive_msg ( slurm_fd open_fd , slurm_msg_t * msg ) if ( ( rc = _slurm_msg_recvfrom ( open_fd , buffer , receive_len, SLURM_PROTOCOL_NO_SEND_RECV_FLAGS , & (msg)->address ) ) == SLURM_SOCKET_ERROR ) { - error ( "Error receiving msg socket: errno %i", errno ) ; + int local_errno = errno ; + debug ( "Error receiving msg socket: errno %i", errno ) ; return rc ; } @@ -306,11 +309,13 @@ int slurm_send_controller_msg ( slurm_fd open_fd , slurm_msg_t * msg ) msg -> address = proto_conf -> primary_controller ; if ( (rc = slurm_send_node_msg ( open_fd , msg ) ) == SLURM_SOCKET_ERROR ) { - error ( "Send message to primary controller failed" ) ; + int local_errno = errno ; + debug ( "Send message to primary controller failed errno: %i", local_errno ) ; msg -> address = proto_conf -> secondary_controller ; if ( (rc = slurm_send_node_msg ( open_fd , msg ) ) == SLURM_SOCKET_ERROR ) { - error ( "Send messge to secondary controller failed" ) ; + int local_errno = errno ; + debug ( "Send messge to secondary controller failed errno: %i", local_errno ) ; } } return rc ; @@ -343,7 +348,8 @@ int slurm_send_node_msg ( slurm_fd open_fd , slurm_msg_t * msg ) /* send msg */ if ( ( rc = _slurm_msg_sendto ( open_fd , buf_temp , SLURM_PROTOCOL_MAX_MESSAGE_BUFFER_SIZE - pack_len , SLURM_PROTOCOL_NO_SEND_RECV_FLAGS , &msg->address ) ) == SLURM_SOCKET_ERROR ) { - error ( "Error sending msg socket: errno %i", errno ) ; + int local_errno = errno ; + debug ( "Error sending msg socket: errno %i", local_errno ) ; } return rc ; } @@ -368,7 +374,8 @@ int slurm_receive_buffer ( slurm_fd open_fd , slurm_addr * source_address , slur if ( ( rc = _slurm_msg_recvfrom ( open_fd , buffer , receive_len, SLURM_PROTOCOL_NO_SEND_RECV_FLAGS , source_address ) ) == SLURM_SOCKET_ERROR ) ; { - error ( "Error receiving msg socket: errno %i", errno ) ; + int local_errno = errno ; + debug ( "Error receiving msg socket: errno %i", local_errno ) ; return rc ; } @@ -405,11 +412,13 @@ int slurm_send_controller_buffer ( slurm_fd open_fd , slurm_msg_type_t msg_type /* try to send to primary first then secondary */ if ( ( rc = slurm_send_node_buffer ( open_fd , & proto_conf -> primary_controller , msg_type , data_buffer , buf_len ) ) == SLURM_SOCKET_ERROR ) { - error ( "Send message to primary controller failed" ) ; - + + int local_errno = errno ; + debug ( "Send message to primary controller failed errno: %i", local_errno ) ; if ( ( rc = slurm_send_node_buffer ( open_fd , & proto_conf -> secondary_controller , msg_type , data_buffer , buf_len ) ) == SLURM_SOCKET_ERROR ) { - error ( "Send messge to secondary controller failed" ) ; + int local_errno = errno ; + debug ( "Send message to secondary controller failed errno: %i", local_errno ) ; } } return rc ; @@ -445,7 +454,8 @@ int slurm_send_node_buffer ( slurm_fd open_fd , slurm_addr * destination_address if ( ( rc = _slurm_msg_sendto ( open_fd , buf_temp , SLURM_PROTOCOL_MAX_MESSAGE_BUFFER_SIZE - pack_len , SLURM_PROTOCOL_NO_SEND_RECV_FLAGS , destination_address ) ) == SLURM_SOCKET_ERROR ) { - error ( "Error sending msg socket: errno %i", errno ) ; + int local_errno = errno ; + debug ( "Error sending msg socket: errno %i", local_errno ) ; } return rc ; } diff --git a/src/common/slurm_protocol_api.h b/src/common/slurm_protocol_api.h index c728d88569395f4b3ec3117f78f821dcf1240e8e..51c4e98d0929be2b016078bffdb850a2f64f99a7 100644 --- a/src/common/slurm_protocol_api.h +++ b/src/common/slurm_protocol_api.h @@ -37,6 +37,7 @@ int read_slurm_port_config ( ); /* slurm_set_api_config * sets the slurm_protocol_config object + * NOT THREAD SAFE * IN protocol_conf - slurm_protocol_config object */ int inline slurm_set_api_config ( slurm_protocol_config_t * protocol_conf ); @@ -55,6 +56,7 @@ int inline slurm_api_set_default_config ( ); /* slurm_set_default_controllers * sets the controller info members of the default slurm_protocol_config object + * NOT THREAD SAFE * IN primary_controller_hostname - primary controller hostname * IN secondary_controller_hostnme - secondary controller hostnme * IN pri_port - primary controller port @@ -258,6 +260,7 @@ void inline slurm_set_addr_uint ( slurm_addr * slurm_address , uint16_t port , u /* slurm_set_addr * initializes the slurm_address with the port and ip_addrss passed to it + * NOT THREAD SAFE * OUT slurm_address - slurm_addr to be filled in * IN port - port in host order * IN host - hostname or dns name @@ -266,6 +269,7 @@ void inline slurm_set_addr ( slurm_addr * slurm_address , uint16_t port , char * /* slurm_set_addr_any * initialized the slurm_address with the port passed to in on INADDR_ANY + * NOT THREAD SAFE * OUT slurm_address - slurm_addr to be filled in * IN port - port in host order */ @@ -281,6 +285,7 @@ void inline slurm_set_addr_char ( slurm_addr * slurm_address , uint16_t port , c /* slurm_get_addr * given a slurm_address it returns to port and hostname + * NOT THREAD SAFE * IN slurm_address - slurm_addr to be queried * OUT port - port number * OUT host - hostname diff --git a/src/common/slurm_protocol_errno.h b/src/common/slurm_protocol_errno.h index 35d63a4a3830f3ebda156de9050e6ec519e2485b..bed04ae81403a1961418604a1bd1cdbb19ec0e83 100644 --- a/src/common/slurm_protocol_errno.h +++ b/src/common/slurm_protocol_errno.h @@ -16,6 +16,7 @@ #define SLURM_COMMUNICATIONS_RECEIVE_ERROR -1903 #define SLURM_COMMUNICATIONS_SHUTDOWN_ERROR -1904 #define SLURM_PROTOCOL_VERSION_ERROR -1910 +#define SLURM_PROTOCOL_IO_STREAM_VERSION_ERROR -1911 /* _info.c/ocommuncation layer RESPONSE_SLURM_RC message codes */ #define SLURM_NO_CHANGE_IN_DATA -1920 @@ -54,6 +55,9 @@ /* step_mgr.c */ /* already defined above ESLURM_ACCESS_DENIED -2202 */ +#define SLURM_PROTOCOL_SOCKET_IMPL_ZERO_RECV_LENGTH -8000 +#define SLURM_PROTOCOL_SOCKET_IMPL_NEGATIVE_RECV_LENGTH -8001 +#define SLURM_PROTOCOL_SOCKET_IMPL_NOT_ALL_DATA_SENT -8002 /* look up an errno value */ extern char * slurm_strerror(int errnum); diff --git a/src/common/slurm_protocol_pack.c b/src/common/slurm_protocol_pack.c index 95ed35189f926e0fee4e8fe4d4a94aa12971cd4e..e7d8d74056a3cdaff57779809cc52673487f2985 100644 --- a/src/common/slurm_protocol_pack.c +++ b/src/common/slurm_protocol_pack.c @@ -221,7 +221,7 @@ int pack_msg ( slurm_msg_t const * msg , char ** buffer , uint32_t * buf_len ) pack_job_step_create_request_msg(( job_step_create_request_msg_t * ) msg -> data , ( void ** ) buffer , buf_len ) ; break; default : - error ( "No pack method for msg type %i", msg -> msg_type ) ; + debug ( "No pack method for msg type %i", msg -> msg_type ) ; return EINVAL ; break; @@ -366,7 +366,7 @@ int unpack_msg ( slurm_msg_t * msg , char ** buffer , uint32_t * buf_len ) unpack_job_step_create_request_msg(( job_step_create_request_msg_t ** ) &msg -> data , ( void ** ) buffer , buf_len ) ; break; default : - error ( "No pack method for msg type %i", msg -> msg_type ) ; + debug ( "No pack method for msg type %i", msg -> msg_type ) ; return EINVAL ; break; diff --git a/src/common/slurm_protocol_socket_implementation.c b/src/common/slurm_protocol_socket_implementation.c index 1d862bf4acab00ed475e0fc78bf0d580bc24dffe..86aa5ba88b043127c1bf8ad8f28cdc33cddd2bcf 100644 --- a/src/common/slurm_protocol_socket_implementation.c +++ b/src/common/slurm_protocol_socket_implementation.c @@ -24,7 +24,9 @@ #include <src/common/log.h> #include <src/common/pack.h> -/* high level calls */ +/***************************************************************** + * MIDDLE LAYER MSG FUNCTIONS + ****************************************************************/ slurm_fd _slurm_init_msg_engine ( slurm_addr * slurm_address ) { return _slurm_listen_stream ( slurm_address ) ; @@ -79,12 +81,15 @@ ssize_t _slurm_msg_recvfrom ( slurm_fd open_fd, char *buffer , size_t size , uin } else if ( recv_len == 0 ) { - error ( "Error receiving length of datagram. errno %i", errno ) ; + /*debug ( "Error receiving length of datagram. recv_len = 0 ") ; */ + slurm_seterrno ( SLURM_PROTOCOL_SOCKET_IMPL_ZERO_RECV_LENGTH ) ; return SLURM_PROTOCOL_ERROR ; } else { - error ( "We don't handle negative return codes > -1") ; + /*debug ( "We don't handle negative return codes > -1") ;*/ + slurm_seterrno ( SLURM_PROTOCOL_SOCKET_IMPL_NEGATIVE_RECV_LENGTH ) ; + return SLURM_PROTOCOL_ERROR ; } } unpack32 ( & transmit_size , ( void ** ) & size_buffer , & size_buffer_len ) ; @@ -101,7 +106,6 @@ ssize_t _slurm_msg_recvfrom ( slurm_fd open_fd, char *buffer , size_t size , uin } else { - error ( "Error receiving datagram. errno %i", errno ) ; return SLURM_PROTOCOL_ERROR ; } return recv_len ; @@ -113,12 +117,15 @@ ssize_t _slurm_msg_recvfrom ( slurm_fd open_fd, char *buffer , size_t size , uin } else if ( recv_len == 0 ) { - error ( "Error receiving datagram. errno %i", errno ) ; + /*debug ( "Error receiving length of datagram. recv_len = 0 ") ; */ + slurm_seterrno ( SLURM_PROTOCOL_SOCKET_IMPL_ZERO_RECV_LENGTH ) ; return SLURM_PROTOCOL_ERROR ; } else { - error ( "We don't handle negative return codes > -1") ; + /*debug ( "We don't handle negative return codes > -1") ;*/ + slurm_seterrno ( SLURM_PROTOCOL_SOCKET_IMPL_NEGATIVE_RECV_LENGTH ) ; + return SLURM_PROTOCOL_ERROR ; } } @@ -153,15 +160,16 @@ ssize_t _slurm_msg_sendto ( slurm_fd open_fd, char *buffer , size_t size , uint3 } else { - error ( "Error in _slurm_send" ) ; sigaction(SIGPIPE, &oldaction , &newaction); return SLURM_PROTOCOL_ERROR ; } } else if ( send_len != sizeof ( uint32_t ) ) { - error ( "Error sending length of datagram" ) ; + /*debug ( "Error sending length of datagram" ) ;*/ + /*debug ( "_slurm_msg_sendto only transmitted %i of %i bytes", send_len , sizeof ( uint32_t ) ) ;*/ sigaction(SIGPIPE, &oldaction , &newaction); + slurm_seterrno ( SLURM_PROTOCOL_SOCKET_IMPL_NOT_ALL_DATA_SENT ) ; return SLURM_PROTOCOL_ERROR ; } else @@ -179,15 +187,15 @@ ssize_t _slurm_msg_sendto ( slurm_fd open_fd, char *buffer , size_t size , uint3 } else { - error ( "Error in _slurm_send" ) ; sigaction(SIGPIPE, &oldaction , &newaction); return SLURM_PROTOCOL_ERROR ; } } else if ( send_len != size ) { - error ( "_slurm_msg_sendto only transmitted %i of %i bytes", send_len , size ) ; + /*debug ( "_slurm_msg_sendto only transmitted %i of %i bytes", send_len , size ) ;*/ sigaction(SIGPIPE, &oldaction , &newaction); + slurm_seterrno ( SLURM_PROTOCOL_SOCKET_IMPL_NOT_ALL_DATA_SENT ) ; return SLURM_PROTOCOL_ERROR ; } else @@ -212,24 +220,25 @@ slurm_fd _slurm_listen_stream ( slurm_addr * slurm_address ) const int one = 1; if ( ( connection_fd =_slurm_create_socket ( SLURM_STREAM ) ) == SLURM_SOCKET_ERROR ) { - error ( "Error creating slurm stream socket: errno %i", errno ) ; + debug ( "Error creating slurm stream socket: errno %i", errno ) ; return connection_fd ; } - if ( ( rc = _slurm_setsockopt(connection_fd , SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one) ) ) ) { - error ("setsockopt SO_REUSEADDR failed"); + if ( ( rc = _slurm_setsockopt(connection_fd , SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one) ) ) ) + { + debug ("setsockopt SO_REUSEADDR failed"); return rc ; } if ( ( rc = _slurm_bind ( connection_fd , ( struct sockaddr const * ) slurm_address , sizeof ( slurm_addr ) ) ) == SLURM_SOCKET_ERROR ) { - error ( "Error binding slurm stream socket: errno %i" , errno ) ; + debug ( "Error binding slurm stream socket: errno %i" , errno ) ; return rc ; } if ( ( rc = _slurm_listen ( connection_fd , SLURM_PROTOCOL_DEFAULT_LISTEN_BACKLOG ) ) == SLURM_SOCKET_ERROR ) { - error ( "Error listening on slurm stream socket: errno %i" , errno ) ; + debug ( "Error listening on slurm stream socket: errno %i" , errno ) ; return rc ; } @@ -242,7 +251,7 @@ slurm_fd _slurm_accept_stream ( slurm_fd open_fd , slurm_addr * slurm_address ) slurm_fd connection_fd ; if ( ( connection_fd = _slurm_accept ( open_fd , ( struct sockaddr * ) slurm_address , & addr_len ) ) == SLURM_SOCKET_ERROR ) { - error ( "Error accepting slurm stream socket: errno %i", errno ) ; + debug ( "Error accepting slurm stream socket: errno %i", errno ) ; } return connection_fd ; @@ -254,13 +263,13 @@ slurm_fd _slurm_open_stream ( slurm_addr * slurm_address ) slurm_fd connection_fd ; if ( ( connection_fd =_slurm_create_socket ( SLURM_STREAM ) ) == SLURM_SOCKET_ERROR ) { - error ( "Error creating slurm stream socket: errno %i", errno ) ; + debug ( "Error creating slurm stream socket: errno %i", errno ) ; return connection_fd ; } if ( ( rc = _slurm_connect ( connection_fd , ( struct sockaddr const * ) slurm_address , sizeof ( slurm_addr ) ) ) == SLURM_SOCKET_ERROR ) { - error ( "Error connecting on slurm stream socket: errno %i" , errno ) ; + debug ( "Error connecting on slurm stream socket: errno %i" , errno ) ; return rc ; } diff --git a/src/common/slurm_protocol_util.c b/src/common/slurm_protocol_util.c index 8a41df8c570d89fd14fdf5e85d9a9275d49b8cfa..3010f0698aba593947e4eafded4025e1ed9d29cb 100644 --- a/src/common/slurm_protocol_util.c +++ b/src/common/slurm_protocol_util.c @@ -11,7 +11,7 @@ uint32_t check_header_version( header_t * header) { if ( header -> version != SLURM_PROTOCOL_VERSION ) { - error ( "Invalid Protocol Version %d ", header -> version ) ; + debug ( "Invalid Protocol Version %d ", header -> version ) ; return SLURM_PROTOCOL_VERSION_ERROR ; } return SLURM_PROTOCOL_SUCCESS ; @@ -30,8 +30,8 @@ uint32_t check_io_stream_header_version( slurm_io_stream_header_t * header) { if ( header -> version != SLURM_PROTOCOL_VERSION ) { - error ( "Invalid Protocol Version %d ", header -> version ) ; - return SLURM_PROTOCOL_VERSION_ERROR ; + debug ( "Invalid IO Stream Protocol Version %d ", header -> version ) ; + return SLURM_PROTOCOL_IO_STREAM_VERSION_ERROR ; } return SLURM_PROTOCOL_SUCCESS ; }