int BIDSSensorLayer::updateState(double timef, double dt){ pvdata_t * output = getCLayer()->V; pvdata_t * input = blayer->getCLayer()->activity->data; int index; //Iterate through post layer for (int i = 0; i < nx * ny; i++){ assert(nf == 1); //Iterate through features // std::cout << "Node (" << coords[i].xCoord << ", " << coords[i].yCoord << ")\n"; for (int k = 0; k < nf; k++){ int x = i % nx; int y = (int) floor(i/nx); index = kIndex(x, y, k, nx, ny, nf); data[i][buf_index] = input[index] - (neutral_val / 256); // std::cout << "\tBuf_index: " << buf_index << ": " << data[i][buf_index] << "\n"; //Next buf index, or reset if at end float out = matchFilter(i, (int)(timef * dt)); output[index] = out * weight; } } if(buf_index < buf_size - 1){ buf_index++; } else{ buf_index = 0; } HyPerLayer::setActivity(); return PV_SUCCESS; }
void httpCreateRxPipeline(HttpConn *conn, HttpRoute *route) { HttpTx *tx; HttpRx *rx; HttpQueue *q; HttpStage *stage, *filter; int next; mprAssert(conn); mprAssert(route); rx = conn->rx; tx = conn->tx; rx->inputPipeline = mprCreateList(-1, 0); if (route) { for (next = 0; (filter = mprGetNextItem(route->inputStages, &next)) != 0; ) { if (matchFilter(conn, filter, route, HTTP_STAGE_RX) == HTTP_ROUTE_OK) { mprAddItem(rx->inputPipeline, filter); } } } mprAddItem(rx->inputPipeline, tx->handler); /* Create the incoming queue heads and open the queues. */ q = tx->queue[HTTP_QUEUE_RX]; for (next = 0; (stage = mprGetNextItem(rx->inputPipeline, &next)) != 0; ) { q = httpCreateQueue(conn, stage, HTTP_QUEUE_RX, q); } conn->readq = tx->queue[HTTP_QUEUE_RX]->prevQ; if (!conn->endpoint) { pairQueues(conn); openQueues(conn); } }
PUBLIC void httpCreateRxPipeline(HttpConn *conn, HttpRoute *route) { HttpTx *tx; HttpRx *rx; HttpQueue *q; HttpStage *stage, *filter; int next; assert(conn); assert(route); rx = conn->rx; tx = conn->tx; rx->inputPipeline = mprCreateList(-1, MPR_LIST_STABLE); if (route) { for (next = 0; (filter = mprGetNextItem(route->inputStages, &next)) != 0; ) { if (matchFilter(conn, filter, route, HTTP_STAGE_RX) == HTTP_ROUTE_OK) { mprAddItem(rx->inputPipeline, filter); } } } mprAddItem(rx->inputPipeline, tx->handler ? tx->handler : conn->http->clientHandler); /* Create the incoming queue heads and open the queues. */ q = tx->queue[HTTP_QUEUE_RX]; for (next = 0; (stage = mprGetNextItem(rx->inputPipeline, &next)) != 0; ) { q = httpCreateQueue(conn, stage, HTTP_QUEUE_RX, q); } if (httpClientConn(conn)) { pairQueues(conn); openQueues(conn); } }
void MessagesDialog::sinkMessage( const MsgEvent *msg ) { QMutexLocker locker( &messageLocker ); QPlainTextEdit *messages = ui.messages; /* Only scroll if the viewport is at the end. Don't bug user by auto-changing/losing viewport on insert(). */ bool b_autoscroll = ( messages->verticalScrollBar()->value() + messages->verticalScrollBar()->pageStep() >= messages->verticalScrollBar()->maximum() ); /* Copy selected text to the clipboard */ if( messages->textCursor().hasSelection() ) messages->copy(); /* Fix selected text bug */ if( !messages->textCursor().atEnd() || messages->textCursor().anchor() != messages->textCursor().position() ) messages->moveCursor( QTextCursor::End ); /* Start a new logic block so we can hide it on-demand */ messages->textCursor().insertBlock(); QString buf = QString( "<i><font color='darkblue'>%1</font>" ).arg( msg->module ); switch ( msg->priority ) { case VLC_MSG_INFO: buf += "<font color='blue'> info: </font>"; break; case VLC_MSG_ERR: buf += "<font color='red'> error: </font>"; break; case VLC_MSG_WARN: buf += "<font color='green'> warning: </font>"; break; case VLC_MSG_DBG: default: buf += "<font color='grey'> debug: </font>"; break; } /* Insert the prefix */ messages->textCursor().insertHtml( buf /* + "</i>" */ ); /* Insert the message */ messages->textCursor().insertHtml( msg->text ); /* Pass the new message thru the filter */ QTextBlock b = messages->document()->lastBlock(); b.setVisible( matchFilter( b.text() ) ); /* Tell the QTextDocument to recompute the size of the given area */ messages->document()->markContentsDirty( b.position(), b.length() ); if ( b_autoscroll ) messages->ensureCursorVisible(); }
void PublicHubsFrame::updateList() { //CLockRedraw<> l_lock_draw(m_ctrlHubs); m_ctrlHubs.DeleteAllItems(); users = 0; visibleHubs = 0; double size = -1; FilterModes mode = NONE; int sel = ctrlFilterSel.GetCurSel(); bool doSizeCompare = parseFilter(mode, size); auto cnt = m_ctrlHubs.GetItemCount(); for (auto i = m_hubs.cbegin(); i != m_hubs.cend(); ++i) { if (matchFilter(*i, sel, doSizeCompare, mode, size)) { TStringList l; l.resize(COLUMN_LAST); l[COLUMN_NAME] = Text::toT(i->getName()); string l_description = i->getDescription(); boost::replace_all(l_description, ".px.", ""); l[COLUMN_DESCRIPTION] = Text::toT(l_description); l[COLUMN_USERS] = Util::toStringW(i->getUsers()); l[COLUMN_SERVER] = Text::toT(i->getServer()); l[COLUMN_COUNTRY] = Text::toT(i->getCountry()); // !SMT!-IP l[COLUMN_SHARED] = Util::formatBytesW(i->getShared()); l[COLUMN_MINSHARE] = Util::formatBytesW(i->getMinShare()); l[COLUMN_MINSLOTS] = Util::toStringW(i->getMinSlots()); l[COLUMN_MAXHUBS] = Util::toStringW(i->getMaxHubs()); l[COLUMN_MAXUSERS] = Util::toStringW(i->getMaxUsers()); l[COLUMN_RELIABILITY] = Util::toStringW(i->getReliability()); l[COLUMN_RATING] = Text::toT(i->getRating()); const auto l_country = i->getCountry(); dcassert(!l_country.empty()); const auto l_index_country = WinUtil::getFlagIndexByName(l_country.c_str()); //const auto l_index = m_ctrlHubs.insert(cnt++, l, l_index_country); // !SMT!-IP /* LVITEM lvItem = { 0 }; lvItem.mask = LVIF_IMAGE; lvItem.iItem = l_index; lvItem.iImage = isOnline(i->getServer()) ? 0 : 1; m_ctrlHubs.SetItem(&lvItem); */ visibleHubs++; users += i->getUsers(); } } m_ctrlHubs.resort(); updateStatus(); }
void PublicHubsFrame::updateList() { ctrlHubs.DeleteAllItems(); users = 0; visibleHubs = 0; ctrlHubs.SetRedraw(FALSE); double size = -1; FilterModes mode = NONE; int sel = ctrlFilterSel.GetCurSel(); bool doSizeCompare = parseFilter(mode, size); for(HubEntryList::const_iterator i = hubs.begin(); i != hubs.end(); ++i) { if(matchFilter(*i, sel, doSizeCompare, mode, size)) { TStringList l; l.resize(COLUMN_LAST); l[COLUMN_NAME] = Text::toT(i->getName()); l[COLUMN_DESCRIPTION] = Text::toT(i->getDescription()); l[COLUMN_USERS] = Text::toT(Util::toString(i->getUsers())); l[COLUMN_SERVER] = Text::toT(i->getServer()); l[COLUMN_COUNTRY] = Text::toT(i->getCountry()); l[COLUMN_SHARED] = Text::toT(Util::formatBytes(i->getShared())); l[COLUMN_MINSHARE] = Text::toT(Util::formatBytes(i->getMinShare())); l[COLUMN_MINSLOTS] = Text::toT(Util::toString(i->getMinSlots())); l[COLUMN_MAXHUBS] = Text::toT(Util::toString(i->getMaxHubs())); l[COLUMN_MAXUSERS] = Text::toT(Util::toString(i->getMaxUsers())); l[COLUMN_RELIABILITY] = Text::toT(Util::toString(i->getReliability())); l[COLUMN_RATING] = Text::toT(i->getRating()); ctrlHubs.insert(ctrlHubs.GetItemCount(), l); visibleHubs++; users += i->getUsers(); } } ctrlHubs.SetRedraw(TRUE); ctrlHubs.resort(); updateStatus(); }
void MessagesDialog::filterMessages() { QMutexLocker locker( &messageLocker ); QPlainTextEdit *messages = ui.messages; QTextBlock block = messages->document()->firstBlock(); while( block.isValid() ) { block.setVisible( matchFilter( block.text().toLower() ) ); block = block.next(); } /* Consider the whole QTextDocument as dirty now */ messages->document()->markContentsDirty( 0, messages->document()->characterCount() ); /* FIXME This solves a bug (Qt?) with the viewport not resizing the vertical scroll bar when one or more QTextBlock are hidden */ QSize vsize = messages->viewport()->size(); messages->viewport()->resize( vsize + QSize( 1, 1 ) ); messages->viewport()->resize( vsize ); }
void FeatureMatcher::match( Frame* reference_frame, Frame* target_frame, const Eigen::Isometry3d& init_motion_est ) { init_matches.clear(); no_repeat_matches.clear(); matches.clear(); final_matches.clear(); bf_matcher.match( reference_frame->descriptors, target_frame->descriptors, init_matches ); std::cout<<"Find init_match "<< init_matches.size() << " matches."<< std::endl; num_InitMatches = init_matches.size(); matchFilter( reference_frame, target_frame, init_motion_est ); num_NoRepeatMatches = no_repeat_matches.size(); #ifdef USE_MAX_CONNECTED_DOMAIN timer("max_connected"); _maxConDom->computeMaxConnectedDomain( reference_frame, target_frame, no_repeat_matches ); num_Matches = _maxConDom->nums_triangle; std::cout << "final matches number: "<< num_Matches << std::endl; for( int i=0; i < num_Matches; i++ ) { matches.push_back( no_repeat_matches[ _maxConDom->final_domain[i] ] ); } timer("max_connected"); #else num_Matches = num_NoRepeatMatches; matches = no_repeat_matches; #endif #ifdef USE_MAX_CLIQUE timer("max_clique"); computeMaximallyConsistentClique( reference_frame, target_frame ); timer("max_clique"); #else num_final_Matches = num_Matches; final_matches = matches; #endif //---------------------------------------------------- //-------------画出,最后的匹配图--------------------- // cv::drawMatches( reference_frame->rgb_img, // reference_frame->keypoints, // target_frame->rgb_img, // target_frame->keypoints, // matches, // imgMatch, // cv::Scalar(0,0,255), // cv::Scalar(255,0,0) ); // cv::imshow( "imgMatch", imgMatch ); // cv::waitKey(0); //------------------------------------------------------- }
void httpCreateTxPipeline(HttpConn *conn, HttpRoute *route) { Http *http; HttpTx *tx; HttpRx *rx; HttpQueue *q; HttpStage *stage, *filter; int next, hasOutputFilters; mprAssert(conn); mprAssert(route); http = conn->http; rx = conn->rx; tx = conn->tx; tx->outputPipeline = mprCreateList(-1, 0); if (tx->handler == 0) { tx->handler = http->passHandler; } mprAddItem(tx->outputPipeline, tx->handler); hasOutputFilters = 0; if (route->outputStages) { for (next = 0; (filter = mprGetNextItem(route->outputStages, &next)) != 0; ) { if (matchFilter(conn, filter, route, HTTP_STAGE_TX) == HTTP_ROUTE_OK) { mprAddItem(tx->outputPipeline, filter); mprLog(4, "Select output filter: \"%s\"", filter->name); hasOutputFilters = 1; } } } if (tx->connector == 0) { if (tx->handler == http->fileHandler && (rx->flags & HTTP_GET) && !hasOutputFilters && !conn->secure && httpShouldTrace(conn, HTTP_TRACE_TX, HTTP_TRACE_BODY, tx->ext) < 0) { tx->connector = http->sendConnector; } else if (route && route->connector) { tx->connector = route->connector; } else { tx->connector = http->netConnector; } } mprAddItem(tx->outputPipeline, tx->connector); mprLog(4, "Select connector: \"%s\"", tx->connector->name); /* Create the outgoing queue heads and open the queues */ q = tx->queue[HTTP_QUEUE_TX]; for (next = 0; (stage = mprGetNextItem(tx->outputPipeline, &next)) != 0; ) { q = httpCreateQueue(conn, stage, HTTP_QUEUE_TX, q); } conn->writeq = tx->queue[HTTP_QUEUE_TX]->nextQ; conn->connectorq = tx->queue[HTTP_QUEUE_TX]->prevQ; pairQueues(conn); /* Put the header before opening the queues incase an open routine actually services and completes the request httpHandleOptionsTrace does this when called from openFile() in fileHandler. */ httpPutForService(conn->writeq, httpCreateHeaderPacket(), HTTP_DELAY_SERVICE); openQueues(conn); /* Refinalize if httpFinalize was called before the Tx pipeline was created */ if (conn->refinalize) { conn->finalized = 0; httpFinalize(conn); } }
int updatePCSCSlots(struct p11SlotPool_t *pool) { struct p11Slot_t *slot,*vslot; LPTSTR readers = NULL; char *filter, *prealloc; DWORD cch = 0; // DWORD cch = SCARD_AUTOALLOCATE; LPTSTR p; LONG rc; int match,vslotcnt,i; FUNC_CALLED(); /* * Create a context if not already done */ if (!globalContext) { rc = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &globalContext); #ifdef DEBUG debug("SCardEstablishContext: %s\n", pcsc_error_to_string(rc)); #endif if (rc != SCARD_S_SUCCESS) { FUNC_FAILS(CKR_DEVICE_ERROR, "Could not establish context to PC/SC manager"); } } rc = SCardListReaders(globalContext, NULL, NULL, &cch); #ifdef DEBUG debug("SCardListReaders: %s\n", pcsc_error_to_string(rc)); #endif if (rc == SCARD_E_NO_READERS_AVAILABLE) { FUNC_RETURNS(CKR_OK); } if (rc != SCARD_S_SUCCESS) { FUNC_FAILS(CKR_DEVICE_ERROR, "Error listing PC/SC card terminals"); } readers = calloc(cch, 1); rc = SCardListReaders(globalContext, NULL, readers, &cch); #ifdef DEBUG debug("SCardListReaders: %s\n", pcsc_error_to_string(rc)); #endif if (rc == SCARD_E_NO_READERS_AVAILABLE) { FUNC_RETURNS(CKR_OK); } if (rc != SCARD_S_SUCCESS) { FUNC_FAILS(CKR_DEVICE_ERROR, "Error listing PC/SC card terminals"); } filter = getenv("PKCS11_READER_FILTER"); #ifdef DEBUG if (filter) { debug("Reader filter '%s'\n", filter); } #endif /* Determine the total number of readers */ p = readers; while (*p != '\0') { #ifdef DEBUG debug("Found reader '%s'\n", p); #endif /* Check if we already have a slot for the reader */ slot = pool->list; match = FALSE; while (slot) { if (strncmp(slot->readername, p, strlen(p)) == 0) { match = TRUE; break; } slot = slot->next; } /* Skip the reader as we already have a slot for it */ if (match) { p += strlen(p) + 1; slot->closed = FALSE; continue; } if (!matchFilter(p, filter)) { p += strlen(p) + 1; continue; } slot = (struct p11Slot_t *) calloc(1, sizeof(struct p11Slot_t)); if (slot == NULL) { free(readers); FUNC_FAILS(CKR_HOST_MEMORY, "Out of memory"); } /* If a reader filter is defined, then slot ids for that reader are * derived from the reader name using a CRC32 value. If the token * in the reader allocated virtual slots, then these have incremented * slot ids. * * This is not enabled by default to prevent slot id collisions */ if (filter) slot->id = crc32(0, p, strlen(p)); rc = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &(slot->context)); #ifdef DEBUG debug("SCardEstablishContext: %s\n", pcsc_error_to_string(rc)); #endif if (rc != SCARD_S_SUCCESS) { free(slot); free(readers); FUNC_FAILS(CKR_DEVICE_ERROR, "Could not establish context to PC/SC manager"); } slotCounter++; strbpcpy(slot->info.slotDescription, (char *)p, sizeof(slot->info.slotDescription)); strcpy(slot->readername, (char *)p); strbpcpy(slot->info.manufacturerID, "CardContact", sizeof(slot->info.manufacturerID)); slot->info.hardwareVersion.minor = 0; slot->info.hardwareVersion.major = 0; slot->info.firmwareVersion.major = VERSION_MAJOR; slot->info.firmwareVersion.minor = VERSION_MINOR; slot->info.flags = CKF_REMOVABLE_DEVICE | CKF_HW_SLOT; // The REINER SCT readers have an APDU buffer limitation of 1014 bytes if (!strncmp((char *)p, "REINER SCT", 10)) { #ifdef DEBUG debug("Detected a REINER SCT reader\n"); #endif if (!strncmp((char *)p, "REINER SCT cyberJack ecom_a", 27)) { #ifdef DEBUG debug("Detected a 'REINER SCT cyberJack ecom_a' reader. Limiting use of Le='000000'\n"); #endif // Some REINER SCT readers fail if Le='000000' returns more than // 1014 bytes. slot->noExtLengthReadAll = 1; } slot->maxRAPDU = 1000; slot->maxCAPDU = 1000; } addSlot(&context->slotPool, slot); #ifdef DEBUG debug("Added slot (%lu, %s) - slot counter is %i\n", slot->id, slot->readername, slotCounter); #endif // The PREALLOCATE option creates two additional virtual slots per card reader. // This is required for Firefox/NSS which sets the friendly flag only for slots that are // already present during the first C_GetSlotList prealloc = getenv("PKCS11_PREALLOCATE_VIRTUAL_SLOTS"); if (prealloc) { vslotcnt = *prealloc; if ((vslotcnt == '1') || (vslotcnt == '2')) { vslotcnt -= '0'; } else { vslotcnt = 2; } #ifdef DEBUG debug("Pre-allocate virtual slots '' %d\n", prealloc, vslotcnt); #endif for (i = 0; i < vslotcnt; i++) { getVirtualSlot(slot, i, &vslot); } } checkForNewPCSCToken(slot); p += strlen(p) + 1; } free(readers); FUNC_RETURNS(CKR_OK); }
PUBLIC void httpCreateTxPipeline(HttpConn *conn, HttpRoute *route) { Http *http; HttpTx *tx; HttpRx *rx; HttpQueue *q; HttpStage *stage, *filter; int next, hasOutputFilters; assert(conn); assert(route); http = conn->http; rx = conn->rx; tx = conn->tx; tx->outputPipeline = mprCreateList(-1, 0); if (conn->endpoint) { if (tx->handler == 0 || tx->finalized) { tx->handler = http->passHandler; } mprAddItem(tx->outputPipeline, tx->handler); } hasOutputFilters = 0; if (route->outputStages) { for (next = 0; (filter = mprGetNextItem(route->outputStages, &next)) != 0; ) { if (matchFilter(conn, filter, route, HTTP_STAGE_TX) == HTTP_ROUTE_OK) { mprAddItem(tx->outputPipeline, filter); if (rx->traceLevel >= 0) { mprLog(rx->traceLevel, "Select output filter: \"%s\"", filter->name); } hasOutputFilters = 1; } } } if (tx->connector == 0) { #if !BIT_ROM if (tx->handler == http->fileHandler && (rx->flags & HTTP_GET) && !hasOutputFilters && !conn->secure && httpShouldTrace(conn, HTTP_TRACE_TX, HTTP_TRACE_BODY, tx->ext) < 0) { tx->connector = http->sendConnector; } else #endif if (route && route->connector) { tx->connector = route->connector; } else { tx->connector = http->netConnector; } } mprAddItem(tx->outputPipeline, tx->connector); if (rx->traceLevel >= 0) { mprLog(rx->traceLevel + 1, "Select connector: \"%s\"", tx->connector->name); } /* Create the outgoing queue heads and open the queues */ q = tx->queue[HTTP_QUEUE_TX]; for (next = 0; (stage = mprGetNextItem(tx->outputPipeline, &next)) != 0; ) { q = httpCreateQueue(conn, stage, HTTP_QUEUE_TX, q); } conn->connectorq = tx->queue[HTTP_QUEUE_TX]->prevQ; /* Double the connector max hi-water mark. This optimization permits connectors to accept packets without unnecesary flow control. */ conn->connectorq->max *= 2; pairQueues(conn); /* Put the header before opening the queues incase an open routine actually services and completes the request */ httpPutForService(conn->writeq, httpCreateHeaderPacket(), HTTP_DELAY_SERVICE); /* Open the pipelien stages. This calls the open entrypoints on all stages */ openQueues(conn); }
bool TransferListSortModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { return matchFilter(sourceRow, sourceParent) && QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent); }
/* * Create stages for the request pipeline. */ void maCreatePipeline(MaConn *conn) { MaHttp *http; MaHost *host; MaResponse *resp; MaRequest *req; MaStage *handler; MaLocation *location; MaStage *stage, *connector; MaFilter *filter; MaQueue *q, *qhead, *rq, *rqhead; int next; req = conn->request; resp = conn->response; host = req->host; location = req->location; handler = resp->handler; http = conn->http; mprAssert(req); mprAssert(location->outputStages); /* * Create the output pipeline for this request. Handler first, then filters, connector last. */ resp->outputPipeline = mprCreateList(resp); /* * Add the handler and filters. Switch to the pass handler if any errors have occurred so far. Only add the * filters if the request has not failed. */ if (conn->requestFailed) { resp->handler = http->passHandler; mprAddItem(resp->outputPipeline, resp->handler); } else { mprAddItem(resp->outputPipeline, resp->handler); for (next = 0; (filter = mprGetNextItem(location->outputStages, &next)) != 0; ) { if (filter->stage == http->authFilter) { if (req->auth->type == 0 && req->auth->type == 0) { continue; } } if (filter->stage == http->rangeFilter && (req->ranges == 0 || handler == http->fileHandler)) { continue; } if ((filter->stage->flags & MA_STAGE_ALL & req->method) == 0) { continue; } /* * Remove the chunk filter chunking if it is explicitly turned off vi a the X_APPWEB_CHUNK_SIZE header setting * the chunk size to zero. Also remove if using the fileHandler which always knows the entity length and an * explicit chunk size has not been requested. */ if (filter->stage == http->chunkFilter) { if ((handler == http->fileHandler && resp->chunkSize < 0) || resp->chunkSize == 0) { continue; } } if (matchFilter(conn, filter)) { mprAddItem(resp->outputPipeline, filter->stage); } } } connector = location->connector; #if BLD_FEATURE_SEND if (resp->handler == http->fileHandler && connector == http->netConnector && http->sendConnector && !req->ranges && !host->secure) { /* * Switch (transparently) to the send connector if serving whole static file content via the net connector */ connector = http->sendConnector; } #endif resp->connector = connector; if ((connector->flags & MA_STAGE_ALL & req->method) == 0) { maFailRequest(conn, MPR_HTTP_CODE_BAD_REQUEST, "Connector \"%s\" does not support the \"%s\" method \"%s\"", connector->name, req->methodName); return; } mprAddItem(resp->outputPipeline, connector); /* * Create the outgoing queue heads and open the queues */ q = &resp->queue[MA_QUEUE_SEND]; for (next = 0; (stage = mprGetNextItem(resp->outputPipeline, &next)) != 0; ) { q = maCreateQueue(conn, stage, MA_QUEUE_SEND, q); } /* * Create the receive pipeline for this request. Connector first, handler last */ if (req->remainingContent > 0) { req->inputPipeline = mprCreateList(resp); mprAddItem(req->inputPipeline, connector); if (!conn->requestFailed) { for (next = 0; (filter = mprGetNextItem(location->inputStages, &next)) != 0; ) { if (filter->stage == http->authFilter || !matchFilter(conn, filter)) { continue; } if ((filter->stage->flags & MA_STAGE_ALL & req->method) == 0) { continue; } mprAddItem(req->inputPipeline, filter->stage); } } mprAddItem(req->inputPipeline, handler); /* * Create the incoming queue heads and open the queues. */ q = &resp->queue[MA_QUEUE_RECEIVE]; for (next = 0; (stage = mprGetNextItem(req->inputPipeline, &next)) != 0; ) { q = maCreateQueue(conn, stage, MA_QUEUE_RECEIVE, q); } } /* * Pair up the send and receive queues. NOTE: can't use a stage multiple times. */ qhead = &resp->queue[MA_QUEUE_SEND]; rqhead = &resp->queue[MA_QUEUE_RECEIVE]; for (q = qhead->nextQ; q != qhead; q = q->nextQ) { for (rq = rqhead->nextQ; rq != rqhead; rq = rq->nextQ) { if (q->stage == rq->stage) { q->pair = rq; rq->pair = q; } } } /* * Open the queues (keep going on errors) */ qhead = &resp->queue[MA_QUEUE_SEND]; for (q = qhead->nextQ; q != qhead; q = q->nextQ) { if (q->open && !(q->flags & MA_QUEUE_OPEN)) { q->flags |= MA_QUEUE_OPEN; openQ(q); } } if (req->remainingContent > 0) { qhead = &resp->queue[MA_QUEUE_RECEIVE]; for (q = qhead->nextQ; q != qhead; q = q->nextQ) { if (q->open && !(q->flags & MA_QUEUE_OPEN)) { if (q->pair == 0 || !(q->pair->flags & MA_QUEUE_OPEN)) { q->flags |= MA_QUEUE_OPEN; openQ(q); } } } } }
PUBLIC void httpCreateTxPipeline(HttpConn *conn, HttpRoute *route) { Http *http; HttpTx *tx; HttpRx *rx; HttpQueue *q; HttpStage *stage, *filter; int next; assert(conn); assert(route); http = conn->http; rx = conn->rx; tx = conn->tx; tx->outputPipeline = mprCreateList(-1, MPR_LIST_STABLE); if (httpServerConn(conn)) { if (tx->handler == 0 || tx->finalized) { tx->handler = http->passHandler; } mprAddItem(tx->outputPipeline, tx->handler); } if (route->outputStages) { for (next = 0; (filter = mprGetNextItem(route->outputStages, &next)) != 0; ) { if (matchFilter(conn, filter, route, HTTP_STAGE_TX) == HTTP_ROUTE_OK) { mprAddItem(tx->outputPipeline, filter); tx->flags |= HTTP_TX_HAS_FILTERS; } } } if (tx->connector == 0) { #if !ME_ROM if (tx->handler == http->fileHandler && (rx->flags & HTTP_GET) && !(tx->flags & HTTP_TX_HAS_FILTERS) && !conn->secure && !httpTracing(conn)) { tx->connector = http->sendConnector; } else #endif tx->connector = (route && route->connector) ? route->connector : http->netConnector; } mprAddItem(tx->outputPipeline, tx->connector); /* Create the outgoing queue heads and open the queues */ q = tx->queue[HTTP_QUEUE_TX]; for (next = 0; (stage = mprGetNextItem(tx->outputPipeline, &next)) != 0; ) { q = httpCreateQueue(conn, stage, HTTP_QUEUE_TX, q); } conn->connectorq = tx->queue[HTTP_QUEUE_TX]->prevQ; /* Double the connector max hi-water mark. This optimization permits connectors to accept packets without unnecesary flow control. */ conn->connectorq->max *= 2; pairQueues(conn); /* Put the header before opening the queues incase an open routine actually services and completes the request */ httpPutForService(conn->writeq, httpCreateHeaderPacket(), HTTP_DELAY_SERVICE); /* Open the pipeline stages. This calls the open entrypoints on all stages. */ openQueues(conn); if (conn->error) { if (tx->handler != http->passHandler) { tx->handler = http->passHandler; httpAssignQueue(conn->writeq, tx->handler, HTTP_QUEUE_TX); } } tx->flags |= HTTP_TX_PIPELINE; if (conn->endpoint) { httpTrace(conn, "request.pipeline", "context", "route:'%s',handler:'%s',target:'%s',endpoint:'%s:%d',host:'%s',referrer:'%s',filename:'%s'", rx->route->pattern, tx->handler->name, rx->route->targetRule, conn->endpoint->ip, conn->endpoint->port, conn->host->name ? conn->host->name : "default", rx->referrer ? rx->referrer : "", tx->filename ? tx->filename : ""); } }