Example #1
0
static VALUE
bdb_s_log_flush(int argc, VALUE *argv, VALUE obj)
{
    bdb_ENV *envst;

    if (argc == 0) {
	GetEnvDB(obj, envst);
#if HAVE_ST_DB_ENV_LG_INFO
	if (!envst->envp->lg_info) {
	    rb_raise(bdb_eFatal, "log region not open");
	}
	bdb_test_error(log_flush(envst->envp->lg_info, NULL));
#elif HAVE_ST_DB_ENV_LOG_FLUSH
	bdb_test_error(envst->envp->log_flush(envst->envp, NULL));
#else
	bdb_test_error(log_flush(envst->envp, NULL));
#endif
	return obj;
    }
    else if (argc == 1) {
	return bdb_s_log_put_internal(obj, argv[0], DB_FLUSH);
    }
    else {
	rb_raise(bdb_eFatal, "Invalid number of arguments");
    }
}
Example #2
0
int main( int argc, char *argv[] )
{
    Huint       j;
    Huint       self;
    register Huint start_time;
    register Huint end_time;

    log_create( &logbuf, LOOPS * 2 );
    for( j = 0; j < LOOPS; j++ )
    {
        start_time = timer_get_globallo();
        self = hthread_self();
        end_time = timer_get_globallo();
        
        logbuf.buffer[ logbuf.pos++ ] = start_time;
        logbuf.buffer[ logbuf.pos++ ] = end_time;
        
#ifdef PRINT
            //XExc_mDisableExceptions(XEXC_NON_CRITICAL);
            printf( "Self: %u\n", self );
            //XExc_mEnableExceptions(XEXC_NON_CRITICAL);
#endif
    }

    //XExc_mDisableExceptions(XEXC_NON_CRITICAL);
    printf( "Flushing %u timing values...\n", logbuf.pos );
    log_flush( &logbuf );
    //log_close( &logbuf );
	printf( "--DONE--\n" );
    //XExc_mEnableExceptions(XEXC_NON_CRITICAL);

	return 1;
}
Example #3
0
File: log.c Project: mideg/server
void log_info(const char *format, ...)
{
  const char * prefix = "INFO";
  const int mask = LOG_CPINFO;

  /* write to the logfile, always */
  if (logfile && (log_flags & mask)) {
    va_list args;
    va_start(args, format);
    _log_write(logfile, 0, prefix, format, args);
    va_end(args);
  }

  /* write to stderr, if that's not the logfile already */
  if (logfile!=stderr && (log_stderr & mask)) {
    int dupe = check_dupe(format, prefix);
    if (!dupe) {
      va_list args;
      va_start(args, format);
      _log_write(stderr, stdio_codepage, prefix, format, args);
      va_end(args);
    }
  }
  if (log_flags & LOG_FLUSH) {
    log_flush();
  }
}
Example #4
0
// ends
static void on_log_exit(int signo)
{
    log_flush();
    log_clear();
    redis_close(&redis);
    exit(0);
}
Example #5
0
File: log.c Project: mideg/server
void log_printf(FILE * io, const char *format, ...)
{
  const char * prefix = "INFO";
  const int mask = LOG_CPINFO;

  /* write to the logfile, always */
  if (logfile && (log_flags & mask)) {
    int codepage = (logfile==stderr || logfile==stdout) ? stdio_codepage : 0;
    va_list args;
    va_start(args, format);
    _log_write(logfile, codepage, prefix, format, args);
    va_end(args);
  }

  /* write to io, if that's not the logfile already */
  if (logfile!=io && (log_stderr & mask)) {
    int dupe = check_dupe(format, prefix);
    if (!dupe) {
      va_list args;
      va_start(args, format);
      _log_write(io, stdio_codepage, prefix, format, args);
      va_end(args);
    }
  }
  if (log_flags & LOG_FLUSH) {
    log_flush();
  }
}
Example #6
0
/**
 * Faehrt den Bot sauber herunter
 */
void ctbot_shutdown(void) {
	LOG_INFO("Shutting c't-Bot down...");

	motor_set(BOT_SPEED_STOP, BOT_SPEED_STOP);

#ifdef MAP_AVAILABLE
	map_flush_cache();
#endif

#ifdef LOG_MMC_AVAILABLE
	log_flush();
#endif

#ifdef BOT_FS_AVAILABLE
	botfs_close_volume();
#endif

#ifdef DISPLAY_AVAILABLE
	display_clear();
	display_cursor(1, 1);
	display_puts("SYSTEM HALTED.");
#endif // DISPLAY_AVAILABLE

	ENA_off(0xff);

	ctbot_shutdown_low();
}
Example #7
0
static void
log_change(struct log *this_)
{
	log_flush(this_);
	log_close(this_);
	log_open(this_);
}
Example #8
0
int log_open(void) {
    if(global_options.output_file) { /* 'output' option specified */
        outfile=file_open(global_options.output_file,
            global_options.log_file_mode);
#if defined(USE_WIN32) && !defined(_WIN32_WCE)
        if(!outfile) {
            char appdata[MAX_PATH], *path;
            if(SHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA|CSIDL_FLAG_CREATE,
                    NULL, 0, appdata)==S_OK) {
                path=str_printf("%s\\%s", appdata, global_options.output_file);
                outfile=file_open(path, global_options.log_file_mode);
                if(outfile)
                    s_log(LOG_NOTICE, "Logging to %s", path);
                str_free(path);
            }
        }
#endif
        if(!outfile) {
            s_log(LOG_ERR, "Cannot open log file: %s",
                global_options.output_file);
            return 1;
        }
    }
    log_flush(LOG_MODE_CONFIGURED);
    return 0;
}
Example #9
0
void coe_logMatrix( log_logLevel_t logLevel
                  , const coe_coefMatrix_t A
                  , unsigned int m
                  , unsigned int n
                  , const tbv_tableOfVariables_t * const pTableOfVars
                  )
{
    /* All logging is done at given level; we can take a shortcut if this verbosity is not
       desired. */
    if(!log_checkLogLevel(_log, logLevel))
        return;

    log_logLine(_log, logLevel, "The linear equation system (%u, %u):", m, n);

    unsigned int row;
    for(row=0; row<m; ++row)
    {
        LOG_DEBUG(_log, "  Row %u:", row);
        unsigned int col;
        for(col=0; col<n; ++col)
        {
            log_log(_log, logLevel, "    (%2d,%2d): ", row, col);
            coe_logCoefficient( A[row][col]
                              , pTableOfVars
                              , /* tabPos */ 13 + log_getLengthOfLineHeader(_log)
                              );
            log_log(_log, log_continueLine, "\n");
        }
    }

    log_flush(_log);

} /* End of coe_logMatrix */
Example #10
0
int interface_superblock(disk_t *disk_car,list_part_t *list_part, char**current_cmd)
{
  const list_part_t *parts;
  const partition_t *old_part=NULL;
#ifdef HAVE_NCURSES
  struct MenuItem menuSuperblock[]=
  {
    { 'P', "Previous",""},
    { 'N', "Next","" },
    { 'Q',"Quit","Return to Advanced menu"},
    { 0, NULL, NULL }
  };
#endif
  screen_buffer_reset();
#ifdef HAVE_NCURSES
  aff_copy(stdscr);
  wmove(stdscr,4,0);
  wprintw(stdscr,"%s",disk_car->description(disk_car));
  wmove(stdscr,5,0);
  mvwaddstr(stdscr,6,0,msg_PART_HEADER_LONG);
#endif
  for(parts=list_part;parts!=NULL;parts=parts->next)
  {
    const partition_t *partition=parts->part;
    if(old_part==NULL ||
      old_part->part_offset!=partition->part_offset ||
      old_part->part_size!=partition->part_size ||
      guid_cmp(old_part->part_type_gpt, partition->part_type_gpt)!=0	||
      old_part->part_type_i386!=partition->part_type_i386 	||
      old_part->part_type_sun!=partition->part_type_sun 	||
      old_part->part_type_mac!=partition->part_type_mac 	||
      old_part->upart_type!=partition->upart_type)
    {
      aff_part_buffer(AFF_PART_BASE, disk_car, partition);
      old_part=partition;
    }
    if(partition->blocksize!=0)
      screen_buffer_add("superblock %lu, blocksize=%u [%s]\n",
          (long unsigned)(partition->sb_offset/partition->blocksize),
          partition->blocksize, partition->fsname);
  }
  if(list_part!=NULL)
  {
    const partition_t *partition=list_part->part;
    screen_buffer_add("\n");
    screen_buffer_add("To repair the filesystem using alternate superblock, run\n");
    screen_buffer_add("fsck.ext%u -p -b superblock -B blocksize device\n",
	(partition->upart_type==UP_EXT2?2:
	 (partition->upart_type==UP_EXT3?3:4)));
  }
  screen_buffer_to_log();
  if(*current_cmd==NULL)
  {
    log_flush();
#ifdef HAVE_NCURSES
    screen_buffer_display(stdscr,"",menuSuperblock);
#endif
  }
  return 0;
}
Example #11
0
bool log_write(int level, const char *msg, ...) {
    char *p, *limit;
    int n;
    va_list val;

    if (log_filter >= level)
        return true;

    if (log_msg_lost) {
        log_msg_lost++;
        return false;
    }

    p= log_buffer + log_buf_pos;
    limit= log_buffer + sizeof(log_buffer);

    n= snprintf(p , limit - p, "%s: ", log_level_name(level));
    if (n >= limit - p) {
        log_msg_lost++;
        return false;
    }
    p+= n;
    va_start(val, msg);
    n= vsnprintf(p, limit - p, msg, val);
    va_end(val);
    if (n >= limit - p) {
        log_msg_lost++;
        return false;
    }
    p+= n;
    *p++ = '\n';
    log_buf_pos= p - log_buffer;
    log_flush();
    return true;
}
Example #12
0
void log_run() {
    if (log_fd < 0 && !log_fd_attach())
        return;

    // If logging failed last iteration, see if we're ready yet
    if (log_blocked) {
        // If we decided to try again on the writeable event, the bit will be set.
        if (woke_on_writeable_only(log_fd)
                || (log_blocked_next_attempt &&
                    (wake->now - log_blocked_next_attempt > 0)
                   )
           ) {
            log_blocked= false;
            log_blocked_next_attempt= 0;
            log_flush();
            // If that also failed, then we no longer trust our writeable-bit, and
            // set a clock-based timeout
            if (log_blocked) {
                log_blocked_next_attempt= wake->now + LOG_RETRY_DELAY;
                if (!log_blocked_next_attempt) log_blocked_next_attempt++;
            }
        }

        // If still blocked, set an appropriate wake event
        if (log_blocked) {
            if (log_blocked_next_attempt)
                wake_at_time(log_blocked_next_attempt);
            else
                // Don't also wake on fd_err, because we don't care.  Error is the same as
                // not-writable (blocked) for logging purposes.
                wake_on_writeable_only(log_fd);
        }
    }
}
Example #13
0
static void log_close() {
	log_flush();
	if (log_fd >= 0) {
		close(log_fd);
		log_fd = -1;
	}
}
Example #14
0
/* See the comment in recovery.h on how the "save" parameter is used */
void rec_done(int save)
{
	if (!rec_file)
		return;

/*
 * If we're the main process for a --fork'ed group of children, leave our .rec
 * file around until the children terminate (at which time we may be called
 * again with save < 0, meaning forced non-saving).
 */
	if (!save && options.fork && john_main_process) {
		rec_save();
		return;
	}

	if (save > 0)
		rec_save();
	else
		log_flush();

	if (fclose(rec_file))
		pexit("fclose");
	rec_file = NULL;

	if ((!save || save == -1) && unlink(path_expand(rec_name)))
		pexit("unlink: %s", path_expand(rec_name));
}
Example #15
0
void setup_loader(void) {
   // export function table
   mod_secondary = &table;
   // flush log first time
   log_flush();
   // minor print
   log_printf("i/o delay value: %d\n",IODelay);
}
Example #16
0
/**
 * Cleans up after a log statement by detecting whether the log is done,
 * (it ends in a newline) and possibly flushing the log.
 */
static void log_end(void)
{
   g_log.in_log = (g_log.buf[g_log.buf_len - 1] != '\n');
   if (!g_log.in_log || (g_log.buf_len > (int)(sizeof(g_log.buf) / 2)))
   {
      log_flush(false);
   }
}
Example #17
0
static void __log_close(void)
{
	if (log_daemon) {
		log_flush();
		closelog();
		free_logarea();
	}
}
Example #18
0
void
log_destroy(struct log *this_)
{
	if (this_->timer)
		g_source_remove(this_->timer);
	log_flush(this_);
	log_close(this_);
	g_free(this_);
}
Example #19
0
static void
log_change(struct log *this_)
{
	log_flush(this_);
	log_close(this_);
	expand_filenames(this_);
	if (! this_->lazy)
		log_open(this_);
}
Example #20
0
void main_cleanup() {
    unbind_ports();
    s_poll_free(fds);
    fds=NULL;
#if 0
    str_stats(); /* main thread allocation tracking */
#endif
    log_flush(LOG_MODE_ERROR);
}
Example #21
0
void
log_destroy(struct log *this_)
{
	callback_destroy(this_->timer_callback);
	event_remove_timeout(this_->timer);
	log_flush(this_);
	log_close(this_);
	g_free(this_);
}
Example #22
0
File: log.c Project: klopp/klib
/*
 * Destroy log info structure. Unsaved buffer will be saved.
 */
void log_destroy( LogInfo log )
{
    log_flush( log );
    Free( log->prefix );
    Free( log->file );
    Free( log->ibuf );
    Free( log->buf );
    Free( log );
}
Example #23
0
/* See the comment in recovery.h on how the "save" parameter is used */
void rec_done(int save)
{
	if (!rec_file)
		return;

/*
 * If we're the main process for a --fork'ed group of children, leave our .rec
 * file around until the children terminate (at which time we may be called
 * again with save < 0, meaning forced non-saving).
 */
#ifndef HAVE_MPI
	if (!save && options.fork && john_main_process) {
#else
	if (!save && (options.fork || mpi_p > 1) && john_main_process) {
#endif
		rec_save();
		return;
	}

	if (save > 0)
		rec_save();
	else
		log_flush();

	if (fclose(rec_file))
		pexit("fclose");
	rec_file = NULL;

	if ((!save || save == -1) && unlink(path_expand(rec_name)))
		pexit("unlink: %s", path_expand(rec_name));
}

static void rec_format_error(char *fn)
{
	path_done();
	cleanup_tiny_memory();

	/*
	 * MEMDBG_PROGRAM_EXIT_CHECKS() would cause the output
	 *     At Program Exit
	 *     MemDbg_Validate level 0 checking Passed
	 * to be writen prior to the
	 *     Incorrect crash recovery file: ...
	 * output.
	 * Not sure if we want this.
	 */
	// MEMDBG_PROGRAM_EXIT_CHECKS(stderr); // FIXME

	if (fn && errno && ferror(rec_file))
		pexit("%s", fn);
	else {
		fprintf(stderr, "Incorrect crash recovery file: %s\n",
			path_expand(rec_name));
		error();
	}
}
Example #24
0
void rec_save(void)
{
	int save_format;
	long size;
	char **opt;

	log_flush();

	if (!rec_file) return;

	if (fseek(rec_file, 0, SEEK_SET)) pexit("fseek");
#ifdef __CYGWIN32__
	if (ftruncate(rec_fd, 0)) pexit("ftruncate");
#endif

	save_format = !options.format && rec_db->loaded;

	fprintf(rec_file, RECOVERY_V "\n%d\n",
	    rec_argc + (save_format ? 1 : 0));

	opt = rec_argv;
	while (*++opt)
		fprintf(rec_file, "%s\n", *opt);

	if (save_format)
		fprintf(rec_file, "--format=%s\n",
		    rec_db->format->params.label);

	fprintf(rec_file, "%u\n%u\n%x\n%x\n%x\n%x\n%x\n%x\n%x\n"
	    "%d\n%d\n%d\n%x\n",
	    status_get_time() + 1,
	    status.guess_count,
	    status.combs.lo,
	    status.combs.hi,
	    status.combs_ehi,
	    status.crypts.lo,
	    status.crypts.hi,
	    status.cands.lo,
	    status.cands.hi,
	    status.compat,
	    status.pass,
	    status_get_progress ? status_get_progress() : -1,
	    rec_check);

	if (rec_save_mode) rec_save_mode(rec_file);

	if (ferror(rec_file)) pexit("fprintf");

	if ((size = ftell(rec_file)) < 0) pexit("ftell");
	if (fflush(rec_file)) pexit("fflush");
	if (ftruncate(rec_fd, size)) pexit("ftruncate");
#ifndef __CYGWIN32__
	if (!options.fork && fsync(rec_fd))
		pexit("fsync");
#endif
}
Example #25
0
void signal_hup_handler(int signum)
{
    LOG_INFO0("Flushing logs");
    log_flush(ices_config->log_id);

    /* Now, let's tell it to move to the next track */
    ices_config->inmod->handle_event(ices_config->inmod,EVENT_NEXTTRACK,NULL);

    signal(SIGHUP, signal_hup_handler);
}
Example #26
0
static void log_data (int c)
{
	if (isprint (c))
		logptr += sprintf (logptr, "%c", c);
	else if (c != 0x80)
		logptr += sprintf (logptr, ".");

	if (logcnt++ > 100)
		log_flush ();
}
Example #27
0
static VALUE
bdb_lsn_log_flush(VALUE obj)
{
    struct dblsnst *lsnst;
    bdb_ENV *envst;

    GetLsn(obj, lsnst, envst);
#if HAVE_ST_DB_ENV_LG_INFO
    if (!envst->envp->lg_info) {
	rb_raise(bdb_eFatal, "log region not open");
    }
    bdb_test_error(log_flush(envst->envp->lg_info, lsnst->lsn));
#elif HAVE_ST_DB_ENV_LOG_FLUSH
    bdb_test_error(envst->envp->log_flush(envst->envp, lsnst->lsn));
#else
    bdb_test_error(log_flush(envst->envp, lsnst->lsn));
#endif
    return obj;
}
Example #28
0
static void john_wait(void)
{
	int waiting_for = john_child_count;

	log_event("Waiting for %d child%s to terminate",
	    waiting_for, waiting_for == 1 ? "" : "ren");
	log_flush();
	fprintf(stderr, "Waiting for %d child%s to terminate\n",
	    waiting_for, waiting_for == 1 ? "" : "ren");

	log_flush();

	/* Tell our friends there is nothing more to crack! */
	if (!database.password_count && !options.reload_at_crack &&
	    cfg_get_bool(SECTION_OPTIONS, NULL, "ReloadAtDone", 0))
		raise(SIGUSR2);

/*
 * Although we may block on wait(2), we still have signal handlers and a timer
 * in place, so we're relaying keypresses to child processes via signals.
 */
	while (waiting_for) {
		int i, status;
		int pid = wait(&status);
		if (pid == -1) {
			if (errno != EINTR)
				perror("wait");
		} else
		for (i = 0; i < john_child_count; i++) {
			if (john_child_pids[i] == pid) {
				john_child_pids[i] = 0;
				waiting_for--;
				children_ok = children_ok &&
				    WIFEXITED(status) && !WEXITSTATUS(status);
				break;
			}
		}
	}

/* Close and possibly remove our .rec file now */
	rec_done((children_ok && !event_abort) ? -1 : -2);
}
Example #29
0
struct jx * jx_database_remove( struct jx_database *db, const char *key )
{
	const char *nkey = strdup(key);

	struct jx *j = hash_table_remove(db->table,key);
	if(db->logdir && j) {
		log_delete(db,nkey);
		log_flush(db);
	}
	return j;
}
Example #30
0
static void sighup_hdlr(int sig)
{
  if(sig == SIGINT)
    log_critical("SIGINT detected! PhotoRec has been killed.\n");
  else
    log_critical("SIGHUP detected! PhotoRec has been killed.\n");
  log_flush();
  action.sa_handler=SIG_DFL;
  sigaction(sig,&action,NULL);
  kill(0, sig);
}