void _tmain (int argc, TCHAR **argv) { CServiceManager mgr(NULL); if (!mgr.ok()) { _ftprintf(stderr, TEXT ("Couldn't open service manager\n")); return; } if ((argc > 1) && (!_tcsicmp(argv[1], TEXT ("install")))) { if (argc != 4) { _ftprintf (stderr, TEXT ("%s install name path\n"), argv[0]); return; } CService svc(&mgr, argv[2]); svc.install(argv[2], argv[2], argv[3]); svc.start (); if (!svc.ok()) { _ftprintf(stderr, TEXT ("Couldn't install service\n")); return; } } else if ((argc > 1) && (!_tcsicmp(argv[1], TEXT ("remove")))) { if (argc != 3) { _ftprintf (stderr, TEXT ("%s remove name\n"), argv[0]); return; } CService svc(&mgr, argv[2]); svc.destroy(); } else { _ftprintf(stderr, TEXT (" %s install\nor %s remove\n"), argv[0], argv[0]); return; } }
void RenderTargetTexture::setViewport(const Viewport &vp) { if (m_texture) svc().resourceMgr.unloadResource(m_texture); m_viewport = vp; TextureCreationParams params; params.setMipmapped(false); params.setFiltering(TextureFiltering::NEAREST); auto pb = make_unique<PixelBuffer>(m_viewport.width(), m_viewport.height(), PixelFormat::RGBA); m_texture = svc().resourceMgr.getFactory().createTexture(std::move(pb), params); }
//--------------------------------------------------- //-- nsPrintData Class Impl //--------------------------------------------------- nsPrintData::nsPrintData(ePrintDataType aType) : mType(aType), mDebugFilePtr(nsnull), mPrintObject(nsnull), mSelectedPO(nsnull), mPrintDocList(nsnull), mIsIFrameSelected(PR_FALSE), mIsParentAFrameSet(PR_FALSE), mOnStartSent(PR_FALSE), mIsAborted(PR_FALSE), mPreparingForPrint(PR_FALSE), mDocWasToBeDestroyed(PR_FALSE), mShrinkToFit(PR_FALSE), mPrintFrameType(nsIPrintSettings::kFramesAsIs), mNumPrintablePages(0), mNumPagesPrinted(0), mShrinkRatio(1.0), mOrigDCScale(1.0), mPPEventListeners(NULL), mBrandName(nsnull) { nsCOMPtr<nsIStringBundle> brandBundle; nsCOMPtr<nsIStringBundleService> svc( do_GetService( NS_STRINGBUNDLE_CONTRACTID ) ); if (svc) { svc->CreateBundle( "chrome://branding/locale/brand.properties", getter_AddRefs( brandBundle ) ); if (brandBundle) { brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(), &mBrandName ); } } if (!mBrandName) { mBrandName = ToNewUnicode(NS_LITERAL_STRING("Mozilla Document")); } }
int Low_Priority_Task::open (void *) { if (use_fork == 1) { ACE_hthread_t thr_handle; ACE_Thread::self (thr_handle); if (ACE_Thread::setprio (thr_handle, priority_) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "setprio failed"), -1); return svc (); } else { long flags = THR_BOUND | THR_NEW_LWP | THR_SCHED_FIFO; // Become an active object. if (this->activate (flags, 1, 0, this->priority_) == -1) ACE_ERROR ((LM_ERROR, "(%P|%t) task activation failed, exiting!\n%a", -1)); return 0; } }
bool MeshComponent::isInFov() { if (m_frustumCullingDisabled) return true; return svc().sceneMgr.getCamera()->getFrustum().sphereInFrustum(getBoundingSphere()); }
int main(int argc, char **argv) { UINT nCheckPoint; BOOL bDebug = FALSE; int nPort = 8000; UINT nNzcNumber = 0; char ipaddr[64] = {0,}; int opt; int ret=0; while((opt=getopt(argc, argv, "dhn:p:")) != -1) { switch(opt) { case 'd': bDebug = TRUE; break; case 'p': nPort = (int)strtol(optarg, (char **)NULL, 10); break; case 'n': nNzcNumber = strtol(optarg, (char **)NULL, 10); break; case 'h': default : usage(argv[0]); } } if((argc - optind) < 1) { usage(argv[0]); } strncpy(ipaddr, argv[optind], MIN(sizeof(ipaddr)-1, strlen(argv[optind]))); CheckPoint(&nCheckPoint); CDbUploadService svc(nNzcNumber, ipaddr, nPort, bDebug); ret = svc.Startup(); svc.Shutdown(); Difference(nCheckPoint); return ret>0?1:0; }
MeshComponent::MeshComponent(const std::string &meshFilePath, ResourceLoadingMode lm) : MeshComponent() { m_rmgrListener->m_guid = resources::CreateGUIDFromPath(meshFilePath); setMeshData(svc().resourceMgr.getFactory().createMeshData(meshFilePath, lm)); }
/** * Attempt to start the service. */ void SCM::start(const string& serviceName) { // Ensure we have a handle to the SCM database. openSvcManager(); // Get a handle to the service. AutoServiceHandle svc(::OpenService(scmHandle, serviceName.c_str(), SERVICE_ALL_ACCESS)); QPID_WINDOWS_CHECK_NULL(svc); // Check the status in case the service is not stopped. DWORD state = waitForStateChangeFrom(svc, SERVICE_STOP_PENDING); if (state == SERVICE_STOP_PENDING) throw qpid::Exception("Timed out waiting for running service to stop."); // Attempt to start the service. QPID_WINDOWS_CHECK_NOT(::StartService(svc, 0, NULL), 0); QPID_LOG(info, "Service start pending..."); // Check the status until the service is no longer start pending. state = waitForStateChangeFrom(svc, SERVICE_START_PENDING); // Determine whether the service is running. if (state == SERVICE_RUNNING) { QPID_LOG(info, "Service started successfully"); } else { throw qpid::Exception(QPID_MSG("Service not yet running; state now " << state)); } }
NS_IMETHODIMP nsCompartmentInfo::GetCompartments(nsIArray** aCompartments) { JSRuntime* rt; nsCOMPtr<nsIJSRuntimeService> svc(do_GetService("@mozilla.org/js/xpc/RuntimeService;1")); NS_ENSURE_TRUE(svc, NS_ERROR_FAILURE); svc->GetRuntime(&rt); nsCOMPtr<nsIMutableArray> compartments = do_CreateInstance(NS_ARRAY_CONTRACTID); CompartmentStatsVector stats; if (!JS_GetCompartmentStats(rt, stats)) return NS_ERROR_OUT_OF_MEMORY; size_t num = stats.length(); for (size_t pos = 0; pos < num; pos++) { nsString addonId; if (stats[pos].addonId) { AssignJSFlatString(addonId, (JSFlatString*)stats[pos].addonId); } else { addonId.AssignLiteral("<non-addon>"); } uint32_t cpowTime = xpc::GetCompartmentCPOWMicroseconds(stats[pos].compartment); nsCString compartmentName(stats[pos].compartmentName); NS_ConvertUTF8toUTF16 name(compartmentName); compartments->AppendElement(new nsCompartment(name, addonId, stats[pos].time, cpowTime), false); } compartments.forget(aCompartments); return NS_OK; }
int main(int argc, char** argv) { qm::init("test_cpp_service"); ServiceImpl svc("hello", 20); // overridden svc impl svc.spin(); return 0; }
void syscall_gate() { __asm__("SYSTEM_CALL:"); __asm__("pushl $0"); store_reg(); svc(); restore_reg(); __asm__("add $4, %esp"); iret(); }
void RenderQueue::sort() { auto cameraDir = svc().defaultWorld().getCamera()->getDir(); auto cameraPos = svc().defaultWorld().getCamera()->getPosition(); auto &transparentOps = rops[RQ_BUCKET_TRANSPARENT]; std::sort(transparentOps.begin(), transparentOps.end(), [&cameraDir, &cameraPos](const RenderOperation &a, const RenderOperation &b) { auto d1 = glm::dot(cameraDir, glm::vec3(a.worldTransform[3]) - cameraPos); auto d2 = glm::dot(cameraDir, glm::vec3(b.worldTransform[3]) - cameraPos); return d1 > d2; }); auto &ops2D = rops[RQ_BUCKET_2D]; std::sort(ops2D.begin(), ops2D.end(), [](const RenderOperation &a, const RenderOperation &b) { return a.z < b.z; }); }
void Browser::removeService(const char *name) { Browser::Service svc(name); auto it = std::lower_bound(services_.begin(), services_.end(), svc); if (it != services_.end() && it->service_name == svc.service_name) { int index = it - services_.begin(); beginRemoveRows(QModelIndex(), index, index); services_.erase(it); endRemoveRows(); } }
void SCM::uninstall(const string& serviceName) { // Ensure there's a handle to the SCM database. openSvcManager(); AutoServiceHandle svc(::OpenService(scmHandle, serviceName.c_str(), DELETE)); QPID_WINDOWS_CHECK_NULL((SC_HANDLE)svc); QPID_WINDOWS_CHECK_NOT(::DeleteService(svc), 0); QPID_LOG(info, "Service deleted successfully."); }
void RenderTargetTexture::bind() { createGLFramebuffer(); if (!m_fbo) return; svc().renderMgr.getRenderer()->setViewport(m_viewport); glBindFramebuffer(GL_FRAMEBUFFER, m_fbo); m_texture->bind(0); }
void Slider::paintEvent(QPaintEvent* ev) { int h = height(); int w = width(); int kw = _sliderSize.width(); int kh = _sliderSize.height(); int pixel = (orient == Qt::Vertical) ? h - kh : w - kw; double range = maxValue() - minValue(); int ppos = int(pixel * (_value - minValue()) / range); if ((orient == Qt::Vertical && _invert) || (orient == Qt::Horizontal && !_invert)) ppos = pixel - ppos; QRect rr(ev->rect()); QPainter p(this); QColor sc(isEnabled() ? _scaleColor : Qt::gray); QColor svc(isEnabled() ? _scaleValueColor : Qt::gray); p.setBrush(svc); int kh2 = kh/2; //--------------------------------------------------- // draw scale //--------------------------------------------------- if (orient == Qt::Vertical) { int xm = (w - _scaleWidth - _sliderSize.height()) / 2; int y1 = kh2; int y2 = h - (ppos + y1); int y3 = h - y1; p.fillRect(xm, y1, _scaleWidth, y2-y1, _invert ? svc : sc); p.fillRect(xm, y2, _scaleWidth, y3-y2, _invert ? sc : svc); p.translate(QPointF(xm + _scaleWidth/2, y2)); } else { int ym = (h - _scaleWidth - _sliderSize.height()) / 2; int x1 = kh2; int x2 = w - (ppos + x1); int x3 = w - x1; p.fillRect(x1, ym, x2-x1, _scaleWidth, _invert ? sc : svc); p.fillRect(x2, ym, x3-x2, _scaleWidth, _invert ? svc : sc); p.translate(QPointF(x2, ym + _scaleWidth/2)); } //--------------------------------------------------- // draw slider //--------------------------------------------------- p.setRenderHint(QPainter::Antialiasing, true); p.setPen(QPen(svc, 0)); p.drawPath(*points); }
void thread_routine() { threadid = ff_getThreadID(); if (barrier) barrier->doBarrier(tid); void * ret; do { init_error=false; if (svc_init()<0) { error("ff_thread, svc_init failed, thread exit!!!\n"); init_error=true; break; } else { ret = svc(NULL); } svc_end(); if (disable_cancelability()) { error("ff_thread, thread_routine, could not change thread cancelability"); return; } // acquire lock. While freezing is true, // freeze and wait. pthread_mutex_lock(&mutex); if (ret != EOS_NOFREEZE && !stp) { if ((freezing == 0) && (ret == EOS)) stp = true; while(freezing==1) { // NOTE: freezing can change to 2 frozen=true; pthread_cond_signal(&cond_frozen); pthread_cond_wait(&cond,&mutex); } } //thawed=true; //pthread_cond_signal(&cond); //frozen=false; if (freezing != 0) freezing = 1; // freeze again next time pthread_mutex_unlock(&mutex); if (enable_cancelability()) { error("ff_thread, thread_routine, could not change thread cancelability"); return; } } while(!stp); if (freezing) { pthread_mutex_lock(&mutex); frozen=true; pthread_cond_signal(&cond_frozen); pthread_mutex_unlock(&mutex); } isdone = true; }
/** * \brief The life cycle of FastFlow thread * * It defines the life cycle of the FastFlow thread. * */ void thread_routine() { if (barrier) barrier->doBarrier(tid); void * ret; do { init_error=false; if (svc_init()<0) { error("ff_thread, svc_init failed, thread exit!!!\n"); init_error=true; break; } else { ret = svc(NULL); svc_releaseOCL(); } svc_end(); if (disable_cancelability()) { error("ff_thread, thread_routine, could not change thread cancelability"); return; } // acquire lock. While freezing is true, // freeze and wait. pthread_mutex_lock(&mutex); if (ret != (void*)FF_EOS_NOFREEZE && !stp) { // <-------------- CONTROLLARE aggiunto !stp while(freezing==1) { // NOTE: freezing can change to 2 frozen=true; pthread_cond_signal(&cond_frozen); pthread_cond_wait(&cond,&mutex); } } thawed=true; // <----------------- CONTROLLARE !!!! era thawed = frozen; pthread_cond_signal(&cond); frozen=false; if (freezing != 0) freezing = 1; // freeze again next time pthread_mutex_unlock(&mutex); if (enable_cancelability()) { error("ff_thread, thread_routine, could not change thread cancelability"); return; } } while(!stp); if (init_error && freezing) { pthread_mutex_lock(&mutex); frozen=true; pthread_cond_signal(&cond_frozen); pthread_mutex_unlock(&mutex); } }
void Browser::addService(AvahiIfIndex iface, AvahiProtocol protocol, const char *name, const char *type, const char *domain) { Browser::Service svc(name); if (!std::binary_search(services_.begin(), services_.end(), svc)) { // Start resolving the service svc.resolver.reset( avahi_s_service_resolver_new( server_.get(), iface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, static_cast<AvahiLookupFlags>(0), &Browser::resolverCallback, this)); auto it = std::upper_bound(services_.begin(), services_.end(), svc); int index = it - services_.begin(); beginInsertRows(QModelIndex(), index, index); services_.emplace(it, std::move(svc)); endInsertRows(); } }
void SupervoxelThread::run(void) { SvC svc( config_->getFloat("Sv_seed_resolution"), config_->getFloat("Sv_resolution") ); SvC::DistFunc dist = std::bind( &Segmentation::DefaultVoxelDistFunctor<DefaultMesh>::dist, vox_dist_, std::placeholders::_1, std::placeholders::_2, svc.getSeedResolution() ); svc.setDistFunctor(dist); timer_.restart(); MeshBundle<DefaultMesh>::PtrList::iterator iter; for(iter=inputs_.begin();iter!=inputs_.end();++iter) { MeshBundle<DefaultMesh>::Ptr &input = *iter; svc.input(&input->mesh_); svc.extract(input->graph_.voxel_label); input->custom_color_.fromlabel(input->graph_.voxel_label); svc.getCentroids(input->graph_.voxel_centers); svc.getCentroidColors(input->graph_.voxel_colors); svc.getCentroidNormals(input->graph_.voxel_normals); svc.getSizes(input->graph_.voxel_size); svc.getSupervoxelAdjacency(input->graph_.voxel_neighbors); } QString msg; int ms = timer_.elapsed(); int s = ms/1000; ms -= s*1000; int m = s/60; s -= m*60; int h = m/60; m -= h*60; msg = msg.sprintf("Time Used of Supervoxel:%02u:%02u:%02u.%03u",h,m,s,ms); emit message(msg,0); }
void SCM::stop(const string& serviceName) { // Ensure a handle to the SCM database. openSvcManager(); // Get a handle to the service. AutoServiceHandle svc(::OpenService(scmHandle, serviceName.c_str(), SERVICE_STOP | SERVICE_QUERY_STATUS | SERVICE_ENUMERATE_DEPENDENTS)); QPID_WINDOWS_CHECK_NULL(svc); // Make sure the service is not already stopped; if it's stop-pending, // wait for it to finalize. DWORD state = waitForStateChangeFrom(svc, SERVICE_STOP_PENDING); if (state == SERVICE_STOPPED) { QPID_LOG(info, "Service is already stopped"); return; } // If the service is running, dependencies must be stopped first. std::auto_ptr<ENUM_SERVICE_STATUS> deps; DWORD numDeps = getDependentServices(svc, deps); for (DWORD i = 0; i < numDeps; i++) stop(deps.get()[i].lpServiceName); // Dependents stopped; send a stop code to the service. SERVICE_STATUS_PROCESS ssp; if (!::ControlService(svc, SERVICE_CONTROL_STOP, (LPSERVICE_STATUS)&ssp)) throw qpid::Exception(QPID_MSG("Stopping " << serviceName << ": " << qpid::sys::strError(::GetLastError()))); // Wait for the service to stop. state = waitForStateChangeFrom(svc, SERVICE_STOP_PENDING); if (state == SERVICE_STOPPED) QPID_LOG(info, QPID_MSG("Service " << serviceName << " stopped successfully.")); }
nsICollation * Service::getLocaleCollation() { mMutex.AssertCurrentThreadOwns(); if (mLocaleCollation) return mLocaleCollation; nsCOMPtr<nsILocaleService> svc(do_GetService(NS_LOCALESERVICE_CONTRACTID)); if (!svc) { NS_WARNING("Could not get locale service"); return nsnull; } nsCOMPtr<nsILocale> appLocale; nsresult rv = svc->GetApplicationLocale(getter_AddRefs(appLocale)); if (NS_FAILED(rv)) { NS_WARNING("Could not get application locale"); return nsnull; } nsCOMPtr<nsICollationFactory> collFact = do_CreateInstance(NS_COLLATIONFACTORY_CONTRACTID); if (!collFact) { NS_WARNING("Could not create collation factory"); return nsnull; } rv = collFact->CreateCollation(appLocale, getter_AddRefs(mLocaleCollation)); if (NS_FAILED(rv)) { NS_WARNING("Could not create collation"); return nsnull; } return mLocaleCollation; }
void Knob::paintEvent(QPaintEvent* /*ev*/) { #if 0 // yet(?) unused QRect rr(ev->rect()); #endif QPainter p(this); p.setRenderHint(QPainter::Antialiasing, true); int markSize2 = _markSize/2; int restR = 360 - _scaleSize; int w = width() - _scaleWidth - 2 * _border; int h = height() - _scaleWidth/2 - 2 * _border; int xoffset, yoffset; if (_center) h -= _markSize; if (w > h) { yoffset = 0; xoffset = (w - h) / 2; w = h; } else { xoffset = 0; // yoffset = (h - w) / 2; // center yoffset = h - w; // top align h = w; } int x = xoffset + _scaleWidth / 2 + _border; int y = yoffset + _scaleWidth / 2 + _border + (_center ? _markSize+_scaleWidth/2 : 0); QRectF ar(x, y, w, h); QColor sc(isEnabled() ? _scaleColor : Qt::gray); QColor svc(isEnabled() ? _scaleValueColor : Qt::gray); //----------------------------------------- // draw arc //----------------------------------------- double dvalue = maxValue() - minValue(); if (_center) { int size = _scaleSize * 8; if (_value >= 0) { int offset = (restR-180) * 8; int r1 = int (size * _value / maxValue()); int r2 = size - r1; p.setPen(QPen(sc, _scaleWidth)); if (r2 > 1) p.drawArc(ar, offset, r2); if (size > 1) p.drawArc(ar, 90*16, size); if (r1 > 1) { p.setPen(QPen(svc, _scaleWidth)); p.drawArc(ar, offset+r2, r1); } } else { // int offset = (restR+180) * 8; int r1 = int(size * _value / minValue()); int r2 = size - r1; p.setPen(QPen(sc, _scaleWidth)); if (size > 1) p.drawArc(ar, (restR-180)*8, size); if (r2 > 1) p.drawArc(ar, 90 * 16 + r1, r2); if (r1 > 1) { p.setPen(QPen(svc, _scaleWidth)); p.drawArc(ar, 90*16, r1); } } } else { int offset = (180-restR) * 8; int size = _scaleSize * 16; int r1 = int(size * (_value - minValue()) / dvalue); int r2 = size - r1; if (r2 >= 1) { p.setPen(QPen(sc, _scaleWidth)); p.drawArc(ar, -offset, r2); } if (r1 >= 1) { p.setPen(QPen(svc, _scaleWidth)); p.drawArc(ar, r2-offset, r1); } } //----------------------------------------- // draw pointer //----------------------------------------- p.setPen(QPen(svc, _scaleWidth)); double r1 = double(_scaleSize) * (_value-minValue()) / dvalue + 90.0 + double(restR/2); r1 = r1 / 180.0 * M_PI; // convert to radians int rd = w/2; int x1 = x + rd; int y1 = y + rd; int x2 = x1 + lrint(cos(r1) * double(rd)); int y2 = y1 + lrint(sin(r1) * double(rd)); p.drawLine(x1, y1, x2, y2); //----------------------------------------- // draw center mark //----------------------------------------- p.setPen(QPen(svc, 0)); p.setBrush(svc); if (_center) { if (points) delete points; qreal x = ar.width() / 2 + ar.x(); qreal y = ar.y() - _markSize - _scaleWidth/2; points = new QPainterPath(QPointF(x - markSize2, y)); points->lineTo(x + markSize2, y); points->lineTo(x, _markSize + y); points->closeSubpath(); p.drawPath(*points); } //----------------------------------------- // draw text //----------------------------------------- if (!_text.isEmpty()) { p.drawText(ar, Qt::AlignBottom | Qt::AlignHCenter, _text); } }
ResourceGUID CreateGUIDFromPath(const std::string &path) { return svc().filesystem.fullPath(path); }
am_status_t BaseService::doRequest(const ServiceInfo& service, const BodyChunk& headerPrefix, const std::string& uriParameters, const Http::CookieList& cookieList, const BodyChunk& headerSuffix, const BodyChunkList& bodyChunkList, Http::Response& response, const ServerInfo** serverInfo) const { am_status_t status = AM_SERVICE_NOT_AVAILABLE; int dataLen = 0; BodyChunk emptyContentLine; // Create a temporary buffer for the Content-Line header // the extra '2' is for the <CR><LF> at the end. The // sizeof the CONTENT_LENGTH_HDR includes space for the // terminating NUL. const std::size_t contentLineLen_sz = sizeof (CONTENT_LENGTH_HDR) + (sizeof (dataLen) * DIGITS_PER_BYTE) + 2; char contentLine[contentLineLen_sz + 1]; std::size_t contentLineLen = 0; for (unsigned int i = 0; i < bodyChunkList.size(); ++i) { dataLen += bodyChunkList[i].data.size(); } memset(&contentLine[0], 0, contentLineLen_sz); contentLineLen = snprintf(contentLine, contentLineLen_sz, "%s%d\r\n", CONTENT_LENGTH_HDR, dataLen); if (contentLineLen_sz > contentLineLen && contentLineLen > 0) { BodyChunk contentLineChunk(contentLine, contentLineLen); ServiceInfo::const_iterator iter; ServiceInfo svc(service); int j = -1, current_index = -1; if (am_web_naming_validation_status() < 2 && svc.getNumberOfServers() > 1) { /* validation is enabled and number of servers is more than one */ char *current_value = read_naming_value(AM_NAMING_LOCK, Log::getLockId()); if (current_value != NULL) { current_index = strtol(current_value, NULL, 10); if (current_index < 0 || errno == ERANGE) { current_index = 0; } else { Log::log(logModule, Log::LOG_MAX_DEBUG, "BaseService::doRequest(): will be using url index: %d", current_index); } free(current_value); } else { current_index = 0; } if ((size_t) current_index >= svc.getNumberOfServers()) { Log::log(logModule, Log::LOG_WARNING, "BaseService::doRequest(): invalid url index: %d (out of %d); validation results ignored.", current_index, svc.getNumberOfServers()); current_index = -1; } } for (iter = svc.begin(); iter != svc.end(); ++iter) { const ServerInfo &svrInfo = (*iter); if (current_index != -1) { if ((++j) != current_index) { Log::log(logModule, Log::LOG_MAX_DEBUG, "BaseService::doRequest(): skipping url(%d) %s", j, svrInfo.getURL().c_str()); continue; } else { Log::log(logModule, Log::LOG_MAX_DEBUG, "BaseService::doRequest(): using url(%d) %s", j, svrInfo.getURL().c_str()); } } Http::HeaderList headerList, proxyHeaderList; Http::Cookie hostHeader("Host", svrInfo.getHost()); headerList.push_back(hostHeader); #ifdef AGENT_PROXY_SUPPORT #ifndef _MSC_VER if (useProxy) { proxyHeaderList.push_back(hostHeader); // Override (temporarily) server credentials if using proxy //svrInfo.setHost(proxyHost); //svrInfo.setPort(proxyPort); // We don't use SSL for initial proxy connection //svrInfo.setUseSSL(false); Log::log(logModule, Log::LOG_DEBUG, "BaseService::doRequest(): Using proxy: %s:%d", proxyHost.c_str(), proxyPort); // Add Proxy-Authorization header if user defined if (useProxyAuth) { // allocate enough for a base64-encoded digest size_t authSize = proxyUser.size() + proxyPassword.size() + 1; // 11 extra bytes for prefix and terminator char * digest = (char *) malloc(authSize * 4 / 3 + 11); strcpy(digest, "Basic "); encode_base64((proxyUser + ":" + proxyPassword).c_str(), authSize, (digest + 6)); Log::log(logModule, Log::LOG_MAX_DEBUG, "BaseService::doRequest(): Using proxy auth as: %s", proxyUser.c_str()); hostHeader = Http::Cookie("Proxy-Authorization", digest); proxyHeaderList.push_back(hostHeader); free(digest); } } #endif #endif // retry to connect to server before marking it as down. // making the number of attempts configurable may have a negative // side effect on performance, if the the value is a high number. int retryAttempts = 3; int retryCount = 0; while (retryCount < retryAttempts) { retryCount++; try { const char *operation = "sending to"; Connection conn(svrInfo.getHost().c_str(), svrInfo.getPort(), svrInfo.useSSL()); #ifdef AGENT_PROXY_SUPPORT std::string requestString = svrInfo.getURI().c_str(); /* * In case the following request would go to a proxy * we need to use full URL and special headers. */ if (useProxy && !(iter->useSSL())) { requestString = iter->getURL(); headerList = proxyHeaderList; } #endif status = sendRequest(conn, headerPrefix, svrInfo.getURI(), uriParameters, headerList, cookieList, dataLen > 0 ? contentLineChunk : emptyContentLine, headerSuffix, bodyChunkList); if (AM_SUCCESS == status) { operation = "receiving from"; status = response.readAndParse(logModule, conn); if (AM_SUCCESS == status) { Log::log(logModule, Log::LOG_MAX_DEBUG, "Response::readAndParse() (%d) %s", response.getBodyLen(), response.getBodyPtr() ? response.getBodyPtr() : "(NULL)"); } } if (AM_NSPR_ERROR == status) { Log::log(logModule, Log::LOG_ALWAYS, "BaseService::doRequest() NSPR failure while " "%s %s", operation, svrInfo.getURL().c_str()); } if (AM_SUCCESS == status) { break; } else { if (retryCount < retryAttempts) { continue; } else { Log::log(logModule, Log::LOG_DEBUG, "BaseService::doRequest() Invoking markSeverDown"); /*svrInfo.markServerDown(poll_primary_server);*/ } } } catch (const NSPRException& exc) { Log::log(logModule, Log::LOG_ERROR, "BaseService::doRequest() caught %s: %s called by %s", exc.what(), exc.getNsprMethod(), exc.getThrowingMethod()); if (retryCount < retryAttempts) { status = AM_NSPR_ERROR; continue; } else { Log::log(logModule, Log::LOG_ERROR, "BaseService::doRequest() Invoking markSeverDown"); /*svrInfo.markServerDown(poll_primary_server);*/ status = AM_NSPR_ERROR; } } } //end of while if (AM_SUCCESS == status) { break; } } // end of for } else { status = AM_BUFFER_TOO_SMALL; } return status; }
inline void *svc(void *task) { return svc(reinterpret_cast<T*>(task));};
ResourceMgrListenerImpl(MeshComponent *holder) : m_holder(holder) { svc().resourceMgr.addListener(this); }
~ResourceMgrListenerImpl() { svc().resourceMgr.removeListener(this); }
EIO_Status CConnTest::ServiceOkay(string* reason) { static const char kService[] = "bounce"; SConnNetInfo* net_info = ConnNetInfo_Create(kService, m_DebugPrintout); if (net_info) net_info->lb_disable = 1/*no local LB to use even if available*/; PreCheck(eStatelessService, 0/*main*/, "Checking whether NCBI services operational"); CConn_ServiceStream svc(kService, fSERV_Stateless, net_info, 0/*extra*/, m_Timeout); svc.SetCanceledCallback(m_Canceled); svc << kTest << NcbiEndl; string temp; svc >> temp; bool responded = temp.size() > 0 ? true : false; EIO_Status status = ConnStatus(NStr::Compare(temp, kTest) != 0, &svc); if (status == eIO_Interrupt) temp = kCanceled; else if (status == eIO_Success) temp = "OK"; else { char* str = net_info ? SERV_ServiceName(kService) : 0; if (str && NStr::CompareNocase(str, kService) == 0) { free(str); str = 0; } SERV_ITER iter = SERV_OpenSimple(kService); if (!iter || !SERV_GetNextInfo(iter)) { // Service not found SERV_Close(iter); iter = SERV_OpenSimple(kTest); if (!iter || !SERV_GetNextInfo(iter) || NStr::CompareNocase(SERV_MapperName(iter), "DISPD") != 0) { // Make sure there will be a mapper error printed SERV_Close(iter); temp.clear(); iter = 0; } else { // kTest service can be located but not kService temp = str ? "Substituted service" : "Service"; temp += " cannot be located"; } } else { temp = responded ? "Unrecognized" : "No"; temp += " response from "; temp += str ? "substituted service" : "service"; } if (!temp.empty()) { if (str) { temp += "; please remove ["; string upper(kService); temp += NStr::ToUpper(upper); temp += "]CONN_SERVICE_NAME=\""; temp += str; temp += "\" from your configuration\n"; } else if (status != eIO_Timeout || m_Timeout > kTimeout) temp += "; please contact " + HELP_EMAIL + '\n'; } if (status != eIO_Timeout) { const char* mapper = SERV_MapperName(iter); if (!mapper || NStr::CompareNocase(mapper, "DISPD") != 0) { temp += "Network dispatcher is not enabled as a service" " locator; please review your configuration to purge any" " occurrences of [CONN]DISPD_DISABLE off your settings\n"; } } else temp += x_TimeoutMsg(); SERV_Close(iter); if (str) free(str); } PostCheck(eStatelessService, 0/*main*/, status, temp); ConnNetInfo_Destroy(net_info); if (reason) reason->swap(temp); return status; }
void Drawbar::paintEvent(QPaintEvent*) { int h = height(); int w = width(); int kh = w * 2; // knob height int kw = w; int pixel = h - kh; int ppos = int(pixel * value() / 8.0); QPainter p(this); QColor sc(Qt::darkGray); QColor svc(Qt::gray); p.setBrush(svc); //--------------------------------------------------- // draw scale //--------------------------------------------------- int sx = (w + 9) / 10; int sw = w - 2 * sx; p.fillRect(sx, 0, sw, ppos, sc); QPen pen(Qt::white); int lw = 2; pen.setWidth(lw); p.setPen(pen); int sx1 = sx + lw/2; p.drawLine(sx1, 0, sx1, ppos); int sx2 = sx + sw - lw/2; p.drawLine(sx2, 0, sx2, ppos); //--------------------------------------------------- // draw numbers //--------------------------------------------------- p.save(); p.setClipRect(QRect(sx, 0, sw, ppos)); QFont f = p.font(); f.setPixelSize(8); int ch = pixel / 8; QString num("%1"); for (int i = 0; i < 8; ++i) { p.drawText(0, i * pixel / 8 - (pixel - ppos), w, ch, Qt::AlignCenter, num.arg(8-i)); } p.restore(); //--------------------------------------------------- // draw slider //--------------------------------------------------- p.fillRect(0, ppos, kw, kh, _sliderColor); pen.setWidth(1); pen.setColor(Qt::black); p.setPen(pen); int y1 = ppos + kh / 5 * 2; int y2 = ppos + kh / 5 * 3; p.drawLine(0, y1, kw, y1); p.drawLine(0, y2, kw, y2); }