Skip to content

Commit

Permalink
fixed an error that makes client hang when running GPU
Browse files Browse the repository at this point in the history
  • Loading branch information
justanhduc committed Nov 11, 2020
1 parent 9cde718 commit 1540cfe
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 80 deletions.
76 changes: 51 additions & 25 deletions client.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ char *build_command_string()

void c_new_job()
{
struct msg m;
struct Msg m;
char *new_command;
char *myenv;

Expand Down Expand Up @@ -103,7 +103,7 @@ void c_new_job()

int c_wait_newjob_ok()
{
struct msg m;
struct Msg m;
int res;

res = recv_msg(server_socket, &m);
Expand All @@ -122,7 +122,7 @@ int c_wait_newjob_ok()

int c_wait_server_commands()
{
struct msg m;
struct Msg m;
int res;

while (1)
Expand Down Expand Up @@ -176,7 +176,7 @@ int c_wait_server_commands()

void c_wait_server_lines()
{
struct msg m;
struct Msg m;
int res;

while (1)
Expand All @@ -202,7 +202,7 @@ void c_wait_server_lines()

void c_list_jobs()
{
struct msg m;
struct Msg m;

m.type = LIST;

Expand All @@ -212,7 +212,7 @@ void c_list_jobs()
/* Exits if wrong */
void c_check_version()
{
struct msg m;
struct Msg m;
int res;

m.type = GET_VERSION;
Expand Down Expand Up @@ -243,7 +243,7 @@ void c_check_version()

void c_show_info()
{
struct msg m;
struct Msg m;
int res;

m.type = INFO;
Expand Down Expand Up @@ -281,7 +281,7 @@ void c_show_info()
}

void c_show_last_id() {
struct msg m;
struct Msg m;
int res;

m.type = LAST_ID;
Expand All @@ -302,7 +302,7 @@ void c_show_last_id() {

void c_send_runjob_ok(const char *ofname, int pid)
{
struct msg m;
struct Msg m;

/* Prepare the message */
m.type = RUNJOB_OK;
Expand All @@ -325,7 +325,7 @@ void c_send_runjob_ok(const char *ofname, int pid)

static void c_end_of_job(const struct Result *res)
{
struct msg m;
struct Msg m;

m.type = ENDJOB;
m.u.result = *res; /* struct copy */
Expand All @@ -335,23 +335,23 @@ static void c_end_of_job(const struct Result *res)

void c_shutdown_server()
{
struct msg m;
struct Msg m;

m.type = KILL_SERVER;
send_msg(server_socket, &m);
}

void c_clear_finished()
{
struct msg m;
struct Msg m;

m.type = CLEAR_FINISHED;
send_msg(server_socket, &m);
}

static char * get_output_file(int *pid)
{
struct msg m;
struct Msg m;
int res;
char *string = 0;

Expand Down Expand Up @@ -469,7 +469,7 @@ void c_kill_job()
}

void c_kill_all_jobs() {
struct msg m;
struct Msg m;
int res;

/* Send the request */
Expand All @@ -496,7 +496,7 @@ void c_kill_all_jobs() {

void c_remove_job()
{
struct msg m;
struct Msg m;
int res;
char *string = 0;

Expand Down Expand Up @@ -529,7 +529,7 @@ void c_remove_job()

int c_wait_job_recv()
{
struct msg m;
struct Msg m;
int res;
char *string = 0;

Expand Down Expand Up @@ -560,7 +560,7 @@ int c_wait_job_recv()

static void c_wait_job_send()
{
struct msg m;
struct Msg m;

/* Send the request */
m.type = WAITJOB;
Expand All @@ -570,7 +570,7 @@ static void c_wait_job_send()

static void c_wait_running_job_send()
{
struct msg m;
struct Msg m;

/* Send the request */
m.type = WAIT_RUNNING_JOB;
Expand All @@ -594,7 +594,7 @@ int c_wait_running_job()

void c_send_max_slots(int max_slots)
{
struct msg m;
struct Msg m;

/* Send the request */
m.type = SET_MAX_SLOTS;
Expand All @@ -604,7 +604,7 @@ void c_send_max_slots(int max_slots)

void c_get_max_slots()
{
struct msg m;
struct Msg m;
int res;

/* Send the request */
Expand All @@ -628,7 +628,7 @@ void c_get_max_slots()

void c_move_urgent()
{
struct msg m;
struct Msg m;
int res;
char *string = 0;

Expand Down Expand Up @@ -664,7 +664,7 @@ void c_move_urgent()

void c_get_state()
{
struct msg m;
struct Msg m;
int res;
char *string = 0;

Expand Down Expand Up @@ -701,7 +701,7 @@ void c_get_state()

void c_swap_jobs()
{
struct msg m;
struct Msg m;
int res;
char *string = 0;

Expand Down Expand Up @@ -737,7 +737,7 @@ void c_swap_jobs()
}

void c_get_count_running() {
struct msg m;
struct Msg m;
int res;

/* Send the request */
Expand All @@ -764,7 +764,7 @@ void c_get_count_running() {

void c_show_label()
{
struct msg m;
struct Msg m;
int res;
char *string = 0;

Expand Down Expand Up @@ -795,3 +795,29 @@ void c_show_label()
/* This will never be reached */
return;
}

void c_get_gpu_wait_time() {
struct Msg m;
int res;

m.type = GET_GPU_WAIT_TIME;
send_msg(server_socket, &m);

/* Receive the answer */
res = recv_msg(server_socket, &m);
if(res != sizeof(m))
error("Error in get_gpu_wait_time");

if (m.type == GET_GPU_WAIT_TIME)
printf("%d\n", m.u.gpu_wait_time);
else
warning("Wrong internal message in get_gpu_wait_time");
}

void c_set_gpu_wait_time() {
struct Msg m;

m.type = SET_GPU_WAIT_TIME;
m.u.gpu_wait_time = command_line.gpu_wait_time;
send_msg(server_socket, &m);
}
6 changes: 3 additions & 3 deletions error.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static void problem(enum Etype type, const char *str, va_list ap)
fclose(out);
}

static void problem_msg(enum Etype type, const struct msg *m, const char *str, va_list ap)
static void problem_msg(enum Etype type, const struct Msg *m, const char *str, va_list ap)
{
FILE *out;

Expand Down Expand Up @@ -161,7 +161,7 @@ void error(const char *str, ...)
exit(-1);
}

void error_msg(const struct msg *m, const char *str, ...)
void error_msg(const struct Msg *m, const char *str, ...)
{
va_list ap;

Expand All @@ -184,7 +184,7 @@ void warning(const char *str, ...)
problem(WARNING, str, ap);
}

void warning_msg(const struct msg *m, const char *str, ...)
void warning_msg(const struct Msg *m, const char *str, ...)
{
va_list ap;

Expand Down
Loading

0 comments on commit 1540cfe

Please sign in to comment.