Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into 1.8.7
Browse files Browse the repository at this point in the history
Conflicts:
	gems_list.txt
  • Loading branch information
brixen committed Mar 30, 2015
2 parents 9fd4421 + 3682bd3 commit be8cdcc
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 30 deletions.
8 changes: 4 additions & 4 deletions library/rubinius/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@
c.vm_variable "profiler.threshold", 1000000,
"The minimum number of nanoseconds a profiler node must have to be reported"

c.vm_variable "system.tmp", "$TMPDIR",
"Default temp/fallback directory for the process"

c.section "system" do |s|
s.vm_variable "tmp", "$TMPDIR",
"Default temp/fallback directory for the process"

s.vm_variable "fsapi.path", "$TMPDIR",
"Base directory of the Rubinius File System API files"

Expand All @@ -185,7 +185,7 @@
s.vm_variable "console.access", 0660,
"Permissions on the Rubinius Console files"

s.vm_variable "log", "/var/log/$PROGRAM_NAME.log",
s.vm_variable "log", "$TMPDIR/$USER-$PROGRAM_NAME.log",
"Logging facility to use: 'syslog', 'console', or path"

s.vm_variable "log.level", "warn",
Expand Down
3 changes: 1 addition & 2 deletions rakelib/blueprint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@

gcc.ldflags << "-lm"

if Rubinius::BUILD_CONFIG[:dtrace] #and
#Rubinius::BUILD_CONFIG[:os] =~ /freebsd(9|10)/
if Rubinius::BUILD_CONFIG[:dtrace]
gcc.ldflags << "-lelf"
gcc.ldflags << "vm/dtrace/probes.o"

Expand Down
43 changes: 20 additions & 23 deletions vm/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,34 +200,25 @@ namespace rubinius {
} else if(!config.system_log.value.compare("console")) {
utilities::logger::open(utilities::logger::eConsoleLogger, RBX_PROGRAM_NAME, level);
} else {
const char* place_holder = "$PROGRAM_NAME";
size_t index = config.system_log.value.find(place_holder);
const char* tmpdir = "$TMPDIR";
size_t index = config.system_log.value.find(tmpdir);

if(index != std::string::npos) {
config.system_log.value.replace(index, strlen(place_holder), RBX_PROGRAM_NAME);
config.system_log.value.replace(index, strlen(tmpdir), config.system_tmp);
}

int fd;
const char* program_name = "$PROGRAM_NAME";
index = config.system_log.value.find(program_name);

if((fd = open(config.system_log.value.c_str(), O_CREAT, 0644)) > 0) {
close(fd);
} else if(errno == EACCES) {
std::ostringstream path;

if(const char* s = strrchr(config.system_log.value.c_str(), '/')) {
path << (s + 1);
} else {
path << config.system_log.value.c_str();
}
if(index != std::string::npos) {
config.system_log.value.replace(index, strlen(program_name), RBX_PROGRAM_NAME);
}

config.system_log.value.assign(config.system_tmp.value + path.str());
const char* user = "$USER";
index = config.system_log.value.find(user);

if((fd = open(config.system_log.value.c_str(), O_CREAT, 0644)) > 0) {
close(fd);
} else {
std::cerr << RBX_PROGRAM_NAME << ": unable to open log: "
<< config.system_log.value.c_str() << std::endl;
}
if(index != std::string::npos) {
config.system_log.value.replace(index, strlen(user), shared->username);
}

utilities::logger::open(utilities::logger::eFileLogger,
Expand Down Expand Up @@ -320,6 +311,7 @@ namespace rubinius {
config_parser.update_configuration(config);

set_tmp_path();
set_username();
set_fsapi_path();
}

Expand All @@ -339,9 +331,14 @@ namespace rubinius {
}
}

void Environment::set_username() {
struct passwd *user_passwd = getpwuid(getuid());

shared->username.assign(user_passwd->pw_name);
}

void Environment::set_fsapi_path() {
std::ostringstream path;
struct passwd *user_passwd = getpwuid(getuid());

if(!config.system_fsapi_path.value.compare("$TMPDIR")) {
path << config.system_tmp.value;
Expand All @@ -352,7 +349,7 @@ namespace rubinius {
if(cpath[cpath.size() - 1] != '/') path << "/";
}

path << "rbx-" << user_passwd->pw_name << "-" << getpid();
path << "rbx-" << shared->username << "-" << getpid();

shared->fsapi_path.assign(path.str());

Expand Down
1 change: 1 addition & 0 deletions vm/environment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ namespace rubinius {
void load_string(std::string str);
void run_file(std::string path);
void set_tmp_path();
void set_username();
void set_fsapi_path();
void load_tool();
void run_from_filesystem();
Expand Down
1 change: 1 addition & 0 deletions vm/shared_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ namespace rubinius {
SymbolTable symbols;
LLVMState* llvm_state;
std::string fsapi_path;
std::string username;
uint32_t hash_seed;

public:
Expand Down
1 change: 1 addition & 0 deletions vm/signal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ namespace rubinius {
logger::fatal("--- end system info ---");

logger::fatal("--- begin rubinius info ---");
logger::fatal("user: %s", signal_thread_->shared().username.c_str());
logger::fatal("pid: %d", getpid());
logger::fatal("program name: %s", RBX_PROGRAM_NAME);
logger::fatal("version: %s", RBX_VERSION);
Expand Down
4 changes: 4 additions & 0 deletions vm/signal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ namespace rubinius {

SignalThread(STATE, Configuration& config);

SharedState& shared() {
return shared_;
}

void initialize(STATE);
void setup_default_handlers();

Expand Down
2 changes: 1 addition & 1 deletion vm/util/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ namespace rubinius {

#define LOGGER_MAX_FILE 5242880
#define LOGGER_OPEN_FLAGS (O_CREAT | O_APPEND | O_WRONLY | O_CLOEXEC)
#define LOGGER_OPEN_PERMS 0644
#define LOGGER_OPEN_PERMS 0600

FileLogger::FileLogger(const char* identifier)
: Logger()
Expand Down

0 comments on commit be8cdcc

Please sign in to comment.