Exemplo n.º 1
0
static void handler(int sig) {
	switch (sig) {
	case SIGTERM:
		__debug("Caught SIGTERM: Scheduling a shutdown");
		if (stopping == 1)
			__error("Shutdown or reload already scheduled");
		else
			stopping = 1;
		break;
	case SIGINT:
		__debug("Caught SIGINT: Scheduling a shutdown");
		if (stopping == 1)
			__error("Shutdown or reload already scheduled");
		else
			stopping = 1;
		break;
	case SIGHUP:
		__debug("Caught SIGHUP: Scheduling a reload");
		if (stopping == 1)
			__error("Shutdown or reload already scheduled");
		else
			stopping = 1, doreload = 1;
		break;
	default:
		__debug("Caught unknown signal %d", sig);
		break;
	}
}
static int wait_child(euca_opts * args, int pid)
{
    time_t timer = 0;
    int rc = 0, status;
    get_timestamp(ts_buff,sizeof(ts_buff));
    fprintf(stderr, "%s INFO Waiting for process to respond to signal.",ts_buff);
    while (rc <= 0 && timer < 5) {
        usleep(1000000), fprintf(stderr, "."), fflush(stderr);
        if ((rc = waitpid(pid, &status, WNOHANG)) == -1) {
            __debug("Error waiting for child: pid=%d waitpid=%d status=%d", pid, rc, status);
            return errno != ECHILD;
        } else if (rc == pid) {
            if (WIFEXITED(status)) {
                __debug("command terminated with exit status pid=%d waitpid=%d status=%d", pid, rc, WEXITSTATUS(status));
                return WEXITSTATUS(status);
            } else if (WIFSIGNALED(status)) {
                __debug("command terminated by signal pid=%d waitpid=%d status=%d", pid, rc, WTERMSIG(status));
                return WTERMSIG(status);
            } else {
                __debug("command terminated pid=%d waitpid=%d status=%d", pid, rc, status);
                return status;
            }
        } else {
            timer++;
            continue;
        }
    }
    if (rc == 0 && status == 0) {
        fprintf(stderr, "\n");
        return 0;
    } else {
        __error("Failed to signal child process pid=%d waitpid=%d status=%d", pid, rc, status);
        return 1;
    }
}
static int child( euca_opts *args, java_home_t *data, uid_t uid, gid_t gid ) {
	int ret = 0;
    jboolean r=0;
	__write_pid( GETARG(args,pidfile) );
	setpgrp( );
	__die(java_init( args, data ) != 1, "Failed to initialize Eucalyptus.");
    __die((r=(*env)->CallBooleanMethod(env,bootstrap.instance,bootstrap.init))==0,"Failed to init Eucalyptus.");
	__abort(4, set_keys_ownership( GETARG( args, home ), uid, gid ) != 0,"Setting ownership of keyfile failed." );
	__abort(4, linuxset_user_group( GETARG( args, user ), uid, gid ) != 0,"Setting the user failed." );
	__abort(4, (set_caps(0)!=0), "set_caps (0) failed");
    __die((r=(*env)->CallBooleanMethod(env,bootstrap.instance,bootstrap.load))==0,"Failed to load Eucalyptus.");
    __die((r=(*env)->CallBooleanMethod(env,bootstrap.instance,bootstrap.start))==0,"Failed to start Eucalyptus.");
	handle._hup = signal_set( SIGHUP, handler );
	handle._term = signal_set( SIGTERM, handler );
	handle._int = signal_set( SIGINT, handler );
	child_pid = getpid( );
	__debug( "Waiting for a signal to be delivered" );
	while( !stopping ) sleep( 60 );
	__debug( "Shutdown or reload requested: exiting" );
    __die((r=(*env)->CallBooleanMethod(env,bootstrap.instance,bootstrap.stop))==0,"Failed to stop Eucalyptus.");
	if( doreload == 1 ) ret = EUCA_RET_RELOAD;
	else ret = 0;
    __die((r=(*env)->CallBooleanMethod(env,bootstrap.instance,bootstrap.destroy))==0,"Failed to destroy Eucalyptus.");
	__die((JVM_destroy( ret ) != 1), "Failed trying to destroy JVM... bailing out seems like the right thing to do" );
	return ret;
}
Exemplo n.º 4
0
static void shutdown(JNIEnv *env, jobject source, jboolean reload) {
	__debug("Shutdown requested (reload is %d)", reload);
	if (reload == 1)
		__debug("Killing self with HUP signal: %d", kill(child_pid, SIGHUP));
	else
		__debug("Killing self with TERM signal: %d", kill(child_pid, SIGTERM));
}
Exemplo n.º 5
0
static int create_initial_commit(git_repository *repo)
{
	git_signature *sign;
	git_index *index;
	git_oid tree_id, commit_id;
	git_tree *tree;
	int rc;

	git_signature_now(&sign, sign_name, sign_email);

	rc = git_repository_index(&index, repo);
	if (rc)
		__debug("could not open repository index");

	rc = git_index_write_tree(&tree_id, index);
	if (rc)
		__debug("unable to write initial tree from index");

	git_index_free(index);

	rc = git_tree_lookup(&tree, repo, &tree_id);
	if (rc)
		__debug("could not look up initial tree");

	rc = git_commit_create_v(&commit_id, repo, "HEAD", sign, sign, NULL, "Initial commit", tree, 0);
	if (rc)
		__debug("could not create the initial commit");

	git_tree_free(tree);
	git_signature_free(sign);

	return rc;
}
static java_home_t *get_java_home( char *path ) {
	java_home_t *data = NULL;
	char buf[ 1024 ];
	int x = -1, k = 0, i = 0;

	if( path == NULL ) return NULL;
	__debug( "Looking for libjvm in %s", path );
	__abort(NULL, (CHECK_ISDIR( path ) == 0 ),"Path %s is not a directory", path );
	data = (java_home_t *) malloc( sizeof(java_home_t) );
	data->path = strdup( path );
	data->jvms = NULL;
	data->jnum = 0;
	while( libjvm_paths[ ++x ] != NULL ) {
		__abort(NULL, ((k = snprintf( buf, 1024, libjvm_paths[ x ], path ) ) <= 0 ),"Error mangling jvm path" );
		__debug( "Attempting to locate VM library %s", buf );
		if( CHECK_ISREG( buf ) == 1 ) {
			data->jvms = (jvm_info_t **) malloc( 2 * sizeof(jvm_info_t *) );
			data->jvms[ i ] = (jvm_info_t *) malloc( sizeof(jvm_info_t) );
			data->jvms[ i ]->libjvm_path = strdup( buf );
			char *dir, *base;
			dir = dirname(buf);
			base = basename(dir);
			data->jvms[ i ]->name = base;
			data->jvms[ ++i ] = NULL;
			data->jnum = i;
			return data;
		}
	}
	return data;
}
Exemplo n.º 7
0
uint8_t fsmanInit(uint8_t * result_code, uint8_t* buffer){
    
    struct tm ts;
    
    fsbuf =  buffer;
    RTC_GetTimeDateDecimal(&ts);
    SetClockVars (ts.tm_year, ts.tm_mon, ts.tm_mday, ts.tm_hour, ts.tm_min, ts.tm_sec);
    
    fsmanInitHardwareSD();
    if (!fsmanMountSD(result_code)){
        
        *result_code = UNKNOWN_SD_MOUNT_ERROR;//from FILEIO_ERROR_TYPE
        return 0;
    }

    //Create a VI_LOG directory if there isnt already one

    if(FSchdir("VI_LOG") != CE_GOOD){
        __debug("VI_LOG Directory was not found, creating it");    
        if(FSmkdir(".\\VI_LOG") != CE_GOOD){
            __debug("Unable to create a VI_LOG directory");
             *result_code = UNKNOWN_WRITE_ERROR;
            return 0;
        }
        else{
            if(FSchdir ("VI_LOG") != CE_GOOD){
                *result_code = UNKNOWN_WRITE_ERROR;
                __debug("VI_LOG Directory was created but not found");
                return 0;
            }
        }
    }
    return 1;
}
void euca_load_bootstrapper(void) {
    __die((bootstrap.class_name=((*env)->NewStringUTF(env,EUCA_MAIN)))==NULL,"Cannot create string for class name.");
    __die((bootstrap.clazz=((*env)->FindClass(env,EUCA_MAIN)))==NULL,"Cannot find Eucalyptus bootstrapper: %s.",EUCA_MAIN);
    __debug("Found Eucalyptus bootstrapper: %s",EUCA_MAIN);
    __die((bootstrap.class_ref = (*env)->NewGlobalRef(env, bootstrap.clazz))==NULL,"Cannot create global ref for %s.",EUCA_MAIN);

    JNINativeMethod shutdown_method = { "shutdown","(Z)V",shutdown };
    __die((*env)->RegisterNatives(env,bootstrap.clazz,&shutdown_method,1)!=0,"Cannot register native method: shutdown.");
    JNINativeMethod hello_method = { "hello","()V",hello };
    __die((*env)->RegisterNatives(env,bootstrap.clazz,&hello_method,1)!=0,"Cannot register native method: hello.");
    __debug("Native methods registered.");

    __die((bootstrap.constructor=(*env)->GetStaticMethodID(env, bootstrap.clazz,euca_get_instance.method_name, euca_get_instance.method_signature))==NULL,"Failed to get reference to default constructor.");
    __die((bootstrap.instance=(*env)->CallStaticObjectMethod(env,bootstrap.clazz,bootstrap.constructor))==NULL,"Failed to create instance of bootstrapper.");
    __debug("Created bootstrapper instance.");//TODO: fix all these error messages..
    __die((bootstrap.init=(*env)->GetMethodID(env,bootstrap.clazz,euca_init.method_name,euca_init.method_signature))==NULL,"Failed to get method reference for load.");
    __debug("-> bound method: init");
    __die((bootstrap.load=(*env)->GetMethodID(env,bootstrap.clazz,euca_load.method_name,euca_load.method_signature))==NULL,"Failed to get method reference for load.");
    __debug("-> bound method: load");
    __die((bootstrap.start=(*env)->GetMethodID(env,bootstrap.clazz,euca_start.method_name,euca_start.method_signature))==NULL,"Failed to get method reference for start.");
    __debug("-> bound method: start");
    __die((bootstrap.stop=(*env)->GetMethodID(env,bootstrap.clazz,euca_stop.method_name,euca_stop.method_signature))==NULL,"Failed to get method reference for stop.");
    __debug("-> bound method: stop");
    __die((bootstrap.destroy=(*env)->GetMethodID(env,bootstrap.clazz,euca_destroy.method_name,euca_destroy.method_signature))==NULL,"Failed to get method reference for destroy.");
    __debug("-> bound method: destroy");
    __die((bootstrap.check=(*env)->GetMethodID(env,bootstrap.clazz,euca_check.method_name,euca_check.method_signature))==NULL,"Failed to get method reference for check.");
    __debug("-> bound method: check");
    __die((bootstrap.version=(*env)->GetMethodID(env,bootstrap.clazz,euca_version.method_name,euca_version.method_signature))==NULL,"Failed to get method reference for version.");
    __debug("-> bound method: version");
}
Exemplo n.º 9
0
uint8_t fsmanFormat(void){

    __debug("Formatting Drive");
    uint8_t res =  FSformat (0, 0, "OPENXC");
    __debug("Formatting Complete %d",res);
    if(res == CE_GOOD)
        return 1;
    
    return 0;
}
int JVM_destroy(int code) {
    jclass system;
    jmethodID method;
    __die((system=(*env)->FindClass(env,"java/lang/System"))==NULL,"Cannot find class java/lang/System.");
    __die((method=(*env)->GetStaticMethodID(env,system,"exit","(I)V"))==NULL,"Cannot find \"System.exit(int)\" entry point.");
    __debug("Calling System.exit(%d)",code);
    (*env)->CallStaticVoidMethod(env,system,method,(jint)code);
    if ((*jvm)->DestroyJavaVM(jvm)!=0) return 0;
    __debug("JVM destroyed.");
    return 1;
}
static void controller( int sig ) {
	switch( sig ) {
	case SIGTERM:
	case SIGINT:
	case SIGHUP:
		__debug( "Forwarding signal %d to process %d", sig, child_pid );
		kill( child_pid, sig );
		signal( sig, controller );
		break;
	default:
		__debug( "Caught unknown signal %d", sig );
		break;
	}
}
Exemplo n.º 12
0
static int s3_do_check ( char * const signature, 
		       char * const date, char * const resource )
{
  char Buf[1024];

  CURL* ch =  curl_easy_init( );
  struct curl_slist *slist=NULL;
 
  snprintf ( Buf, sizeof(Buf), "Date: %s", date );
  slist = curl_slist_append(slist, Buf );
  snprintf ( Buf, sizeof(Buf), "Authorization: AWS %s:%s", awsKeyID, signature );
  slist = curl_slist_append(slist, Buf ); 

  snprintf ( Buf, sizeof(Buf), "http://%s/%s", S3Host, resource );
  curl_easy_setopt ( ch, CURLOPT_HTTPHEADER, slist);
  curl_easy_setopt ( ch, CURLOPT_URL, Buf );
  curl_easy_setopt(ch, CURLOPT_NOBODY, 1);

  CURLcode  sc  = curl_easy_perform(ch);
  /** \todo check the return code  */
  __debug ( "Return Code: %d ", sc );
  long response_code;
  curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &response_code);
  curl_slist_free_all(slist);
  curl_easy_cleanup(ch);
  if(response_code == 200){
	printf("FILE EXISTS\n");
	return 1;
  }
  else{
	printf("FILE DOES NOT EXIST\n");
	return 0;
  }
}
Exemplo n.º 13
0
uint8_t fsmanSessionStart(uint8_t * result_code){
    //open file here
    char file_name[25];
    struct tm ts;
    
    uint32_t tm_code;
    
    tm_code =  (uint32_t)RTC_GetTimeDateUnix();
    
    RTC_GetTimeDateDecimal(&ts);
    
    SetClockVars (ts.tm_year, ts.tm_mon, ts.tm_mday, ts.tm_hour, ts.tm_min, ts.tm_sec);
    
    sprintf(file_name,"%X.TXT", tm_code);
                            
    __debug("Creating %s",file_name);
    
    file = FSfopen (file_name,"w");
    
    if (file == NULL){
        *result_code = UNKNOWN_WRITE_ERROR;
        return FALSE;
    }
    return TRUE;
}
Exemplo n.º 14
0
/// Handles sending of the data
/// \param ptr pointer to the incoming data
/// \param size size of the data member
/// \param nmemb number of data memebers
/// \param stream pointer to I/O buffer
/// \return number of bytes written
static size_t readfunc ( void * ptr, size_t size, size_t nmemb, void * stream )
{
  char * Ln = ptr;
  int sz = aws_iobuf_getline ( stream, ptr, size*nmemb);
  __debug ( "Sent[%3d] %s", sz, Ln );
  return sz;
}
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
static void usb_detect_irq_handler(void *p_arg)
{
	pusb_struct pusb = &awxx_usb[0];
	__u32 temp;

	temp = usb_get_bus_interrupt_status(pusb);
	usb_clear_bus_interrupt_status(pusb, temp);
    __debug("%s,temp=%x\n",__FUNCTION__,temp);
	if(temp & 0x04) //reset babble detected,set to usb pc
	{   
		usb_clock_exit();
		wBoot_DisableInt(awxx_usb[0].irq_no);

		power_ops_int_status |= 0x08;
		wBoot_timer_stop(tmr_hd);
		wBoot_timer_release(tmr_hd);
		tmr_hd = NULL;
        __inf("usb set pc\n");
		//power_set_usbpc();

		usb_working = 0;
	}

	return;
}
Exemplo n.º 16
0
void IfxCpu_Trap_internalProtectionError(uint32 tin)
{
    trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_internalProtection, tin);
    IFX_CFG_CPU_TRAP_TSR_HOOK(trapWatch);
    __debug();
    __asm("rfe");
}
char *java_library(euca_opts *args, java_home_t *data) {
    char *libjvm_path=NULL;
    int x;
    if (data->jnum==0) {
        __error("Cannot find any VM in Java Home %s",data->path);
		exit(1);
    }
    if (args->jvm_name_given==0) {
    	libjvm_path=data->jvms[0]->libjvm_path;
    } else {
        for (x=0; x<data->jnum; x++) {
            if (data->jvms[x]->name==NULL) continue;
            if (strcmp(GETARG(args,jvm_name),data->jvms[x]->name)==0) {
            	libjvm_path=data->jvms[x]->libjvm_path;
                break;
            }
        }
    }
    if (libjvm_path==NULL) {
        __error("Failed to locate usable JVM %s %s",GETARG(args,jvm_name),libjvm_path);
        exit(1);
    }
    __debug("Using libjvm.so in %s",libjvm_path);
    return libjvm_path;
}
Exemplo n.º 18
0
void IfxCpu_Trap_nonMaskableInterrupt(uint32 tin)
{
    trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_nonMaskableInterrupt, tin);
    IFX_CFG_CPU_TRAP_TSR_HOOK(trapWatch);
    __debug();
    __asm("rfe");
}
Exemplo n.º 19
0
void IfxCpu_Trap_memoryManagementError(uint32 tin)
{
    trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_memoryManagement, tin);
    IFX_CFG_CPU_TRAP_TSR_HOOK(trapWatch);
    __debug();
    __asm("rfe");
}
Exemplo n.º 20
0
void IfxCpu_Trap_assertion(uint32 tin)
{
    trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_assertion, tin);
    IFX_CFG_CPU_TRAP_TSR_HOOK(trapWatch);
    __debug();
    __asm("rfe");
}
Exemplo n.º 21
0
/// Internal function to get configuration file
static FILE * __aws_getcfg ()
{
  int rv;
  char ConfigFile[256];
  /// Compose FileName and check
  snprintf ( ConfigFile, sizeof(ConfigFile) - 3, "%s/.awsAuth",
	     getenv("HOME"));
  __debug ( "Config File %s", ConfigFile );

  struct stat sBuf;
  rv = stat ( ConfigFile, &sBuf );
  if ( rv == -1 ) return NULL;

  
  if ( sBuf.st_mode & 066   ||
       sBuf.st_uid != getuid () )
    {
      fprintf ( stderr, "I refuse to read your credentials from %s as this "
	       "file is readable by, writable by or owned by someone else."
		"Try chmod 600 %s", ConfigFile, ConfigFile );
      return NULL;
    }

  return fopen ( ConfigFile, "r" );
}
Exemplo n.º 22
0
static void check_error(int error_code, const char *action)
{
	const git_error *error = giterr_last();
	if (!error_code)
		return;

	__debug("Error %d %s - %s\n", error_code, action, (error && error->message) ? error->message : "???");
}
Exemplo n.º 23
0
int ArchivePanel::OnReportError(ReportErrorStruct* pRE)
{
	__debug(_T("Error - %s, %d"), _T("filename"), pRE->nError);

//	m_OS.ErrorList.AddError(pRE->pItem->lpFileName);

	return 0;
}
Exemplo n.º 24
0
void TestDeformer::__debugMeshInfo(const char* msg, MObject &meshMobj)
{
#ifdef _DEBUG

        MStatus status;

        MFnMesh fnMesh(meshMobj, &status);
        CHECK_MSTATUS(status);

        __debug("%s(), fnMesh.fullPathName=%s", msg, fnMesh.fullPathName().asChar());
        __debug("%s(), fnMesh.name=%s", msg, fnMesh.name().asChar());

        MDagPath path; CHECK_MSTATUS(fnMesh.getPath(path));
        __debug("%s(), path=%s", msg, path.fullPathName().asChar());

        MDagPath dagpath = fnMesh.dagPath(&status); CHECK_MSTATUS(status);
        __debug("%s(), dagpath=%s", msg, dagpath.fullPathName().asChar());

        MFnDependencyNode fnDNode(meshMobj, &status); CHECK_MSTATUS(status);//
        __debug("%s(), name=%s", msg, fnDNode.name().asChar());

        MFnDagNode fnDagNode(meshMobj, &status);
        CHECK_MSTATUS(status);//

        MDagPath path2; CHECK_MSTATUS(fnDagNode.getPath(path2));//
        __debug("%s(), path2=%s", msg, path2.fullPathName().asChar());

        MDagPath dagpath2 = fnDagNode.dagPath(&status); CHECK_MSTATUS(status);//
        __debug("%s(), dagpath2=%s", msg, dagpath2.fullPathName().asChar());
#endif
}
Exemplo n.º 25
0
 static void test() {
   __trace() << "trace message";
   __debug() << "debug message";
   __info() << "info message";
   __notice() << "notice message";
   __warn() << "warn message";
   __error() << "error message";
   __fatal() << "fatal message";
 }
Exemplo n.º 26
0
/**
 * Dump our view of the cluster in the logs.
 */
static void
dump_view(int sig)
{
  exa_nodeid_t node_id;
  char known_str[EXA_MAX_NODES_NUMBER + 1];

  if (sig)
    __debug("got signal %d, dumping view", sig);

  __debug("incarnation: %hu", self->incarnation);

  exa_nodeset_to_bin(&cluster.known_nodes, known_str);
  __debug("num_nodes: %u known_nodes: %s", cluster.num_nodes, known_str);

  for (node_id = 0; node_id < EXA_MAX_NODES_NUMBER; node_id++)
    if (exa_nodeset_contains(&cluster.known_nodes, node_id))
	dump_node(sup_cluster_node(&cluster, node_id));
}
Exemplo n.º 27
0
static char* __aws_sign ( char * const str )
{
  HMAC_CTX ctx;
  unsigned char MD[256];
  unsigned len;

  __debug("StrToSign:%s", str );

  HMAC_CTX_init(&ctx);
  HMAC_Init(&ctx, awsKey, strlen(awsKey), EVP_sha1());
  HMAC_Update(&ctx,(unsigned char*)str, strlen(str));
  HMAC_Final(&ctx,(unsigned char*)MD,&len);
  HMAC_CTX_cleanup(&ctx);

  char * b64 = __b64_encode (MD,len);
  __debug("Signature:  %s", b64 );

  return b64;
}
Exemplo n.º 28
0
/// Get Request Date
/// \internal
/// \return date in HTTP format
static char * __aws_get_httpdate ()
{
  static char dTa[256];
  time_t t = time(NULL);
  struct tm * gTime = gmtime ( & t );
  memset ( dTa, 0 , sizeof(dTa));
  strftime ( dTa, sizeof(dTa), "%a, %d %b %Y %H:%M:%S +0000", gTime );
  __debug ( "Request Time: %s", dTa );
  return dTa;
}
Exemplo n.º 29
0
/**
 * Print a view in a file.
 *
 * \param[in] view       View to print
 * \param     file       File to print to
 */
void
sup_view_debug(const sup_view_t *view)
{
  char seen_str[EXA_MAX_NODES_NUMBER + 1];
  char clique_str[EXA_MAX_NODES_NUMBER + 1];

  if (view == NULL)
    {
      __debug("(null view)");
      return;
    }

  exa_nodeset_to_bin(&view->nodes_seen, seen_str);
  exa_nodeset_to_bin(&view->clique, clique_str);

  __debug("state=%s seen=%s num_seen=%u clique=%s coord=%u"
	  " accepted=%u committed=%u", sup_state_name(view->state),
	  seen_str, view->num_seen, clique_str, view->coord,
	  view->accepted, view->committed);
}
Exemplo n.º 30
0
uint8_t fsmanSessionReset(uint8_t * result_code){
    
    uint32_t pending = fsmanSessionCacheBytesWaiting();
    if(pending){
        __debug("Resetting session pending to disk %d bytes", pending);
        
        if (FSfwrite ((void *)fsbuf, 1, pending, file) != pending){
            *result_code = UNKNOWN_WRITE_ERROR;
            __debug("Write pending bytes failed");
            file = NULL;
            return FALSE;
        }else{
            fsbufptr = 0;
        }
    }
    if (*result_code = FSfclose(file),
            *result_code != CE_GOOD){
        return FALSE;
    }
    return fsmanSessionStart(result_code);
}