Example #1
0
shared_ptr<Layer<Dtype> > GetPoolingLayer(const LayerParameter& param) {
  PoolingParameter_Engine engine = param.pooling_param().engine();
  if (engine == PoolingParameter_Engine_DEFAULT) {
    engine = PoolingParameter_Engine_CAFFE;
#ifdef USE_CUDNN
    engine = PoolingParameter_Engine_CUDNN;
#endif
  }
  if (engine == PoolingParameter_Engine_CAFFE) {
    return shared_ptr<Layer<Dtype> >(new PoolingLayer<Dtype>(param));
#ifdef USE_CUDNN
  } else if (engine == PoolingParameter_Engine_CUDNN) {
    if (param.top_size() > 1) {
      LOG(INFO) << "cuDNN does not support multiple tops. "
                << "Using Caffe's own pooling layer.";
      return shared_ptr<Layer<Dtype> >(new PoolingLayer<Dtype>(param));
    }
    // CuDNN assumes layers are not being modified in place, thus
    // breaking our index tracking for updates in some cases in Caffe.
    // Until there is a workaround in Caffe (index management) or
    // cuDNN, use Caffe layer to max pooling, or don't use in place
    // layers after max pooling layers
    if (param.pooling_param().pool() == PoolingParameter_PoolMethod_MAX) {
        return shared_ptr<Layer<Dtype> >(new PoolingLayer<Dtype>(param));
    } else {
        return shared_ptr<Layer<Dtype> >(new CuDNNPoolingLayer<Dtype>(param));
    }
#endif
  } else {
    LOG(FATAL) << "Layer " << param.name() << " has unknown engine.";
  }
}
Example #2
0
static void m65ce02_set_irq_line(m65ce02_Regs *cpustate, int irqline, int state)
{
	if (irqline == INPUT_LINE_NMI)
	{
		if (cpustate->nmi_state == state) return;
		cpustate->nmi_state = state;
		if( state != CLEAR_LINE )
		{
			LOG(("M65ce02 '%s' set_nmi_line(ASSERT)\n", cpustate->device->tag()));
			EAD = M65CE02_NMI_VEC;
			cpustate->icount -= 7;
			PUSH(PCH);
			PUSH(PCL);
			PUSH(P & ~F_B);
			P = (P & ~F_D) | F_I;		/* knock out D and set I flag */
			PCL = RDMEM(EAD);
			PCH = RDMEM(EAD+1);
			LOG(("M65ce02 '%s' takes NMI ($%04x)\n", cpustate->device->tag(), PCD));
		}
	}
	else
	{
		cpustate->irq_state = state;
		if( state != CLEAR_LINE )
		{
			LOG(("M65ce02 '%s' set_irq_line(ASSERT)\n", cpustate->device->tag()));
			cpustate->pending_irq = 1;
		}
	}
}
Example #3
0
void ResourceManagerEntry(int argc, char ** argv) {
    // change process name
    char buf[16] = {0};
    prctl(PR_GET_NAME, buf);
    const char name[] = "-resource";
    strncat(buf, name, strlen(name));
    prctl(PR_SET_NAME, buf);
    strncat(argv[0], name, strlen(name));
    LOG(INFO) << "resource manager process begin: " << buf;
    ResourceMgr::Instance()->Init();
    // if temperory directory does not exist then create it
    if (access(FLAGS_work_directory.c_str(), F_OK) < 0)
        mkdir(FLAGS_work_directory.c_str(), S_IRWXU|S_IRWXG|S_IROTH);
    signal(SIGINT, SIG_DFL);
    pthread_t start_executor_t, resoure_info_t, control_executor_t;
    pthread_create(&start_executor_t, NULL, StartExecutorReceiver, NULL);
    pthread_create(&resoure_info_t, NULL, ResourceInfoSender, NULL);
    pthread_create(&control_executor_t, NULL, ExecutorControlReceiver, NULL);
    // wait pid for task execution finished
    pid_t pid;
    int status;
    while (true) {
        if ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
            LOG(ERROR) << "FFF" << pid;
            ContainerPool::ContainerFunc func = bind(&Container::ContainerFinished,
                                                     _1);
            // find the container and deal with the thing
            if(ContainerMgr::Instance()->FindToDo(pid, func))
                // remove the container since it has finished
                ContainerMgr::Instance()->Delete(pid);
        }
        sleep(1);
    }
} 
Example #4
0
static void main_realtime_init(void)
{
   ASSERT_ONCE();

   LOG(LL_INFO, "setting up real-time scheduling");
   sp.sched_priority = sched_get_priority_max(SCHED_FIFO);
   sched_setscheduler(getpid(), SCHED_FIFO, &sp);
   
   if (nice(-20) == -1)
   {
      LOG(LL_ERROR, "could not renice process");
      die();
   }
   
   thread->sched_param.sched_priority = 97;
   pthread_setschedparam(pthread_self(), SCHED_FIFO, &thread->sched_param);

   /*if (mlockall(MCL_CURRENT | MCL_FUTURE) != 0)
   {
      LOG(LL_ERROR, "mlockall() failed");
      die();
   }*/

   thread->name = "main_loop";
   thread->running = 1;
   thread->periodic_data.period.tv_sec = 0;
   thread->periodic_data.period.tv_nsec = NSEC_PER_SEC * REALTIME_PERIOD;
}
Example #5
0
int
main (int argc, char **argv) {
	// Log messeages into stderr
	FLAGS_logtostderr = 1;
	google::InitGoogleLogging (argv[0]);

	LOG(INFO) << "Begin BLAS Demo";
	std::cout << "  A = [ 0 0 1 ; 0 1 0 ; 1 0 0 ]" << std::endl
		<< "  B = [ 1;2;3 ]" << std::endl;
	int M=3, K=3, N=1;
	float A[M*K] = { 0,0,1, 0,1,0, 1,0,0 };
	float B[K*N] = { 1,2,3 };
	float C[M*N];

	// Do matrix multiplication
	LOG(INFO) << "Calculating  C := 1.0 A * B + 0.0 C ";
	cblas_sgemm (CblasRowMajor, CblasNoTrans, CblasNoTrans, M, N, K,
		1.0, A, K, B, N, 0.0, C, N);

	// Dump matrix	
	LOG(INFO) << "Dumping matrix C";
	std::cout << "C = [" << std::endl;
	for (int i = 1; i <= M; i++) {
		std::cout << "\t";
		for (int j = 1; j <= N; j++) {
			std::cout << C[i*j-1] << " ";
		}
		std::cout << std::endl;
	}
	std::cout << "];" << std::endl;

	LOG(INFO) << "Demo done.";
	return 0;
}
/**
 * Creates a Authorization Session.
 */
AAASession* AAACreateAuthSession(void *generic_data,int is_client,int is_statefull,AAASessionCallback_f *cb,void *param)
{
	AAASession *s;
	str id;
	cdp_session_type_t type;
	
	generate_session_id(&id,0);
	
	if (is_client){
		if (is_statefull) type = AUTH_CLIENT_STATEFULL;
		else type = AUTH_CLIENT_STATELESS;
	}else{
		if (is_statefull) type = AUTH_SERVER_STATEFULL;
		else type = AUTH_SERVER_STATELESS;		
	}
	s = new_session(id,type);
	if (s) {
		s->u.auth.generic_data = generic_data;
		s->cb = cb;
		s->cb_param = param;
		s->u.auth.timeout=time(0)+config->tc*30; 
		s->u.auth.lifetime=time(0)+config->tc*32;
		s->u.auth.grace_period=config->tc*2;
		LOG(L_DBG,"id is %.*s",s->id.len,s->id.s);
		LOG(L_DBG,"hash is %u",s->hash);
		add_session(s);
	}
	return s;
}
Example #7
0
const struct addrinfo * get_one_host(const char * name) {
    struct addrinfo * res;
    struct addrinfo hints;
    
    bzero(&hints, sizeof(hints));
    
    // This is the family and protocol, since we are making DNS probes on UDP.
    hints.ai_family = PF_INET;
    hints.ai_protocol = IPPROTO_UDP;
    
    int ret = getaddrinfo(name, service, &hints, &res);
    LOG(1, "getaddrinfo(\"%s\", \"%s\", %p, %p) == %d", name, service, &hints, &res, ret);
    
    if (0 > ret) DIE(EX_OSERR, "getaddrinfo");
    
    for (struct addrinfo * i = res; NULL != i; i = i->ai_next) {
        LOG(2, "res:          { ai_flags: %d, ai_family: %d, ai_socktype: %d, ai_protocol: %d, ai_addrlen: %d, ai_addr: %p, ai_canonname: %s }",
            i->ai_flags, i->ai_family, i->ai_socktype, i->ai_protocol, i->ai_addrlen, i->ai_addr, i->ai_canonname);
    }
    if (NULL != res->ai_next) DIEx(EX_SOFTWARE, "more than one addr from getaddrinfo");
    
    struct sockaddr_in * in = (struct sockaddr_in *)res->ai_addr;
    LOG(2, "res->ai_addr: { sin_len: %hhu, sin_family: %hhu, sin_port: %hu, sin_addr.s_addr: %hhu.%hhu.%hhu.%hhu }",
        in->sin_len,
        in->sin_family,
        htons(in->sin_port),
        ((u_char *)&(in->sin_addr.s_addr))[0],
        ((u_char *)&(in->sin_addr.s_addr))[1],
        ((u_char *)&(in->sin_addr.s_addr))[2],
        ((u_char *)&(in->sin_addr.s_addr))[3]);

    return res;
}
Example #8
0
File: link.c Project: fd/telehash-c
// process a decrypted channel packet
link_t link_receive(link_t link, lob_t inner, pipe_t pipe)
{
  chan_t chan;

  if(!link || !inner) return LOG("bad args");

  // see if existing channel and send there
  if((chan = xht_get(link->index, lob_get(inner,"c"))))
  {
    if(channel3_receive(chan->c3, inner)) return LOG("channel receive error, dropping %s",lob_json(inner));
    link_pipe(link,pipe); // we trust the pipe at this point
    if(chan->handle) chan->handle(link, chan->c3, chan->arg);
    // check if there's any packets to be sent back
    return link_flush(link, chan->c3, NULL);
  }

  // if it's an open, validate and fire event
  if(!lob_get(inner,"type")) return LOG("invalid channel open, no type %s",lob_json(inner));
  if(!exchange3_cid(link->x, inner)) return LOG("invalid channel open id %s",lob_json(inner));
  link_pipe(link,pipe); // we trust the pipe at this point
  inner = mesh_open(link->mesh,link,inner);
  if(inner)
  {
   LOG("unhandled channel open %s",lob_json(inner));
   lob_free(inner);
   return NULL;
  }
  
  return link;
}
Example #9
0
File: link.c Project: fd/telehash-c
// create/track a new channel for this open
channel3_t link_channel(link_t link, lob_t open)
{
  chan_t chan;
  channel3_t c3;
  if(!link || !open) return LOG("bad args");

  // add an outgoing cid if none set
  if(!lob_get_int(open,"c")) lob_set_int(open,"c",exchange3_cid(link->x, NULL));
  c3 = channel3_new(open);
  if(!c3) return LOG("invalid open %s",lob_json(open));
  LOG("new outgoing channel open: %s",lob_get(open,"type"));

  // add this channel to the link's channel index
  if(!(chan = malloc(sizeof (struct chan_struct))))
  {
    channel3_free(c3);
    return LOG("OOM");
  }
  memset(chan,0,sizeof (struct chan_struct));
  chan->c3 = c3;
  xht_set(link->channels, channel3_uid(c3), chan);
  xht_set(link->index, channel3_c(c3), chan);

  return c3;
}
ProtocolError DTLSMessageChannel::setup_context()
{
	int ret;
	mbedtls_ssl_free(&ssl_context);
	ret = mbedtls_ssl_setup(&ssl_context, &conf);
	EXIT_ERROR(ret, "unable to setup SSL context");

	mbedtls_ssl_set_timer_cb(&ssl_context, &timer, mbedtls_timing_set_delay, mbedtls_timing_get_delay);
	mbedtls_ssl_set_bio(&ssl_context, this, &DTLSMessageChannel::send_, &DTLSMessageChannel::recv_, NULL);

	if ((ssl_context.session_negotiate->peer_cert = (mbedtls_x509_crt*)calloc(1, sizeof(mbedtls_x509_crt))) == NULL)
	{
		LOG(ERROR,"unable to allocate cert storage");
		return INSUFFICIENT_STORAGE;
	}

	mbedtls_x509_crt_init(ssl_context.session_negotiate->peer_cert);
	ret = mbedtls_pk_parse_public_key(&ssl_context.session_negotiate->peer_cert->pk, server_public, server_public_len);
	if (ret) {
		LOG(WARN,"unable to parse negotiated pub key: -%x", -ret);
		return IO_ERROR_PARSING_SERVER_PUBLIC_KEY;
	}

	return NO_ERROR;
}
Example #11
0
File: link.c Project: fd/telehash-c
// load in the key to existing link
link_t link_load(link_t link, uint8_t csid, lob_t key)
{
  char hex[3];
  lob_t copy;

  if(!link || !csid || !key) return LOG("bad args");
  if(link->x) return link;

  LOG("adding %x key to link %s",csid,link->id->hashname);
  
  // key must be bin
  if(key->body_len)
  {
    copy = lob_copy(key);
  }else{
    util_hex(&csid,1,hex);
    copy = lob_get_base32(key,hex);
  }
  link->x = exchange3_new(link->mesh->self, csid, copy);
  if(!link->x)
  {
    lob_free(copy);
    return LOG("invalid %x key %d %s",csid,key->body_len,lob_json(key));
  }

  link->csid = csid;
  link->key = copy;
  // route packets to this token
  util_hex(exchange3_token(link->x),16,link->token);
  xht_set(link->mesh->index,link->token,link);
  exchange3_out(link->x, platform_seconds());
  LOG("delivering session token %s to %s",link->token,link->id->hashname);

  return link;
}
hlcanopen::CanMsg Pci7841Card::read()
{
  CAN_PACKET canPacket;
  memset(&canPacket, 0, sizeof(canPacket));


  if (CanRcvMsg(handle, &canPacket) == 0) {
    if(getCanId(canPacket.CAN_ID) == 0) {
    } else {
      LOG(DEBUG) << "receiving data: " <<
        " -- COB-ID:  " << canPacket.CAN_ID <<
        " can-id:  " << getCanId(canPacket.CAN_ID) << " -- data: " <<
        packetDataToStr(canPacket);
    }
  } else {
    LOG(DEBUG) << "no data received ";
    memset(&canPacket, 0, sizeof(canPacket));
  }

   hlcanopen::CanMsg canMsg;
   canMsg.cobId = hlcanopen::COBId(getCanId(canPacket.CAN_ID), getCOBType(canPacket.CAN_ID));
   for(BYTE i =0; i < 8; i++) {
      canMsg[i] = canPacket.data[i];
   }

   return canMsg;
}
Example #13
0
int generate_rsa_pkey() {
	FILE * fp;
	RSA * rsa_priv_key;
	const int kBits = 1024;
	const int kExp = 3;
	int keylen;
	char *pem_key;
        
	rsa_priv_key = RSA_generate_key(kBits, kExp, 0, 0);

	/* To get the C-string PEM form: */
	BIO *bio = BIO_new(BIO_s_mem());
	PEM_write_bio_RSAPrivateKey(bio, rsa_priv_key, NULL, NULL, 0, NULL, NULL);

	keylen = BIO_pending(bio);
	pem_key = calloc(keylen + 1, 1); /* Null-terminate */
	BIO_read(bio, pem_key, keylen);

	fp = fopen(f_rsa_private_key, "w");
	if (fp) {
		fwrite(pem_key, keylen, 1, fp);
		fclose(fp);
	} else {
		LOG(ERROR, "[API] RSA key generation failed, could not write key to %s", f_rsa_private_key);
		return -1;
	}

	LOG(VERBOSE, "[API] Private key created:%s", pem_key);

	BIO_free_all(bio);
	free(pem_key);
        pem_key = NULL;
	return 0;
}
void	V2State::colloectNavalBase()
{
	//Only one naval base in a state
	V2Province* prov = nullptr;
	int level = 0;
	for (auto province : provinces)
	{
		if (!prov)
		{
			prov = province;
		}
		level += province->getNavalBaseLevel();
		if (prov->getNavalBaseLevel() < province->getNavalBaseLevel())
		{
			prov = province;
		}
	}
	LOG(LogLevel::Debug) << this->provinces.size() << " provinces in state " << this->id;
	for (auto province : provinces)
	{
		province->setNavalBaseLevel(0);
		LOG(LogLevel::Debug) << province->getName() << " naval base set to 0";	//test
	}
	prov->setNavalBaseLevel(level > 2 ? 2 : level);
}
void vmsHttpFlvTrafficAnalyzer::FindDialogsByUniqueUrlWordsMatch(LPCSTR pszSwfContext, const HTTPDLGLIST &vDlgs, HTTPDLGLIST &vResult)
{
	LOGFN ("vmsHttpFlvTrafficAnalyzer::FindDialogsByUniqueUrlWordsMatch");

	vResult.clear ();
	
	vector < vector <string> > vvUniqueWords;
	vmsWinSockHttpTrafficAnalyzer::FindUniqueUrlWords (vDlgs, vvUniqueWords);
	
	assert (vvUniqueWords.size () == vDlgs.size ());
	
	for (size_t iDlg = 0; iDlg < vvUniqueWords.size (); iDlg++)
	{
		vector <string> &vWords = vvUniqueWords [iDlg];
		if (vWords.empty ())
			continue;
		for (size_t iW = 0; iW < vWords.size (); iW++)
		{
			if (strstr (pszSwfContext, vWords [iW].c_str ()) != NULL)
			{
				vResult.push_back (vDlgs [iDlg]);
				LOG ("Unique url word \"%s\" is containing in source text", vWords [iW].c_str ());
				LOG ("|-dialog url-%s", vDlgs [iDlg]->strRequestUrl.c_str ());
				break;
			}
		}
	}
}
Example #16
0
File: link.c Project: fd/telehash-c
link_t link_key(mesh_t mesh, lob_t key)
{
  uint8_t csid;
  hashname_t hn;
  link_t link;

  if(!mesh || !key) return LOG("invalid args");
  csid = hashname_id(mesh->keys,key);
  if(!csid) return LOG("no supported key");

  hn = hashname_key(key);
  if(!hn) return LOG("invalid key");

  link = link_get(mesh, hn->hashname);
  if(link)
  {
    hashname_free(hn);
  }else{
    link = link_new(mesh,hn);
  }

  // load key if it's not yet
  if(!link->key) return link_load(link, csid, key);

  return link;
}
Example #17
0
Core::Core(): quit(false), actTime(0), lastTime(0), delta(0) {
	LOG(info) << "Core::Core()";

	int error = SDL_Init(SDL_INIT_EVERYTHING);
	if (error < 0) {
		LOG(error) << "SDL init fail";
		throw Exception(SDL_GetError());
	}

	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

	window = SDL_CreateWindow("Demo",
							  SDL_WINDOWPOS_UNDEFINED,
							  SDL_WINDOWPOS_UNDEFINED,
							  WIDTH,
							  HEIGHT,
							  SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL | \
							  SDL_WINDOW_RESIZABLE
							  );
	if (window == NULL) {
		LOG(error) << "Create window fail";
		throw Exception("SDL create window failed!");
	}

	renderer = new Renderer(window, "../assets/shader.vert", "../assets/shader.frag", WIDTH, HEIGHT);
	scene = nullptr;
	v = 1;

	LOG(info) << "Core::Core() done";
}
Example #18
0
void LMDB::Open(const string& source, Mode mode) {
  MDB_CHECK(mdb_env_create(&mdb_env_));
  MDB_CHECK(mdb_env_set_mapsize(mdb_env_, LMDB_MAP_SIZE));
  if (mode == NEW) {
    CHECK_EQ(mkdir(source.c_str(), 0744), 0) << "mkdir " << source << " failed";
  }
  int flags = 0;
  if (mode == READ) {
    flags = MDB_RDONLY | MDB_NOTLS;
  }
  int rc = mdb_env_open(mdb_env_, source.c_str(), flags, 0664);
#ifndef ALLOW_LMDB_NOLOCK
  MDB_CHECK(rc);
#else
  if (rc == EACCES) {
    LOG(WARNING) << "Permission denied. Trying with MDB_NOLOCK ...";
    // Close and re-open environment handle
    mdb_env_close(mdb_env_);
    MDB_CHECK(mdb_env_create(&mdb_env_));
    // Try again with MDB_NOLOCK
    flags |= MDB_NOLOCK;
    MDB_CHECK(mdb_env_open(mdb_env_, source.c_str(), flags, 0664));
  } else {
    MDB_CHECK(rc);
  }
#endif
  LOG(INFO) << "Opened lmdb " << source;
}
Example #19
0
/**
 * Check the list of pending requests, send the next
 * one to the core.
 *
 * @param h core handle
 * @param ignore_currently_down transmit message even if not initialized?
 */
static void
trigger_next_request (struct GNUNET_CORE_Handle *h,
                      int ignore_currently_down)
{
  uint16_t msize;

  if ((GNUNET_YES == h->currently_down) && (ignore_currently_down == GNUNET_NO))
  {
    LOG (GNUNET_ERROR_TYPE_DEBUG,
         "Core connection down, not processing queue\n");
    return;
  }
  if (NULL != h->cth)
  {
    LOG (GNUNET_ERROR_TYPE_DEBUG, "Request pending, not processing queue\n");
    return;
  }
  if (NULL != h->control_pending_head)
    msize =
        ntohs (((struct GNUNET_MessageHeader *) &h->
                control_pending_head[1])->size);
  else if (h->ready_peer_head != NULL)
    msize =
      h->ready_peer_head->th.msize + sizeof (struct SendMessage);
  else
  {
    LOG (GNUNET_ERROR_TYPE_DEBUG,
         "Request queue empty, not processing queue\n");
    return;                     /* no pending message */
  }
  h->cth =
      GNUNET_CLIENT_notify_transmit_ready (h->client, msize,
                                           GNUNET_TIME_UNIT_FOREVER_REL,
                                           GNUNET_NO, &transmit_message, h);
}
Example #20
0
static int dvdwrap_open(const char *path, struct fuse_file_info *fi)
{
	dvdwrap_ctx_t *ctx = PRIVATE;
	dvdwrap_fh_t *private;
	int maj, min;
	uint64_t total_size;
	char targetpath[PATH_MAX];
	char vtspath[PATH_MAX];
	struct stat st;

	LOG("%s(%s, %p)\n", __FUNCTION__, path, fi);

	/* Process path for filename and remove extension */
	snprintf(targetpath, PATH_MAX, "%s/%s", ctx->sourcepath, path);
	if (strcmp(&targetpath[strlen(targetpath) - strlen(FILE_EXTENSION)], FILE_EXTENSION) != 0) {
		/* This file doesn't refer to a DVD image */
		LOG("Bad filename\n");
		return -ENOENT;
	}
	targetpath[strlen(targetpath) - strlen(FILE_EXTENSION)] = '\0';

	/* Scan for titleset major number and total size */
	if (dvdwrap_scan_videots(targetpath, &maj, &total_size) < 0) {
		LOG("VTS scan failed\n");
		return -ENOENT;
	}

	/* All is well - allocate private data */
	private = calloc(1, sizeof(dvdwrap_fh_t));
Example #21
0
void AdStreamSubscriber::heart_check()
{
    bool server_lost = false;
    while(true)
    {
        if (!conn_mgr_)
            break;
        try
        {
            server_lost = !conn_mgr_->testServer();
            boost::this_thread::interruption_point();
            sleep(HEART_CHECK_INTERVAL);
            if (server_lost)
            {
                LOG(INFO) << "server lost, try resubscribe_all.";
                resubscribe_all();
            }
            else
            {
                retry_failed_subscriber();
            }
        }
        catch(const boost::thread_interrupted& e)
        {
            break;
        }
        catch(const std::exception& e)
        {
            LOG(INFO) << "exception in heart_check : " << e.what();
        }
    }
    LOG(INFO) << "heart_check thread exit. ";
}
Example #22
0
bool Content::DownloadFile( const QString &sURL, const QString &sStorageGroup )
{
    QFileInfo finfo(sURL);
    QString filename = finfo.fileName();
    StorageGroup sgroup(sStorageGroup, gCoreContext->GetHostName(), false);
    QString outDir = sgroup.FindNextDirMostFree();
    QString outFile;

    if (outDir.isEmpty())
    {
        LOG(VB_GENERAL, LOG_ERR,
            QString("Unable to determine directory "
                    "to write to in %1 write command").arg(sURL));
        return false;
    }

    if ((filename.contains("/../")) ||
        (filename.startsWith("../")))
    {
        LOG(VB_GENERAL, LOG_ERR,
            QString("ERROR: %1 write filename '%2' does not "
                    "pass sanity checks.") .arg(sURL).arg(filename));
        return false;
    }

    outFile = outDir + "/" + filename;

    if (GetMythDownloadManager()->download(sURL, outFile))
        return true;

    return false;
}
int PointFloatShapeFeatureExtractor::readConfig(const string& cfgFilePath)
{
    LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << "Entering " <<
        "PointFloatShapeFeatureExtractor::readConfig()" << endl;
    
	LTKConfigFileReader* configurableProperties = NULL;
	string tempStringVar = "";

	try
	{
		configurableProperties = new LTKConfigFileReader(cfgFilePath);
	}

	catch(LTKException e)
	{
		delete configurableProperties;

        int eCode = e.getErrorCode();

        LOG( LTKLogger::LTK_LOGLEVEL_ERR) << "Error: " << eCode << 
            " : " << getErrorMessage(eCode) <<
            " PointFloatShapeFeatureExtractor::readConfig" <<endl;
        
		LTKReturnError(eCode);
	}
    
	delete configurableProperties;

    LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << "Exiting " <<
        "PointFloatShapeFeatureExtractor::readConfig()" << endl;
	return SUCCESS;

}
Example #24
0
inline static str* get_source_uri(struct sip_msg* msg,int source)
{
	/* which uri will be used? */
	if (source&AVPOPS_USE_FROM)
	{ /* from */
		if (parse_from_header( msg )<0 )
		{
			LOG(L_ERR,"ERROR:avpops:get_source_uri: failed "
				"to parse from\n");
			goto error;
		}
		return &(get_from(msg)->uri);
	} else if (source&AVPOPS_USE_TO)
	{  /* to */
		if (parse_headers( msg, HDR_TO, 0)<0)
		{
			LOG(L_ERR,"ERROR:avpops:get_source_uri: failed "
				"to parse to\n");
			goto error;
		}
		return &(get_to(msg)->uri);
	} else if (source&AVPOPS_USE_RURI) {  /* RURI */
		if(msg->new_uri.s!=NULL && msg->new_uri.len>0)
			return &(msg->new_uri);
		return &(msg->first_line.u.request.uri);
	} else {
		LOG(L_CRIT,"BUG:avpops:get_source_uri: unknow source <%d>\n",
			source);
		goto error;
	}
error:
	return 0;
}
Example #25
0
void WedgePlatform::initTransceiverMap(SwSwitch* sw) {
  const int MAX_WEDGE_MODULES = 16;

  // If we can't get access to the USB devices, don't bother to
  // create the QSFP objects;  this is likely to be a permanent
  // error.

  try {
    wedgeI2CBusLock_ = make_unique<WedgeI2CBusLock>();
  } catch (const LibusbError& ex) {
    LOG(ERROR) << "failed to initialize USB to I2C interface";
    return;
  }

  // Wedge port 0 is the CPU port, so the first port associated with
  // a QSFP+ is port 1.  We start the transceiver IDs with 0, though.

  for (int idx = 0; idx < MAX_WEDGE_MODULES; idx++) {
    std::unique_ptr<WedgeQsfp> qsfpImpl =
      make_unique<WedgeQsfp>(idx, wedgeI2CBusLock_.get());
    for (int channel = 0; channel < QsfpModule::CHANNEL_COUNT; ++channel) {
      qsfpImpl->setChannelPort(ChannelID(channel),
          PortID(idx * QsfpModule::CHANNEL_COUNT + channel + 1));
    }
    std::unique_ptr<QsfpModule> qsfp =
      make_unique<QsfpModule>(std::move(qsfpImpl));
    sw->addTransceiver(TransceiverID(idx), std::move(qsfp));
    LOG(INFO) << "making QSFP for " << idx;
    for (int channel = 0; channel < QsfpModule::CHANNEL_COUNT; ++channel) {
      sw->addTransceiverMapping(PortID(idx * QsfpModule::CHANNEL_COUNT +
          channel + 1), ChannelID(channel), TransceiverID(idx));
    }
  }
}
Example #26
0
static int parse_source_uri(struct sip_msg* msg,int source,struct sip_uri *uri)
{
	str *uri_s;

	/* get uri */
	if ( (uri_s=get_source_uri(msg,source))==0 )
	{
		LOG(L_ERR,"ERROR:avpops:parse_source_uri: cannot get uri\n");
		goto error;
	}

	/* parse uri */
	if (parse_uri(uri_s->s, uri_s->len , uri)<0)
	{
		LOG(L_ERR,"ERROR:avpops:parse_source_uri: failed to parse uri\n");
		goto error;
	}

	/* check uri */
	if (!uri->user.s || !uri->user.len || !uri->host.len || !uri->host.s )
	{
		LOG(L_ERR,"ERROR:avpops:parse_source_uri: incomplet uri <%.*s>\n",
			uri_s->len,uri_s->s);
		goto error;
	}

	return 0;
error:
	return -1;
}
bool W3cXmlPlugin::process(const QString *infoListfile)
{
    LOG("BEGIN W3cXmlPlugin::process infoListfile=" << infoListfile);

    if (infoListfile == NULL && m_dir.exists()) {
        LOG("W3cXmlPlugin::process search for config.xml");
        // Search for config.xml file

        QFileInfoList tempExtract = m_dir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot);
        LOG("W3cXmlPlugin::process got entryInfoList");

        foreach (const QFileInfo &isWidgetDir, tempExtract ) {
            if (!isWidgetDir.fileName().compare("config.xml", Qt::CaseSensitive)) {
                // We found the config.xml
                QString filePath = isWidgetDir.absoluteFilePath();
                if (!filePath.isEmpty()) {
                    QFileInfo f = filePath;
                    m_dir = f.dir();
                    LOG("W3cXmlPlugin::process found config.xml at " << filePath);
                    m_parser->setFile(filePath);
                    if (m_parser->parseFile()) {
                       setAttributeMap();
                       LOG("END W3cXmlPlugin::process xml parsing successful");
                       return true;
                    }
                }
            }
        }   // end of foreach
    }
bool WaveOutPulseAudio::Play()
{
    LOG(LOG_VERBOSE, "Starting playback stream..");

    mPlayMutex.lock();

    if (!mWaveOutOpened)
    {
        // unlock grabbing
        mPlayMutex.unlock();

        LOG(LOG_VERBOSE, "Playback device wasn't opened yet");

        return true;
    }

    if (!mPlaybackStopped)
    {
        // unlock grabbing
        mPlayMutex.unlock();

        LOG(LOG_VERBOSE, "Playback was already started");

        return true;
    }

    WaveOut::Play();

    // unlock grabbing
    mPlayMutex.unlock();

    return true;
}
Example #29
0
void WebSocket::close(int code, const String& reason, ExceptionCode& ec)
{
    if (code == WebSocketChannel::CloseEventCodeNotSpecified)
        LOG(Network, "WebSocket %p close() without code and reason", this);
    else {
        LOG(Network, "WebSocket %p close() code=%d reason='%s'", this, code, reason.utf8().data());
        if (!(code == WebSocketChannel::CloseEventCodeNormalClosure || (WebSocketChannel::CloseEventCodeMinimumUserDefined <= code && code <= WebSocketChannel::CloseEventCodeMaximumUserDefined))) {
            ec = INVALID_ACCESS_ERR;
            return;
        }
        CString utf8 = reason.utf8(StrictConversionReplacingUnpairedSurrogatesWithFFFD);
        if (utf8.length() > maxReasonSizeInBytes) {
            scriptExecutionContext()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, ASCIILiteral("WebSocket close message is too long."));
            ec = SYNTAX_ERR;
            return;
        }
    }

    if (m_state == CLOSING || m_state == CLOSED)
        return;
    if (m_state == CONNECTING) {
        m_state = CLOSING;
        m_channel->fail("WebSocket is closed before the connection is established.");
        return;
    }
    m_state = CLOSING;
    if (m_channel)
        m_channel->close(code, reason);
}
Example #30
0
shared_ptr<Layer<Dtype> > GetConvolutionLayer(
    const LayerParameter& param) {
  ConvolutionParameter conv_param = param.convolution_param();
  ConvolutionParameter_Engine engine = conv_param.engine();
#ifdef USE_CUDNN
  bool use_dilation = false;
  for (int i = 0; i < conv_param.dilation_size(); ++i) {
    if (conv_param.dilation(i) > 1) {
      use_dilation = true;
    }
  }
#endif
  if (engine == ConvolutionParameter_Engine_DEFAULT) {
    engine = ConvolutionParameter_Engine_CAFFE;
#ifdef USE_CUDNN
    if (!use_dilation) {
      engine = ConvolutionParameter_Engine_CUDNN;
    }
#endif
  }
  if (engine == ConvolutionParameter_Engine_CAFFE) {
    return shared_ptr<Layer<Dtype> >(new ConvolutionLayer<Dtype>(param));
#ifdef USE_CUDNN
  } else if (engine == ConvolutionParameter_Engine_CUDNN) {
    if (use_dilation) {
      LOG(FATAL) << "CuDNN doesn't support the dilated convolution at Layer "
                 << param.name();
    }
    return shared_ptr<Layer<Dtype> >(new CuDNNConvolutionLayer<Dtype>(param));
#endif
  } else {
    LOG(FATAL) << "Layer " << param.name() << " has unknown engine.";
  }
}