virtual void init() { if (mInotifyFd == -1) { mInotifyFd = inotify_init1(IN_CLOEXEC); if (mInotifyFd == -1) { rtLogWarn("hotplug disabled: %s", getSystemError(errno).c_str()); } else { rtLogDebug("initializing inotify, adding watch: %s", kDevInput); mWatchFd = inotify_add_watch(mInotifyFd, kDevInput, (IN_DELETE | IN_CREATE)); if (mWatchFd == -1) { rtLogWarn("hotplug disabled: %s", getSystemError(errno).c_str()); } else { rtLogDebug("adding change notify descriptor: %d to poll list", mInotifyFd); pollfd p; p.fd = mInotifyFd; p.events = (POLLIN | POLLERR); p.revents = 0; mFds.push_back(p); } } } registerDevices(getKeyboardDevices()); registerDevices(getMouseDevices()); }
bool processChangeNotify(const pollfd& pfd) { assert(pfd.fd != -1); assert(pfd.revents & POLLIN); bool importantChange = false; int n = read(pfd.fd, &mNotifyBuffer[0], static_cast<int>(mNotifyBuffer.size())); if (n == -1) { rtLogWarn("failed to read change notify buffer: %d", n); return false; } else { inotify_event* e = reinterpret_cast<inotify_event *>(&mNotifyBuffer[0]); if (e->len) { size_t n = strlen(e->name); if ((n > 4) && (strncmp(e->name, "event", 5) == 0)) { importantChange = true; if (deviceExists(e->name)) { rtLogInfo("%s added", e->name); waitForDevice(kDevInputByPath); } else { rtLogInfo("device removed: %s", e->name); } } } } return importantChange; }
float pxText::getFBOHeight() { if( mh > MAX_TEXTURE_HEIGHT) { rtLogWarn("Text height is larger than maximum texture allowed: %lf. Maximum texture size of %d will be used.",mh, MAX_TEXTURE_HEIGHT); return MAX_TEXTURE_HEIGHT; } else return mh; }
float pxText::getFBOWidth() { if( mw > MAX_TEXTURE_WIDTH) { rtLogWarn("Text width is larger than maximum texture allowed: %lf. Maximum texture size of %d will be used.",mw, MAX_TEXTURE_WIDTH); return MAX_TEXTURE_WIDTH; } else return mw; }
virtual bool next(uint32_t timeoutMillis) { // reset event state for (poll_list::iterator i = mFds.begin(); i != mFds.end(); ++i) { i->events = POLLIN | POLLERR; i->revents = 0; } int n = poll(&mFds[0], static_cast<int>(mFds.size()), timeoutMillis); if (n < 0) { int err = errno; if (err == EINTR) { rtLogInfo("poll was interrupted by EINTR?"); } else { rtLogError("error processing events: %s", getSystemError(err).c_str()); return false; } } bool deviceListChanged = false; for (poll_list::iterator i = mFds.begin(); i != mFds.end(); ++i) { if (i->fd == -1) { rtLogWarn("invalid file descriptor"); continue; } if (!(i->revents & POLLIN)) continue; if (i->fd == mInotifyFd) deviceListChanged = processChangeNotify(*i); else processDescriptor(*i); } if (deviceListChanged) { rtLogInfo("device list change notify"); close(false); init(); } return true; }
void rtScriptDuk::init2(int argc, char** argv) #endif { // Hack around with the argv pointer. Used for process.title = "blah". #ifdef ENABLE_DEBUG_MODE g_argvduk = uv_setup_args(g_argcduk, g_argvduk); #else argv = uv_setup_args(argc, argv); #endif rtLogInfo(__FUNCTION__); #if 0 #warning Using DEBUG AGENT... use_debug_agent = true; // JUNK #endif if(duk_is_initialized == false) { duk_is_initialized = true; uv_loop_t *dukLoop = new uv_loop_t(); uv_loop_init(dukLoop); //uv_loop_t dukLoop = uv_default_loop(); dukCtx = duk_create_heap(NULL, NULL, NULL, dukLoop, NULL); if (!dukCtx) { rtLogWarn("Problem initiailizing duktape heap\n"); return; } dukLoop->data = dukCtx; uvLoops.push_back(dukLoop); { duk_push_thread_stash(dukCtx, dukCtx); duk_push_pointer(dukCtx, (void*)dukLoop); duk_bool_t rc = duk_put_prop_string(dukCtx, -2, "__duk_loop"); assert(rc); duk_pop(dukCtx); } rtScriptDukUtils::rtSetupJsModuleBindings(dukCtx); } }
rtError rtRemoteEndpointHandleStreamServer::doAccept(int& new_fd, rtRemoteEndpointPtr& remote_addr) { sockaddr_storage remote_endpoint; memset(&remote_endpoint, 0, sizeof(remote_endpoint)); socklen_t len = sizeof(sockaddr_storage); new_fd = accept(m_fd, reinterpret_cast<struct sockaddr*>(&remote_endpoint), &len); if (new_fd == -1) { rtError e = rtErrorFromErrno(errno); rtLogWarn("error accepting new tcp connect. %s", rtStrError(e)); return RT_FAIL; } rtLogInfo("new connection from %s with fd:%d", rtSocketToString(remote_endpoint).c_str(), new_fd); return rtRemoteSocketToEndpointAddress(remote_endpoint, rtConnType::STREAM, remote_addr); }
virtual void stop() { rtLogWarn("implement me"); }
rtError rtScriptDuk::init() { rtLogInfo(__FUNCTION__); char const* s = getenv("RT_TEST_GC"); if (s && strlen(s) > 0) mTestGc = true; else mTestGc = false; if (mTestGc) rtLogWarn("*** PERFORMANCE WARNING *** : gc being invoked in render thread"); // TODO Please make this better... less hard coded... //0123456 789ABCDEF012 345 67890ABCDEF #if ENABLE_V8_HEAP_PARAMS #ifdef ENABLE_NODE_V_6_9 static const char *args2 = "rtNode\0-e\0console.log(\"rtNode Initalized\");\0\0"; static const char *argv2[] = {&args2[0], &args2[7], &args2[10], NULL}; #else rtLogWarn("v8 old heap space configured to 64mb\n"); static const char *args2 = "rtNode\0--expose-gc\0--max_old_space_size=64\0-e\0console.log(\"rtNode Initalized\");\0\0"; static const char *argv2[] = {&args2[0], &args2[7], &args2[19], &args2[43], &args2[46], NULL}; #endif // ENABLE_NODE_V_6_9 #else #ifdef ENABLE_NODE_V_6_9 #ifndef ENABLE_DEBUG_MODE static const char *args2 = "rtNode\0-e\0console.log(\"rtNode Initalized\");\0\0"; static const char *argv2[] = {&args2[0], &args2[7], &args2[10], NULL}; #endif //!ENABLE_DEBUG_MODE #else static const char *args2 = "rtNode\0--expose-gc\0-e\0console.log(\"rtNode Initalized\");\0\0"; static const char *argv2[] = {&args2[0], &args2[7], &args2[19], &args2[22], NULL}; #endif // ENABLE_NODE_V_6_9 #endif //ENABLE_V8_HEAP_PARAMS #ifndef ENABLE_DEBUG_MODE int argc = sizeof(argv2)/sizeof(char*) - 1; static args_t aa(argc, (char**)argv2); s_gArgs = &aa; char **argv = aa.argv; #endif #ifdef RUNINMAIN #ifdef WIN32 __rt_main_thread__ = GetCurrentThreadId(); #else __rt_main_thread__ = pthread_self(); // NB #endif #endif nodePath(); #ifdef ENABLE_NODE_V_6_9 rtLogWarn("rtNode::rtNode() calling init \n"); #ifdef ENABLE_DEBUG_MODE init2(); #else init2(argc, argv); #endif #else #ifdef ENABLE_DEBUG_MODE init2(); #else init2(argc, argv); #endif #endif // ENABLE_NODE_V_6_9 return RT_OK; }