~ubuntu-branches/ubuntu/utopic/mariadb-5.5/utopic-security

« back to all changes in this revision

Viewing changes to storage/tokudb/ft-index/portability/file.cc

  • Committer: Package Import Robot
  • Author(s): Otto Kekäläinen
  • Date: 2014-04-17 20:55:22 UTC
  • mfrom: (2.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20140417205522-wof4l36nxhlkn89m
* New upstream release, fixing the following security issues:
  * Corresponding MariaDB CVEs for Oracle SPU April 2014 (Closes: #745330)
    - CVE-2014-0384 
    - CVE-2014-2419 
    - CVE-2014-2430 
    - CVE-2014-2431 
    - CVE-2014-2432 
    - CVE-2014-2436 
    - CVE-2014-2438 
    - CVE-2014-2440
* Re-enabled TokuDB with "if arch amd64" in d/rules
* Applied patch to log init output better
  (Closes https://mariadb.atlassian.net/browse/MDEV-5957)

Show diffs side-by-side

added added

removed removed

Lines of Context:
449
449
static uint64_t toku_long_fsync_threshold = 1000000;
450
450
static uint64_t toku_long_fsync_count;
451
451
static uint64_t toku_long_fsync_time;
 
452
static uint64_t toku_long_fsync_eintr_count;
 
453
static int toku_fsync_debug = 0;
452
454
 
453
455
void toku_set_func_fsync(int (*fsync_function)(int)) {
454
456
    t_fsync = fsync_function;
458
460
static void file_fsync_internal (int fd) {
459
461
    uint64_t tstart = toku_current_time_microsec();
460
462
    int r = -1;
 
463
    uint64_t eintr_count = 0;
461
464
    while (r != 0) {
462
465
        if (t_fsync) {
463
466
            r = t_fsync(fd);
466
469
        }
467
470
        if (r) {
468
471
            assert(get_error_errno() == EINTR);
 
472
            eintr_count++;
469
473
        }
470
474
    }
471
475
    toku_sync_fetch_and_add(&toku_fsync_count, 1);
474
478
    if (duration >= toku_long_fsync_threshold) {
475
479
        toku_sync_fetch_and_add(&toku_long_fsync_count, 1);
476
480
        toku_sync_fetch_and_add(&toku_long_fsync_time, duration);
 
481
        toku_sync_fetch_and_add(&toku_long_fsync_eintr_count, eintr_count);
 
482
        if (toku_fsync_debug) {
 
483
            const int tstr_length = 26;
 
484
            char tstr[tstr_length];
 
485
            time_t t = time(0);
 
486
#if __linux__
 
487
            char fdname[256];
 
488
            snprintf(fdname, sizeof fdname, "/proc/%d/fd/%d", getpid(), fd);
 
489
            char lname[256];
 
490
            ssize_t s = readlink(fdname, lname, sizeof lname);
 
491
            if (0 < s && s < (ssize_t) sizeof lname)
 
492
                lname[s] = 0;
 
493
            fprintf(stderr, "%.24s toku_file_fsync %s fd=%d %s duration=%" PRIu64 " usec eintr=%" PRIu64 "\n", 
 
494
                    ctime_r(&t, tstr), __FUNCTION__, fd, s > 0 ? lname : "?", duration, eintr_count);
 
495
#else
 
496
            fprintf(stderr, "%.24s toku_file_fsync  %s fd=%d duration=%" PRIu64 " usec eintr=%" PRIu64 "\n", 
 
497
                    ctime_r(&t, tstr), __FUNCTION__, fd, duration, eintr_count);
 
498
#endif
 
499
            fflush(stderr);
 
500
        }
477
501
    }
478
502
}
479
503