@@ -102,6 +102,20 @@ find_free_uuid_hash_index(
102102 int run_id ,
103103 const ej_uuid_t * puuid );
104104
105+ static void
106+ touch_last_update_time_us (runlog_state_t state )
107+ {
108+ struct timeval tv ;
109+ gettimeofday (& tv , NULL );
110+ state -> last_update_time_us = tv .tv_sec * 1000000LL + tv .tv_usec ;
111+ }
112+
113+ long long
114+ run_get_last_update_time_us (runlog_state_t state )
115+ {
116+ return state -> last_update_time_us ;
117+ }
118+
105119runlog_state_t
106120run_init (teamdb_state_t ts )
107121{
@@ -150,6 +164,8 @@ run_set_runlog(
150164 if (runlog_check (0 , & state -> head , id_offset , total_entries , entries ) < 0 )
151165 return -1 ;
152166
167+ touch_last_update_time_us (state );
168+
153169 if (state -> iface -> set_runlog (state -> cnts , id_offset , total_entries , entries ) < 0 )
154170 return -1 ;
155171
@@ -185,6 +201,8 @@ run_open(
185201 return -1 ;
186202 }
187203
204+ touch_last_update_time_us (state );
205+
188206 if (!plugin_name ) {
189207 // use the default plugin
190208 if (global ) plugin_name = global -> rundb_plugin ;
@@ -320,6 +338,8 @@ run_add_record(
320338 uint64_t flags = 0 ;
321339 int run_to_ignore = -1 ;
322340
341+ touch_last_update_time_us (state );
342+
323343 state -> uuid_hash_last_added_index = -1 ;
324344 state -> uuid_hash_last_added_run_id = -1 ;
325345 if (!is_hidden ) {
@@ -498,6 +518,8 @@ run_add_record(
498518int
499519run_undo_add_record (runlog_state_t state , int run_id )
500520{
521+ touch_last_update_time_us (state );
522+
501523 if (run_id < state -> run_f || run_id >= state -> run_u ) {
502524 err ("run_undo_add_record: invalid run_id" );
503525 return -1 ;
@@ -558,6 +580,8 @@ run_change_status(
558580 if (state -> runs [off_run_id ].is_readonly )
559581 ERR_R ("this entry is read-only" );
560582
583+ touch_last_update_time_us (state );
584+
561585 return state -> iface -> change_status (state -> cnts , runid , newstatus , newtest ,
562586 newpassedmode , newscore , judge_id ,
563587 judge_uuid , verdict_bits );
@@ -599,6 +623,8 @@ run_change_status_3(
599623 if (state -> runs [off_run_id ].is_readonly )
600624 ERR_R ("this entry is read-only" );
601625
626+ touch_last_update_time_us (state );
627+
602628 return state -> iface -> change_status_3 (state -> cnts , /* cntx */
603629 runid , /* run_id */
604630 newstatus , /* new_status */
@@ -636,6 +662,8 @@ run_change_status_4(
636662 if (state -> runs [off_run_id ].is_readonly )
637663 ERR_R ("this entry is read-only" );
638664
665+ touch_last_update_time_us (state );
666+
639667 return state -> iface -> change_status_4 (state -> cnts , runid , newstatus );
640668}
641669
@@ -656,31 +684,41 @@ run_is_imported(runlog_state_t state, int runid)
656684int
657685run_start_contest (runlog_state_t state , time_t start_time )
658686{
687+ touch_last_update_time_us (state );
688+
659689 if (state -> head .start_time ) ERR_R ("Contest already started" );
660690 return state -> iface -> start (state -> cnts , start_time );
661691}
662692
663693int
664694run_stop_contest (runlog_state_t state , time_t stop_time )
665695{
696+ touch_last_update_time_us (state );
697+
666698 return state -> iface -> stop (state -> cnts , stop_time );
667699}
668700
669701int
670702run_set_duration (runlog_state_t state , time_t dur )
671703{
704+ touch_last_update_time_us (state );
705+
672706 return state -> iface -> set_duration (state -> cnts , dur );
673707}
674708
675709int
676710run_sched_contest (runlog_state_t state , time_t sched )
677711{
712+ touch_last_update_time_us (state );
713+
678714 return state -> iface -> schedule (state -> cnts , sched );
679715}
680716
681717int
682718run_set_finish_time (runlog_state_t state , time_t finish_time )
683719{
720+ touch_last_update_time_us (state );
721+
684722 return state -> iface -> set_finish_time (state -> cnts , finish_time );
685723}
686724
@@ -1107,6 +1145,8 @@ run_reset(
11071145
11081146 run_drop_uuid_hash (state );
11091147
1148+ touch_last_update_time_us (state );
1149+
11101150 return state -> iface -> reset (state -> cnts , init_duration , init_sched_time ,
11111151 init_finish_time );
11121152}
@@ -1308,6 +1348,8 @@ run_set_entry(
13081348 time_t stop_time ;
13091349 int old_user_id = 0 ;
13101350
1351+ touch_last_update_time_us (state );
1352+
13111353 ASSERT (in );
13121354 if (run_id < state -> run_f || run_id >= state -> run_u ) ERR_R ("bad runid: %d" , run_id );
13131355 out = & state -> runs [run_id - state -> run_f ];
@@ -1675,6 +1717,8 @@ run_virtual_start(
16751717 int i ;
16761718 struct run_entry re ;
16771719
1720+ touch_last_update_time_us (state );
1721+
16781722 if (!state -> head .start_time ) {
16791723 err ("run_virtual_start: the contest is not started" );
16801724 return -1 ;
@@ -1735,6 +1779,8 @@ run_virtual_stop(
17351779 time_t exp_stop_time = 0 ;
17361780 struct run_entry re ;
17371781
1782+ touch_last_update_time_us (state );
1783+
17381784 if (!state -> head .start_time ) {
17391785 err ("run_virtual_stop: the contest is not started" );
17401786 return -1 ;
@@ -1827,6 +1873,8 @@ run_clear_entry(runlog_state_t state, int run_id)
18271873 int i ;
18281874 struct user_run_header_info * urh = NULL ;
18291875
1876+ touch_last_update_time_us (state );
1877+
18301878 if (run_id < state -> run_f || run_id >= state -> run_u ) ERR_R ("bad runid: %d" , run_id );
18311879 if (state -> runs [run_id - state -> run_f ].is_readonly ) ERR_R ("run %d is readonly" , run_id );
18321880 switch (state -> runs [run_id - state -> run_f ].status ) {
@@ -1879,6 +1927,8 @@ run_clear_user_entries(
18791927 int run_id ;
18801928 if (user_id <= 0 ) return 0 ;
18811929
1930+ touch_last_update_time_us (state );
1931+
18821932 for (run_id = state -> run_u - 1 ; run_id >= state -> run_f ; -- run_id ) {
18831933 if (state -> runs [run_id - state -> run_f ].user_id == user_id ) {
18841934 state -> iface -> clear_entry (state -> cnts , run_id );
@@ -1894,6 +1944,8 @@ run_forced_clear_entry(runlog_state_t state, int run_id)
18941944{
18951945 if (run_id < state -> run_f || run_id >= state -> run_u ) ERR_R ("bad runid: %d" , run_id );
18961946
1947+ touch_last_update_time_us (state );
1948+
18971949 struct user_run_header_info * urh = run_try_user_run_header (state , state -> runs [run_id - state -> run_f ].user_id );
18981950 if (urh ) {
18991951 urh -> run_id_valid = 0 ;
@@ -1910,6 +1962,7 @@ int
19101962run_set_hidden (runlog_state_t state , int run_id )
19111963{
19121964 if (run_id < 0 || run_id >= state -> run_u ) ERR_R ("bad runid: %d" , run_id );
1965+ touch_last_update_time_us (state );
19131966 return state -> iface -> set_hidden (state -> cnts , run_id , 1 );
19141967}
19151968
@@ -1941,6 +1994,7 @@ run_has_transient_user_runs(runlog_state_t state, int user_id)
19411994int
19421995run_squeeze_log (runlog_state_t state )
19431996{
1997+ touch_last_update_time_us (state );
19441998 return state -> iface -> squeeze (state -> cnts );
19451999}
19462000
@@ -2463,6 +2517,7 @@ run_set_pages(runlog_state_t state, int run_id, int pages)
24632517{
24642518 if (run_id < 0 || run_id >= state -> run_u ) ERR_R ("bad runid: %d" , run_id );
24652519 if (pages < 0 || pages > 255 ) ERR_R ("bad pages: %d" , pages );
2520+ touch_last_update_time_us (state );
24662521 return state -> iface -> set_pages (state -> cnts , run_id , pages );
24672522}
24682523
@@ -2627,6 +2682,7 @@ run_put_entry(
26272682 runlog_state_t state ,
26282683 const struct run_entry * re )
26292684{
2685+ touch_last_update_time_us (state );
26302686 return state -> iface -> put_entry (state -> cnts , re );
26312687}
26322688
@@ -2635,6 +2691,7 @@ run_put_header(
26352691 runlog_state_t state ,
26362692 const struct run_header * rh )
26372693{
2694+ touch_last_update_time_us (state );
26382695 return state -> iface -> put_header (state -> cnts , rh );
26392696}
26402697
@@ -3038,6 +3095,8 @@ run_set_user_stop_time(
30383095 return -1 ;
30393096 }
30403097
3098+ touch_last_update_time_us (state );
3099+
30413100 return state -> iface -> user_run_header_set_stop_time (state -> cnts , user_id , stop_time , last_change_user_id );
30423101}
30433102
@@ -3048,6 +3107,8 @@ run_set_virtual_is_checked(
30483107 int is_checked ,
30493108 int last_change_user_id )
30503109{
3110+ touch_last_update_time_us (state );
3111+
30513112 if (state -> iface -> user_run_header_set_is_checked ) {
30523113 return state -> iface -> user_run_header_set_is_checked (state -> cnts , user_id , is_checked , last_change_user_id );
30533114 } else {
@@ -3076,6 +3137,8 @@ run_set_user_duration(
30763137 return -1 ;
30773138 }
30783139
3140+ touch_last_update_time_us (state );
3141+
30793142 return state -> iface -> user_run_header_set_duration (state -> cnts , user_id , duration , last_change_user_id );
30803143}
30813144
@@ -3116,6 +3179,8 @@ run_rebuild_user_run_index(runlog_state_t state, int user_id)
31163179int
31173180run_set_run_is_checked (runlog_state_t state , int run_id , int is_checked )
31183181{
3182+ touch_last_update_time_us (state );
3183+
31193184 if (run_id < 0 || run_id >= state -> run_u ) ERR_R ("bad runid: %d" , run_id );
31203185 if (!state -> iface -> run_set_is_checked ) {
31213186 ERR_R ("run_set_is_checked is not implemented" );
0 commit comments