Skip to content
Snippets Groups Projects
Commit cbc7af6b authored by jce's avatar jce
Browse files

ported reconfigure to new comm layer.

parent 3ff55080
No related branches found
No related tags found
No related merge requests found
......@@ -117,7 +117,7 @@ slurm_load_jobs (time_t update_time, job_info_msg_t **job_info_msg_pptr)
slurm_msg_t request_msg ;
slurm_msg_t response_msg ;
last_update_msg_t last_time_msg ;
return_code_msg_t * slurm_rc_msg ;
return_code_msg_t * slurm_rc_msg ;
/* init message connection for message communication with controller */
if ( ( sockfd = slurm_open_controller_conn ( SLURM_PORT ) ) == SLURM_SOCKET_ERROR )
......
......@@ -10,14 +10,8 @@
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <src/common/slurm_protocol_api.h>
#include "slurm.h"
#if DEBUG_MODULE
......@@ -43,59 +37,46 @@ main (int argc, char *argv[]) {
#endif
/*
* reconfigure - _ request that slurmctld re-read the configuration files
* output: returns 0 on success, errno otherwise
*/
int
reconfigure () {
int buffer_offset, buffer_size, error_code, in_size;
char request_msg[64], *buffer;
int sockfd;
struct sockaddr_in serv_addr;
if ((sockfd = socket (AF_INET, SOCK_STREAM, 0)) < 0)
return EINVAL;
serv_addr.sin_family = PF_INET;
serv_addr.sin_addr.s_addr = inet_addr (SLURMCTLD_HOST);
serv_addr.sin_port = htons (SLURMCTLD_PORT);
if (connect
(sockfd, (struct sockaddr *) &serv_addr,
sizeof (serv_addr)) < 0) {
close (sockfd);
return EINVAL;
}
sprintf (request_msg, "Reconfigure");
if (send (sockfd, request_msg, strlen (request_msg) + 1, 0) <
strlen (request_msg)) {
close (sockfd);
return EINVAL;
}
buffer = NULL;
buffer_offset = 0;
buffer_size = 1024;
while (1) {
buffer = realloc (buffer, buffer_size);
if (buffer == NULL) {
close (sockfd);
return ENOMEM;
}
in_size =
recv (sockfd, &buffer[buffer_offset],
(buffer_size - buffer_offset), 0);
if (in_size <= 0) { /* end if input */
in_size = 0;
break;
}
buffer_offset += in_size;
buffer_size += in_size;
}
close (sockfd);
buffer_size = buffer_offset + in_size;
buffer = realloc (buffer, buffer_size);
if (buffer == NULL)
return ENOMEM;
error_code = atoi (buffer);
free (buffer);
return error_code;
slurm_reconfigure ()
{
int msg_size ;
int rc ;
slurm_fd sockfd ;
slurm_msg_t request_msg ;
slurm_msg_t response_msg ;
return_code_msg_t* rc_msg ;
/* init message connection for message communication with controller */
if ( ( sockfd = slurm_open_controller_conn ( SLURM_PORT ) ) == SLURM_SOCKET_ERROR )
return SLURM_SOCKET_ERROR ;
/* send request message */
request_msg . msg_type = REQUEST_RECONFIGURE ;
if ( ( rc = slurm_send_controller_msg ( sockfd , & request_msg ) ) == SLURM_SOCKET_ERROR )
return SLURM_SOCKET_ERROR ;
/* receive message */
if ( ( msg_size = slurm_receive_msg ( sockfd , & response_msg ) ) == SLURM_SOCKET_ERROR )
return SLURM_SOCKET_ERROR ;
/* shutdown message connection */
if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) == SLURM_SOCKET_ERROR )
return SLURM_SOCKET_ERROR ;
switch ( response_msg . msg_type )
{
case RESPONSE_SLURM_RC:
rc_msg = ( return_code_msg_t * ) response_msg . data ;
return rc_msg->return_code ;
break ;
default:
return SLURM_UNEXPECTED_MSG_ERROR ;
break ;
}
return SLURM_SUCCESS ;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment