~ubuntu-branches/ubuntu/precise/boinc/precise

« back to all changes in this revision

Viewing changes to sched/time_stats_log.cpp

Tags: 6.12.8+dfsg-1
* New upstream release.
* Simplified debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include "parse.h"
23
23
 
24
24
#include "sched_msgs.h"
 
25
#include "sched_config.h"
 
26
#include "sched_types.h"
25
27
 
26
28
#include "time_stats_log.h"
27
29
 
39
41
// The host has been authenticated, so write the stats.
40
42
// Use a directory hierarchy since there may be many hosts
41
43
//
42
 
void write_time_stats_log(SCHEDULER_REPLY& reply) {
43
 
    char dirname[256], filename[256];
 
44
void write_time_stats_log() {
 
45
    char filename[256];
 
46
    const char *dirname;
44
47
 
45
 
    int hostid = reply.host.id;
 
48
    int hostid = g_reply->host.id;
46
49
    int dirnum = hostid % 1000;
47
 
    sprintf(dirname, "../time_stats_log/%d", dirnum);
 
50
    dirname = config.project_path("time_stats_log/%d", dirnum);
48
51
    if (!is_dir(dirname)) {
49
52
        int retval = boinc_mkdir(dirname);
50
53
        if (retval) {
51
54
            log_messages.printf(MSG_CRITICAL,
52
55
                "Can't make time stats log dir %s: %d\n", dirname, retval
53
56
            );
54
 
            perror("mkdir");
 
57
            std::perror("mkdir");
55
58
            return;
56
59
        }
57
60
    }
58
 
    sprintf(filename, "../time_stats_log/%d/%d", dirnum, hostid);
 
61
    sprintf(filename, "%s/%d", dirname, hostid);
59
62
#ifndef _USING_FCGI_
60
63
    FILE* f = fopen(filename, "w");
61
64
#else
69
72
    }
70
73
    fputs(stats_buf, f);
71
74
    fclose(f);
 
75
    free(stats_buf);
 
76
    stats_buf = 0;
72
77
}
73
78
 
74
 
bool have_time_stats_log(SCHEDULER_REPLY& reply) {
75
 
    char filename[256];
76
 
 
77
 
    int hostid = reply.host.id;
 
79
bool have_time_stats_log() {
 
80
    int hostid = g_reply->host.id;
78
81
    int dirnum = hostid % 1000;
79
 
    sprintf(filename, "../time_stats_log/%d/%d", dirnum, hostid);
80
 
    return is_file(filename);
 
82
    return is_file(config.project_path("time_stats_log/%d/%d", dirnum, hostid));
81
83
}