Example #1
0
/**
 * Prints Microsoft specific error messages to log
 */
static void mserror(const char *str)
{
    char errbuf[300];
    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
                  0, errbuf, sizeof(errbuf), NULL);
    clog0(0, 0, 0, "%s: (0x%08X) %s", str, GetLastError(), errbuf);
}
Example #2
0
/**
 * Print the final statistics for the given file
 */
void print_status(const struct finfo_t *finfo, struct timeval start_time)
{
    struct timeval done_time;
    double elapsed_time;
    int i;

    if (sync_mode) {
        print_sync_status(finfo, start_time);
        return;
    }

    if (finfo->file_id == 0) {
        log0(0, 0, "Group complete");
        return;
    }

    log0(0, 0, "Transfer status:");
    for (done_time = start_time, i = 0; i < destcount; i++) {
        if (destlist[i].clientcnt >= 0) {
            continue;
        }
        clog0(0, 0, "Host: %-15s  Status: ", destlist[i].name);
        switch (destlist[i].status) {
        case DEST_MUTE:
            slog0("Mute");
            break;
        case DEST_LOST:
            slog0("Lost connection");
            break;
        case DEST_ABORT:
            slog0("Aborted");
            break;
        case DEST_DONE:
            if (destlist[i].comp_status == COMP_STAT_REJECTED) {
                slog0("Rejected");
                break;
            }
            if (diff_usec(finfo->deststate[i].time, done_time) > 0) {
                done_time = finfo->deststate[i].time;
            }
            elapsed_time = (double)diff_usec(finfo->deststate[i].time,
                                             start_time) / 1000000;
            slog0("Completed   time: %7.3f seconds    NAKs: %d",
                 elapsed_time, finfo->deststate[i].naks);
            break;
        default:
            slog0("Unknown  code: %d", destlist[i].status);
            break;
        }
    }
    elapsed_time = (double)diff_usec(done_time, start_time) / 1000000;
    log1(0, 0, "Total elapsed time: %.3f seconds", elapsed_time);
    log1(0, 0, "Overall throughput: %.2f KB/s",
               (elapsed_time != 0) ? (finfo->size / elapsed_time / 1024) : 0);
}
Example #3
0
/**
 * Print the final statistics for the given file while in sync mode
 */
void print_sync_status(const struct finfo_t *finfo, struct timeval start_time)
{
    double elapsed_time, throughput;
    int i;

    if (finfo->file_id == 0) {
        log0(0, 0, "- Status -");
        log0(0, 0, "HSTATS;target;copy;overwrite;"
                   "skip;totalMB;time;speedKB/s");
        for (i = 0; i < destcount; i++) {
            if (destlist[i].clientcnt >= 0) {
                continue;
            }
            if (destlist[i].total_time > 0) {
                throughput = destlist[i].total_size /
                             destlist[i].total_time / 1024;
            } else {
                throughput = 0;
            }
            log0(0, 0, "STATS;%s;%d;%d;%d;%sMB;%.3f;%.2fKB/s",
                    destlist[i].name, destlist[i].num_copy,
                    destlist[i].num_overwrite, destlist[i].num_skip,
                    printll(destlist[i].total_size / 1048576),
                    destlist[i].total_time,
                    throughput);
        }
        return;
    }

    for (i = 0; i < destcount; i++) {
        if (destlist[i].clientcnt >= 0) {
            continue;
        }
        clog0(0, 0, "RESULT;%s;%s;%sKB;", destlist[i].name,
                finfo->destfname, printll(finfo->size / 1024));
        switch (destlist[i].status) {
        case DEST_MUTE:
            slog0("mute;");
            break;
        case DEST_LOST:
            slog0("lost;");
            break;
        case DEST_ABORT:
            slog0("aborted;");
            break;
        case DEST_DONE:
            if (sync_preview) {
                throughput = rate / 8;
                elapsed_time = finfo->size / (throughput * 1024);
            } else {
                elapsed_time = (double)diff_usec(finfo->deststate[i].time,
                                                 start_time) / 1000000;
                if (elapsed_time > 0) {
                    throughput = finfo->size / elapsed_time / 1024;
                } else {
                    throughput = 0;
                }
            }
            switch (destlist[i].comp_status) {
            case COMP_STAT_NORMAL:
                slog0("copy;%.2fKB/s", throughput);
                destlist[i].num_copy++;
                destlist[i].total_time += elapsed_time;
                destlist[i].total_size += finfo->size;
                break;
            case COMP_STAT_SKIPPED:
                slog0("skipped;");
                destlist[i].num_skip++;
                break;
            case COMP_STAT_OVERWRITE:
                slog0("overwritten;%.2fKB/s", throughput);
                destlist[i].num_overwrite++;
                destlist[i].total_time += elapsed_time;
                destlist[i].total_size += finfo->size;
                break;
            case COMP_STAT_REJECTED:
                slog0("rejected;");
                break;
            default:
                slog0("Unknown;");
                break;
            }
            break;
        default:
            slog0("Unknown;");
            break;
        }
    }
}