void gw_rm_wait_success(void *_job_id) { int job_id; gw_msg_t msg; int length; gw_job_t * job; gw_connection_list_t * connection; int rc; job_id = *((int *) _job_id); length = sizeof(gw_msg_t); free(_job_id); job = gw_job_pool_get(job_id, GW_TRUE); if (job == NULL) msg.rc = GW_RC_FAILED_BAD_JOB_ID; else { if ( job->job_state == GW_JOB_STATE_FAILED) msg.rc = GW_RC_FAILED_JOB_FAIL; else msg.rc = GW_RC_SUCCESS; msg.exit_code = job->exit_code; msg.array_id = job->array_id; } msg.msg_type = GW_MSG_WAIT; msg.job_id = job_id; connection = gw_connection_list_get(&(gw_rm.connection_list), GW_MSG_WAIT, job_id); if ( connection == NULL ) gw_log_print("RM",'W',"Connection for job %i has been closed (WAIT_SUCCESS).\n", job_id); else while ( connection != NULL )/*Notify all clients waiting for this job*/ { if ( job != NULL ) job->client_waiting--; rc = send(connection->socket_fs,(void *)&msg,length,0); if ( rc == -1 ) gw_log_print("RM",'E',"Error sending message %s\n",strerror(errno)); /* If in a wait-any remove pending waits of this client */ if ( connection->wait_type == GW_MSG_WAIT_ANY ) gw_rm_wait_remove_anys(connection->socket_fs); free (connection); connection = gw_connection_list_get(&(gw_rm.connection_list), GW_MSG_WAIT, job_id); } pthread_mutex_unlock(&(job->mutex)); }
void gw_rm_kill_success(void *_job_id) { int job_id; gw_msg_t msg; int length; gw_connection_list_t * connection; int rc; job_id = *( (int *) _job_id ); length = sizeof(gw_msg_t); free(_job_id); msg.msg_type = GW_MSG_KILL; msg.job_id = job_id; msg.rc = GW_RC_SUCCESS; connection = gw_connection_list_get(&(gw_rm.connection_list), GW_MSG_KILL, job_id); while ( connection != NULL ) { rc = send(connection->socket_fs,(void *) &msg, length, 0); if ( rc == -1 ) gw_log_print("RM",'E',"Error sending message %s\n",strerror(errno)); free (connection); connection = gw_connection_list_get(&(gw_rm.connection_list), GW_MSG_KILL, job_id); } /* CHECK IF SOMEONE WAS WAITING FOR THIS JOB */ msg.rc = GW_RC_FAILED_JOB_KILLED; connection = gw_connection_list_get(&(gw_rm.connection_list), GW_MSG_WAIT, job_id); while ( connection != NULL ) { rc = send(connection->socket_fs,(void *) &msg,length,0); if ( rc == -1 ) gw_log_print("RM",'E',"Error sending message %s\n",strerror(errno)); if ( connection->wait_type == GW_MSG_WAIT_ANY ) gw_rm_wait_remove_anys(connection->socket_fs); free (connection); connection = gw_connection_list_get(&(gw_rm.connection_list), GW_MSG_WAIT, job_id); } }
void gw_rm_wait_failed (void *_job_id) { int job_id; gw_msg_t msg; int length; gw_connection_list_t * connection; int rc; job_id = *( (int *) _job_id ); length = sizeof(gw_msg_t); free(_job_id); msg.rc = GW_RC_FAILED_BAD_JOB_ID; msg.msg_type = GW_MSG_WAIT; msg.job_id = job_id; connection = gw_connection_list_get(&(gw_rm.connection_list), GW_MSG_WAIT, job_id); if ( connection == NULL ) gw_log_print("RM",'W',"Connection for job %i has been closed (WAIT_FAILED).\n", job_id); else { rc = send(connection->socket_fs,(void *)&msg,length,0); if ( rc == -1 ) gw_log_print("RM",'E',"Error sending message %s\n",strerror(errno)); if ( connection->wait_type == GW_MSG_WAIT_ANY ) gw_rm_wait_remove_anys(connection->socket_fs); free (connection); } }
void gw_rm_resume_failed (void *_job_id) { int job_id; gw_msg_t msg; int length; gw_job_t * job; gw_connection_list_t * connection; int rc; job_id = *( (int *) _job_id ); length = sizeof(gw_msg_t); free(_job_id); job = gw_job_pool_get(job_id, GW_FALSE); if (job == NULL) msg.rc = GW_RC_FAILED_BAD_JOB_ID; else msg.rc = GW_RC_FAILED_BAD_JOB_STATE; msg.msg_type = GW_MSG_RELEASE; msg.job_id = job_id; connection = gw_connection_list_get(&(gw_rm.connection_list), GW_MSG_RESUME, job_id); if ( connection == NULL ) gw_log_print("RM",'W',"Connection for job %i has been closed (RESUME_FAILED).\n", job_id); else while ( connection != NULL ) { rc = send(connection->socket_fs, (void *) &msg, length, 0); if ( rc == -1 ) gw_log_print("RM",'E',"Error sending message %s\n",strerror(errno)); free (connection); connection = gw_connection_list_get(&(gw_rm.connection_list), GW_MSG_RELEASE, job_id); } }
void gw_rm_stop_success(void *_job_id) { int job_id; gw_msg_t msg; int length; gw_connection_list_t * connection; int rc; job_id = *((int *) _job_id); length = sizeof(gw_msg_t); free(_job_id); msg.msg_type = GW_MSG_STOP; msg.job_id = job_id; msg.rc = GW_RC_SUCCESS; connection = gw_connection_list_get(&(gw_rm.connection_list), GW_MSG_STOP, job_id); if ( connection == NULL ) gw_log_print("RM",'W',"Connection for job %i has been closed (STOP_SUCCESS).\n", job_id); else while ( connection != NULL ) { rc = send(connection->socket_fs, (void *) &msg, length, 0); if ( rc == -1 ) gw_log_print("RM",'E',"Error sending message %s\n",strerror(errno)); free (connection); connection = gw_connection_list_get(&(gw_rm.connection_list), GW_MSG_STOP, job_id); } }