mirror of
https://github.com/QingdaoU/Judger.git
synced 2024-12-28 07:51:42 +00:00
Merge pull request #14 from QingdaoU/bug_fix
fix a bug in logger; fix test warnings
This commit is contained in:
commit
679994e8df
@ -48,8 +48,8 @@ void log_write(int level, const char *source_filename, const int line, const FIL
|
||||
va_end(ap);
|
||||
|
||||
int count = snprintf(buffer, log_buffer_size,
|
||||
"%s [%s] [%s:%d]%s\n",
|
||||
LOG_LEVEL_NOTE[level], datetime, source_filename, line, log_buffer);
|
||||
"%s [%s] [%s:%s]%s\n",
|
||||
LOG_LEVEL_NOTE[level], datetime, source_filename, line_str, log_buffer);
|
||||
fprintf(stdout, "%s", buffer);
|
||||
int log_fd = fileno((FILE *) log_fp);
|
||||
if (flock(log_fd, LOCK_EX) == 0) {
|
||||
|
@ -86,6 +86,9 @@ void run(struct config *_config, struct result *_result) {
|
||||
kill_pid(child_pid);
|
||||
ERROR_EXIT(WAIT_FAILED);
|
||||
}
|
||||
// get end time
|
||||
gettimeofday(&end, NULL);
|
||||
_result->real_time = (int) (end.tv_sec * 1000 + end.tv_usec / 1000 - start.tv_sec * 1000 - start.tv_usec / 1000);
|
||||
|
||||
// process exited, we may need to cancel timeout killer thread
|
||||
if (_config->max_real_time != UNLIMITED) {
|
||||
@ -99,10 +102,6 @@ void run(struct config *_config, struct result *_result) {
|
||||
resource_usage.ru_utime.tv_usec / 1000);
|
||||
_result->memory = resource_usage.ru_maxrss * 1024;
|
||||
|
||||
// get end time
|
||||
gettimeofday(&end, NULL);
|
||||
_result->real_time = (int) (end.tv_sec * 1000 + end.tv_usec / 1000 - start.tv_sec * 1000 - start.tv_usec / 1000);
|
||||
|
||||
if (_result->exit_code != 0) {
|
||||
_result->result = RUNTIME_ERROR;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -1,6 +1,4 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
sleep(4000);
|
||||
|
Loading…
Reference in New Issue
Block a user