Bugfix: some "-t" and "-c" were not notified at end of job.
--- a/buglist.bug Wed Jul 16 06:38:33 2008 +0200
+++ b/buglist.bug Wed Jul 16 07:02:48 2008 +0200
@@ -7,4 +7,3 @@
13 3 open Wrong output message on -t D State Output E-Level Times(r/u/s) Command\n17 finished /tmp/ts-out.Ra7s9g 1 5.31/1.23/1.72 clearmake bcd_io_bcd_io_src_io_bsd_server_bsd bcd_io_bcd_io_src_io_bsd_test_server_rserver\n18 skipped (no output) && clearmake bcd_io_bcd_io_src_io_bsd_io_testbsd_engine\n19 skipped (no output) && putio.sh 16.23.86.24 bin/io_testbsd_engine bin/io_bsd_server_rserver\n\n$ ts -t\nError in the request: Job -1 was skipped due to a dependency.\n\nThere should say "The last job was skipped..."
14 -3 open '-t' doesn't show 10 lines, but more.
15 1 open 'ts -r' show a strange message, when all jobs are finished. \nit says something about cannot remove a jobid - a strange jobid.
-16 10 open sometimes "ts -t" doesn't end. I've seen it with the latest version with multislot support.
--- a/client.c Wed Jul 16 06:38:33 2008 +0200
+++ b/client.c Wed Jul 16 07:02:48 2008 +0200
@@ -14,6 +14,8 @@
#include "main.h"
static void c_end_of_job(const struct Result *res);
+static void c_wait_job_send();
+static void c_wait_running_job_send();
char *build_command_string()
{
@@ -329,7 +331,7 @@
exit(-1);
}
- c_wait_job_send();
+ c_wait_running_job_send();
return tail_file(str, 10 /* Last lines to show */);
}
@@ -344,7 +346,7 @@
fprintf(stderr, "The output is not stored. Cannot cat.\n");
exit(-1);
}
- c_wait_job_send();
+ c_wait_running_job_send();
return tail_file(str, -1 /* All the lines */);
}
@@ -437,7 +439,7 @@
return -1;
}
-void c_wait_job_send()
+static void c_wait_job_send()
{
struct msg m;
@@ -447,6 +449,16 @@
send_msg(server_socket, &m);
}
+static void c_wait_running_job_send()
+{
+ struct msg m;
+
+ /* Send the request */
+ m.type = WAIT_RUNNING_JOB;
+ m.u.jobid = command_line.jobid;
+ send_msg(server_socket, &m);
+}
+
/* Returns the errorlevel */
int c_wait_job()
{
@@ -454,10 +466,16 @@
return c_wait_job_recv();
}
+/* Returns the errorlevel */
+int c_wait_running_job()
+{
+ c_wait_running_job_send();
+ return c_wait_job_recv();
+}
+
void c_send_max_slots(int max_slots)
{
struct msg m;
- int res;
/* Send the request */
m.type = SET_MAX_SLOTS;
--- a/jobs.c Wed Jul 16 06:38:33 2008 +0200
+++ b/jobs.c Wed Jul 16 07:02:48 2008 +0200
@@ -39,14 +39,6 @@
static struct Job * get_job(int jobid);
void notify_errorlevel(struct Job *p);
-static int max_int(int a, int b)
-{
- if (a > b)
- return a;
- else
- return b;
-}
-
static void send_list_line(int s, const char * str)
{
struct msg m;
@@ -1036,6 +1028,69 @@
add_to_notify_list(s, p->jobid);
}
+void s_wait_running_job(int s, int jobid)
+{
+ struct Job *p = 0;
+
+ /* The job finding algorithm should be similar to that of
+ * s_send_output, because this will be used by "-t" and "-c" */
+ if (jobid == -1)
+ {
+ /* This means that we want the output info of the running task, or that
+ * of the last job run */
+ if (busy_slots > 0)
+ {
+ p = firstjob;
+ if (p == 0)
+ error("Internal state WAITING, but job not run."
+ "firstjob = %x", firstjob);
+ }
+ else
+ {
+ p = first_finished_job;
+ if (p == 0)
+ {
+ send_list_line(s, "No jobs.\n");
+ return;
+ }
+ while(p->next != 0)
+ p = p->next;
+ }
+ }
+ else
+ {
+ p = firstjob;
+ while (p != 0 && p->jobid != jobid)
+ p = p->next;
+
+ /* Look in finished jobs if needed */
+ if (p == 0)
+ {
+ p = first_finished_job;
+ while (p != 0 && p->jobid != jobid)
+ p = p->next;
+ }
+ }
+
+ if (p == 0)
+ {
+ char tmp[50];
+ if (jobid == -1)
+ sprintf(tmp, "The last job cannot be waited.\n");
+ else
+ sprintf(tmp, "The job %i cannot be waited.\n", jobid);
+ send_list_line(s, tmp);
+ return;
+ }
+
+ if (p->state == FINISHED || p->state == SKIPPED)
+ {
+ send_waitjob_ok(s, p->result.errorlevel);
+ }
+ else
+ add_to_notify_list(s, p->jobid);
+}
+
void s_set_max_slots(int new_max_slots)
{
if (new_max_slots > 0)
--- a/main.h Wed Jul 16 06:38:33 2008 +0200
+++ b/main.h Wed Jul 16 07:02:48 2008 +0200
@@ -19,6 +19,7 @@
REMOVEJOB,
REMOVEJOB_OK,
WAITJOB,
+ WAIT_RUNNING_JOB,
WAITJOB_OK,
URGENT,
URGENT_OK,
@@ -174,8 +175,8 @@
void c_remove_job();
void c_show_pid();
int c_wait_job();
+int c_wait_running_job();
int c_wait_job_recv();
-void c_wait_job_send();
void c_move_urgent();
int c_wait_newjob_ok();
void c_get_state();
@@ -198,6 +199,7 @@
void s_remove_notification(int s);
void check_notify_list(int jobid);
void s_wait_job(int s, int jobid);
+void s_wait_running_job(int s, int jobid);
void s_move_urgent(int s, int jobid);
void s_send_state(int s, int jobid);
void s_swap_jobs(int s, int jobid1, int jobid2);
--- a/server.c Wed Jul 16 06:38:33 2008 +0200
+++ b/server.c Wed Jul 16 07:02:48 2008 +0200
@@ -375,6 +375,11 @@
s_wait_job(s, m.u.jobid);
}
+ if (m.type == WAIT_RUNNING_JOB)
+ {
+ s_wait_running_job(s, m.u.jobid);
+ }
+
if (m.type == URGENT)
{
s_move_urgent(s, m.u.jobid);