7 * check if anyone appears to have defaulted on a booking
10 * if it is allocated/tentative
11 * and it's allocation time is before now, but after last check
12 * and user allocated is not on
14 * record default for allocated user in this lab for this period
18 void check_default(table *t)
20 static time_t last_check = 0;
23 int grace = get_configint("grace");
27 if (grace==0) grace=7*60;
35 for (ind=0 ; ind < t->table_len ; ind++)
37 if (Cluster_type(t,ind)== ALLOCCLUSTER)
39 lab = Cluster_id(t,ind);
40 alloctime = Cluster_modtime(t,ind);
42 if (Cluster_type(t,ind) == WSRESCLUSTER
43 && (Res_status(t,ind) == NODEALLOCATED
44 ||Res_status(t,ind) == NODETENTATIVE)
45 && Res_user(t,ind) < get_class_min()
46 && alloctime +grace <= now
47 && alloctime +grace > last_check
48 && Cluster_type(t,ind-1) == WSSTATUSCLUSTER
49 && Cluster_id(t,ind-1) == Cluster_id(t,ind)
50 /* && Ws_user(t,ind-1) != Res_user(t,ind) */
53 /* ok, a rescluster which might be for us.
54 * must check the ws belong to us, and that
57 workstation_state *ws = get_wsstate(Cluster_id(t,ind),0);
59 && (ws->host == my.hostid
60 || (ws->host <0 && Ws_whereon(t,ind-1)==my.hostid)
61 || (ws->host <0 && Ws_whereon(t,ind-1)<0 && am_master)
69 ch.chng = CLAIM_BOOKING;
70 cp = & ch.book_change_u.aclaim;
72 get_doypod(&alloctime, &doy, &pod);
73 cp->slot = make_bookkey(doy, pod, lab);
74 cp->user = Res_user(t,ind);
77 if (check_whoison(Cluster_id(t,ind), &whenon) ==
80 int delta_whenon = whenon - alloctime;
81 if (delta_whenon < -10*60)
83 cp->claimtime = DID_LOGIN | ((delta_whenon+30*60) <<4);
84 cp->where = Cluster_id(t,ind);
86 else if (Cluster_modtime(t,ind) > alloctime + 30)
88 /* looks like they claimed, but haven't logged on yet, give them the benefit of the doubt */
93 /* Ok, looks like a defaulter to me!! */
94 cp->claimtime = DID_DEFAULT;
98 sprintf(buf, "check_default set %x for user %d on %d (d%d,p%d,l%d)\n",
99 cp->claimtime, (int)cp->user, cp->where, doy, pod, lab);