Example #1
0
void initializeLibrary(ToolType Tool) {
  // We assume there is only one thread during init.
  if (EsanIsInitialized) {
    CHECK(Tool == WhichTool);
    return;
  }
  WhichTool = Tool;
  SanitizerToolName = "EfficiencySanitizer";
  initializeFlags();

  // Intercepting libc _exit or exit via COMMON_INTERCEPTOR_ON_EXIT only
  // finalizes on an explicit exit call by the app.  To handle a normal
  // exit we register an atexit handler.
  ::__cxa_atexit((void (*)())finalizeLibrary);

  VPrintf(1, "in esan::%s\n", __FUNCTION__);
  if (WhichTool != ESAN_CacheFrag) {
    Printf("ERROR: unknown tool %d requested\n", WhichTool);
    Die();
  }

  initializeInterceptors();

  EsanIsInitialized = true;
}
Example #2
0
int main(int argc, char *argv[])
{
    CCoreThread *core;

    appStartMs = Utils::getCurrentMs();
    
    initializeFlags();                                          // initialize flags 
    Debug::setDefaultLogFile();
    loadDefaultArgumentsFromFile();                             // first parse default arguments from file
    loadLastHwConfig();                                         // load last found HW IF, HW version, SCSI machine
    
    printf("CosmosEx preinit app starting...\n");
    //------------------------------------
    if(signal(SIGINT, sigint_handler) == SIG_ERR) {		    // register SIGINT handler
        printf("Cannot register SIGINT handler!\n");
    }

    if(signal(SIGHUP, sigint_handler) == SIG_ERR) {		    // register SIGHUP handler
        printf("Cannot register SIGHUP handler!\n");
    }

    //------------------------------------
    // normal app run follows
    Debug::printfLogLevelString();

    char appVersion[16];
    Version::getAppVersion(appVersion);
    
    Debug::out(LOG_INFO, "\n\n---------------------------------------------------");
    Debug::out(LOG_INFO, "CosmosEx preinit starting, version: %s", appVersion);

//	system("sudo echo none > /sys/class/leds/led0/trigger");	    // disable usage of GPIO 23 (pin 16) by LED

	if(!gpio_open()) {									            // try to open GPIO and SPI on RPi
		return 0;
	}

    //-------------
    // Copy the configdrive to /tmp so we can change the content as needed.
    // This must be done before new CCoreThread because it reads the data from /tmp/configdrive 
    system("rm -rf /tmp/configdrive");                      // remove any old content
    system("mkdir /tmp/configdrive");                       // create dir
    system("cp -r /ce/app/configdrive/* /tmp/configdrive"); // copy new content
    //-------------
    core = new CCoreThread();
    
	core->run();										// run the main thread

	delete core;
	gpio_close();										// close gpio and spi

    Debug::out(LOG_INFO, "CosmosEx preinit terminated.");
    printf("Preinit terminated\n");
    return 0;
}
Example #3
0
void
Controller::onRequestBegin(Client *client, Request *req) {
	ParentClass::onRequestBegin(client, req);

	CC_BENCHMARK_POINT(client, req, BM_AFTER_ACCEPT);

	{
		// Perform hash table operations as close to header parsing as possible,
		// and localize them as much as possible, for better CPU caching.
		RequestAnalysis analysis;
		analysis.flags = req->secureHeaders.lookup(FLAGS);
		analysis.appGroupNameCell = req->config->singleAppMode
			? NULL
			: req->secureHeaders.lookupCell(PASSENGER_APP_GROUP_NAME);
		analysis.unionStationSupport = unionStationContext != NULL
			&& getBoolOption(req, UNION_STATION_SUPPORT, false);
		req->stickySession = getBoolOption(req, PASSENGER_STICKY_SESSIONS,
			mainConfig.stickySessions);
		req->showVersionInHeader = getBoolOption(req, PASSENGER_SHOW_VERSION_IN_HEADER,
			req->config->showVersionInHeader);
		req->host = req->headers.lookup(HTTP_HOST);

		/***************/
		/***************/

		SKC_TRACE(client, 2, "Initiating request");
		req->startedAt = ev_now(getLoop());
		req->bodyChannel.stop();

		initializeFlags(client, req, analysis);
		if (respondFromTurboCache(client, req)) {
			return;
		}
		initializePoolOptions(client, req, analysis);
		if (req->ended()) {
			return;
		}
		initializeUnionStation(client, req, analysis);
		if (req->ended()) {
			return;
		}
		setStickySessionId(client, req);
	}

	if (!req->hasBody() || !req->requestBodyBuffering) {
		req->requestBodyBuffering = false;
		checkoutSession(client, req);
	} else {
		beginBufferingBody(client, req);
	}
}