Ejemplo n.º 1
0
/*
 * @brief Handle a request for a child device.
 * @param header the incoming_header
 * @param param_data The param_data
 * @param child_index The child device index.
 */
static int HandleChildRequest(const RDMHeader *header,
                              const uint8_t *param_data,
                              unsigned int child_index) {
  if (header->command_class == DISCOVERY_COMMAND) {
    // Always pass discovery commands through to the child.
    return HandleRequest(header, param_data);
  }

  ChildDevice *device = &g_children[child_index];

  // If GET QUEUED_MESSAGE and there is next or last message, see if we need to
  // return it.
  int response_size = RDM_RESPONDER_NO_RESPONSE;
  if (header->command_class == GET_COMMAND &&
      ntohs(header->param_id) == PID_QUEUED_MESSAGE &&
      device->free_size_count != PROXY_BUFFERS_PER_CHILD &&
      RDMUtil_IsUnicast(header->dest_uid)) {
    response_size = MaybeRespondWithQueuedMessage(header, param_data,
                                                  child_index);
    if (response_size) {
      return response_size;
    }
  }

  // If the request is unicast, and we're out of buffer space then NACK.
  if (RDMUtil_IsUnicast(header->dest_uid) && device->next != NULL) {
    return RDMResponder_BuildNack(header, NR_PROXY_BUFFER_FULL);
  }

  // Let the child handle the request.
  response_size = HandleRequest(header, param_data);
  const RDMHeader *response_header = (RDMHeader*) g_rdm_buffer;
  // Only queue the frame if the message length is correct
  if (response_size >= (int) sizeof(RDMHeader) + (int) RDM_CHECKSUM_LENGTH &&
      ((int) response_header->message_length + (int) RDM_CHECKSUM_LENGTH ==
       response_size)) {
    if (device->next == NULL) {
      // Queue the response
      device->next = device->free_list[device->free_size_count - 1];
      device->free_size_count--;

      memcpy(device->next->buffer, g_rdm_buffer, response_size);
      response_size = RDMResponder_BuildAckTimer(header, ACK_TIMER_DELAY);
      g_responder->queued_message_count = 1u;
    } else {
      // Something has gone wrong, and we don't have space to queue the
      // response. Nack with a hardware fault.
      return RDMResponder_BuildNack(header, NR_HARDWARE_FAULT);
    }
  }
  return response_size;
}
Ejemplo n.º 2
0
vector<string>* Session::GetBlacklist(string configId) {
    AuthRequest* authRequest = new AuthRequest(consumerKey, consumerSecret, configId, applicationName);
    QueryMethod method = GET;
    string url = host + "/blacklist." + format;
    cout << endl << "url: " << url << endl;
    int status = authRequest->authWebRequest(url, method);

    vector<string>* result = new vector<string>();
    if (status <= 202 && "" != authRequest->GetReceivedData()) {
        Stub_Blacklist* stub = new Stub_Blacklist();
        if (format == "xml") {
            (static_cast<XmlSerializer*>(serializer))->Deserialize(authRequest->GetReceivedData(), stub);
        } else {
            (static_cast<JsonSerializer*>(serializer))->Deserialize(authRequest->GetReceivedData(), stub);
        }
        result = stub->GetBlacklistItems();

        // @TODO don't forget that items are stored in stub, so if
        // we delete items in stub's destructor - all items from result
        // will be removed too.
        // maybe we should use smart pointer?
        delete stub;
    }
    HandleRequest(method, url, "");
    HandleConfigurationResponse(status, authRequest);

    delete authRequest;

    return result;
}
Ejemplo n.º 3
0
	void WebServer::HandleGetRequest(http_request message)
	{
		HTTPRequest request(message);
		auto service = request.GetArgumentValue("service");

		if (wms && service == "WMS")
		{
			return wms->HandleRequest(request);
		}
		else if (wmts && service == "WMTS")
		{
			return wmts->HandleRequest(request);
		}

		return HandleServiceException(request, "unknown service request");
	}
Ejemplo n.º 4
0
void * StarServer(void * client)
{
    http_request * request = CreateRequest();

    int client_socket;
    client_socket = *(int *)client;

    int server_status;
    server_status = GetContent(client_socket, request->buf, HTTP_REQUEST_BUF_MAX_LENGTH);

    if(server_status)
    {
        if(server_status==-1)
            ReturnError(400,client_socket);
        if(server_status==-2)
            ReturnError(414,client_socket);
    }
    else
    {
        int analysis_status = 0;
        analysis_status = AnalysisRequest(request);

        if(analysis_status)
            ReturnError(analysis_status, client_socket);
        else
            HandleRequest(client_socket, request);
    }
    DestroyRequest(request);
    close(client_socket);

    return NULL;
}
Ejemplo n.º 5
0
void IrcBot::ReadHandler(const boost::system::error_code &error, std::size_t bytesRead)
{
	if (shuttingDown)
	{
		return;
	}
	if (!error)
	{
		messageString = readBuffer.data();

		std::cout << std::string(readBuffer.data(), bytesRead);
		HandlePing(messageString);

		// handle welcome message 001
		if (messageString.find(serverWelcomeMessage) == 0)//if (messageString.find(":" + serverName + " 001") == 0)
		{
			Send(join);
		}
		HandleRequest(messageString);

		if (activeGame != NONE)
		{
			HandleGameInput(messageString);
		}

		readBuffer.fill('\0');
		sock.async_read_some(buffer(readBuffer), [this](boost::system::error_code ec, std::size_t bytesRead) { ReadHandler(ec, bytesRead); });
	}
	else
	{
		ConsoleMessage(error.message());
	}
}
Ejemplo n.º 6
0
//This function will accept and process file Get messages from other peers
void StartQHandler(void)
{
  int NewConnSocketNo;
  int TempInt1;
  int CurrPort = 18200;
  CurrPort = qPort + 200;
  struct sockaddr_in NewConnSocket;
  //Listen for messages on MPrt for ever
  printf("----QHandler Started\n");
  if(listen(qPortSocket, 10) < 0)
  {
    printf("--------Node in an Unstable Condition, close the node App by keying Ctrl C---------\n");
    exit(0);
    //continue;
  }
  while(1)
  {
    //Listen for new Connections
    TempInt1 = sizeof(NewConnSocket);
    if((NewConnSocketNo = accept(qPortSocket, (struct sockaddr *) &NewConnSocket, &TempInt1)) < 0)
    {
      continue;
    }
    if((TempInt1 = fork()) == 0)
    {
      HandleRequest(NewConnSocketNo, NewConnSocket, CurrPort++);
      exit(0);
    }
  }
}
Ejemplo n.º 7
0
void FileUpload::Execute()
{
    if (HasRequest() && mState != eClient_STATE_CONNECTED) // 有上传请求 && 尚未连接
    {
        TryConnectServer();
    }
    
    if (mState == eClient_STATE_CONNECTED) // 已连接上
    {
        //if (CanSendData())
        {
            UploadRequest* Req = PopRequest();
            if (Req)
            {
                if (HandleRequest(Req))
                {
                    // Req已放入WaitingList, 暂不回收
                }
                else
                {
                    AddResponse(*Req, false, "");
                    delete Req;
                }
            }
        }
        
        if (CanRecvData() && mRecvSize < MAX_RECV_BUFF_SIZE)
        {
            int Ret = recv(mSocket, &mRecvBuff[mRecvSize], MAX_RECV_BUFF_SIZE - mRecvSize, 0);
            if (Ret == SOCKET_ERROR || Ret <= 0)
            {
                CloseSocket(eClient_STATE_ABORT, true); // TODO: 当服务器send主动关闭时 (应该至少还能recv一次, 没问题)
            }
            else
            {
                mRecvSize += Ret;
            }
        }
    }
    
    ServerResponse SrvRep;
    if (TryDecodeRecvBuff(SrvRep))
    {
        auto Itr = mWaitingList.find(SrvRep.mSrvFileName);
        if (Itr != mWaitingList.end())
        {
            auto Req = Itr->second;
            
            if (Req)
            {
                AddResponse(*Req, SrvRep.mFlag == 0x00A2, SrvRep.mSrvFileName);
                delete Req;
            }
            
            mWaitingList.erase(Itr);
        }
    }
    
    WaitFor(1);
}
Ejemplo n.º 8
0
  void SocksConnection::ReadFromSocket()
  {
    qDebug() << "SOCKS ReadFromSocket in state" << _state;

    if(!_socket_open || !_socket->bytesAvailable()) return;

    switch(_state) {
      case ConnState_WaitingForMethodHeader:
        HandleMethodHeader();
        break;
      case ConnState_WaitingForMethods:
        HandleMethods();
        break;
      case ConnState_WaitingForRequestHeader:
        HandleRequestHeader();
        break;
      case ConnState_WaitingForRequest:
        HandleRequest();
        break;
      case ConnState_Connected:
        HandleConnected();
        break;
      default:
        qFatal("Unknown state");
        break;
    }
  }
Ejemplo n.º 9
0
vector<Category*>* Session::GetCategories(string configId) {
    AuthRequest* authRequest = new AuthRequest(consumerKey, consumerSecret, configId, applicationName);
    QueryMethod method = GET;
    string url = host + "/categories." + format;
    cout << endl << "url: " << url << endl;
    int status = authRequest->authWebRequest(url, method);

    vector<Category*>* result = new vector<Category*>();
    if (status <= 202 && "" != authRequest->GetReceivedData()) {
        Stub_Categories* stub = new Stub_Categories();
        if (format == "xml") {
            (static_cast<XmlSerializer*>(serializer))->Deserialize(authRequest->GetReceivedData(), stub);
        } else {
            (static_cast<JsonSerializer*>(serializer))->Deserialize(authRequest->GetReceivedData(), stub);
        }
        result = stub->GetCategories();
        delete stub;
    }
    HandleRequest(method, url, "");
    HandleConfigurationResponse(status, authRequest);

    delete authRequest;

    return result;
}
Ejemplo n.º 10
0
HttpResponse * 
EHS::RouteRequest ( HttpRequest * ipoHttpRequest ///< request info for service
	)
{

	// get the next path from the URI
	std::string sNextPathPart = GetNextPathPart ( ipoHttpRequest->sUri );


	EHS_TRACE ( "Info: Trying to route: '%s'\n", sNextPathPart.c_str ( ) );


	// if there is no more path, call HandleRequest on this EHS object with
	//   whatever's left - or if we're not routing
	if ( sNextPathPart.empty ( ) ||
		 m_oEHSServerParameters.find ( "norouterequest" ) !=
		 m_oEHSServerParameters.end ( ) ) {

		// create an HttpRespose object for the client
		HttpResponse * poHttpResponse = 
			new HttpResponse ( ipoHttpRequest->m_nRequestId,
							   ipoHttpRequest->m_poSourceEHSConnection );
		
		// get the actual response and return code
		poHttpResponse->m_nResponseCode = 
			HandleRequest ( ipoHttpRequest, poHttpResponse );

		return poHttpResponse;

	}

	// if the path exists, check it against the map of EHSs
	if ( oEHSMap [ sNextPathPart ] ) {

		// if it exists, call RouteRequest with that EHS and the
		//   new shortened path

		return oEHSMap [ sNextPathPart ]->RouteRequest ( ipoHttpRequest );

	}
	// if it doesn't exist, send an error back up saying resource doesn't exist
	else {

		
		EHS_TRACE ( "Info: Routing failed.  Most likely caused by an invalid URL, not internal error\n" );


		// send back a 404 response
		HttpResponse * poHttpResponse = new HttpResponse ( ipoHttpRequest->m_nRequestId,
														   ipoHttpRequest->m_poSourceEHSConnection );

		poHttpResponse->m_nResponseCode = HTTPRESPONSECODE_404_NOTFOUND;
		poHttpResponse->SetBody ( "404 - Not Found", strlen ( "404 - Not Found" ) );

		return poHttpResponse;
		
	}

}
Ejemplo n.º 11
0
void* BaseWorker::Handle() 
{
  while (State != ENDED) 
  {
    TakeRequests();
    HandleRequest();
  }    
}
Ejemplo n.º 12
0
int main(int argc, char *argv[]) {
    void *h1 = New(ConcreteHandleA);
    void *h2 = New(ConcreteHandleB);
    void *h3 = New(ConcreteHandleC);

    SetSuccessor(h1, h2);
    SetSuccessor(h2, h3);

    HandleRequest(h1, 300);
    HandleRequest(h1, 600);
    HandleRequest(h1, 1500);
    HandleRequest(h1, 3000);
    
    Delete(h1);
    Delete(h2);
    Delete(h3);
    
    return 0;
}
Ejemplo n.º 13
0
void Server::HandleConnection(int conn_fd) {
  Request request(conn_fd);
  if (!request.IsOK()) {
    WLOG("Bad request, ignoring.");
    return;
  }
  HandleRequest(request);

  // TODO: Way to mark the content body as read, read it here if never read.
  // This allows the handler to stream if need be.

  // TODO: Could handle keep alive here.
  request.Write();
}
Ejemplo n.º 14
0
  void HTTP::HandlePacket(Packet& p)
  {
    String got;
    got.assign(p.GetData(), p.GetSize());
    LOG(got);

    //handle request, close connection after handling
    String response = HandleRequest(got);
    auto foundIt = m_connections.find(p.GetAddress());
    if(foundIt != m_connections.end())
      foundIt->second.sock->Send(response.c_str(), response.size());
    else
      ERR("where did the connection go!?!?");
  }
Ejemplo n.º 15
0
int
realapp ()
{
#ifdef WITH_MYSQL
	mysql_library_init(0, NULL, NULL);
#endif
	os_mutex_init (&crypt_lock);
	os_mutex_init (&getpwnam_lock);
	os_mutex_init (&getspnam_lock);
	os_mutex_init (&localtime_lock);
	os_mutex_init (&writerpipe_lock);
#ifndef _WIN32_
	reloadconfig (SIGHUP);
	signal (SIGCHLD, kidkiller);
	signal (SIGPIPE, ignorer);
	signal (SIGQUIT, closeup);
	signal (SIGINT, closeup);
#else
	reloadconfig (0);
#endif
#ifndef _WIN32_
	if (runAsDaemon)
		daemonize ();
	else if (log_filename) {
		int fh = open (log_filename, O_CREAT|O_TRUNC|O_RDWR, 0666);
		if (fh == -1) {
			fprintf(stderr, "failed to open logfile %s:%s\n", log_filename, strerror(errno));
			fh = open ("/dev/null", O_RDWR);
		}

		close (1);
		close (2);
		dup2 (fh, 1);
		dup2 (fh, 2);
	}
#endif
	log_log (NULL, LOG_EVT_SERVERSTART, 0, conf);
	while (TRUE) {
		if (!HandleRequest ()) {
#ifdef WITH_DEBUG
			DEBUG_LOG ("Couldn't handle request.");
#endif
		}
	}

#ifdef WITH_MYSQL
	mysql_library_end();
#endif
	return EXIT_SUCCESS;
}
Ejemplo n.º 16
0
void EnumerateSlave (BYTE ThreadID) {
    usbslave_ioctl_cb_t iocb;
    BYTE SetupBuffer[9];
    BYTE Status;
    WaitForDevicesStarted();
    dprint("\nSlave Openned, SETUP thread (%d) started", &ThreadID);
    iocb.ioctl_code = VOS_IOCTL_USBSLAVE_WAIT_SETUP_RCVD;
    iocb.request.setup_or_bulk_transfer.buffer = &SetupBuffer[0];
    iocb.request.setup_or_bulk_transfer.size = sizeof(SetupBuffer);
    while (1) {
        Status = i_vos_dev_ioctl(ThreadID, hDevice[Slave], &iocb);
        dprint("\nSetup received:", 0);
        dprintBuffer(&SetupBuffer[0], sizeof(SetupBuffer));
        HandleRequest(ThreadID, (usb_deviceRequest_t*)&SetupBuffer[0]);
        }
    }
Ejemplo n.º 17
0
 void RpcHandler::HandleData(const QSharedPointer<ISender> &from,
     const QVariantList &container)
 {
   if(container.size() < 2) {
     return;
   }
   
   QString type = container.at(0).toString();
   if(type == Request::RequestType ||
       type == Request::NotificationType)
   {
     HandleRequest(Request(_responder, from, container));
   } else if(type == Response::ResponseType) {
     HandleResponse(Response(from, container));
   } else {
     qDebug() << "Received an unknown Rpc type:" << type;
   }
 }
Ejemplo n.º 18
0
int Session::QueueCollection(Collection* collection, string configId) {
    AuthRequest* authRequest = new AuthRequest(consumerKey, consumerSecret, configId, applicationName);
    QueryMethod method = POST;
    string url = host + "/collection." + format;
    cout << endl << "url: " << url << endl;
    string body = "";
    if (format == "xml") {
        body = (static_cast<XmlSerializer*>(serializer))->Serialize(collection);
    } else {
        body = (static_cast<JsonSerializer*>(serializer))->Serialize(collection);
    }
    int result = authRequest->authWebRequest(url, method, body);

    HandleCollAutoResponse(result, authRequest);
    HandleRequest(method, url, body);

    delete authRequest;

    return result;
}
Ejemplo n.º 19
0
int Session::UpdateItems(string path, UpdateProxy<T>* proxy, string configId) {
    AuthRequest* authRequest = new AuthRequest(consumerKey, consumerSecret, configId, applicationName);
    QueryMethod method = POST;
    string url = host + "/" + path + "." + format;
    cout << endl << "url: " << url << endl;
    string body = "";
    if (format == "xml") {
        body = (static_cast<XmlSerializer*>(serializer))->Serialize(proxy);
    } else {
        body = (static_cast<JsonSerializer*>(serializer))->Serialize(proxy);
    }

    int result = authRequest->authWebRequest(url, method, body);

    HandleRequest(POST, url, body);
    HandleConfigurationResponse(result, authRequest);

    delete authRequest;
    return result;
}
Ejemplo n.º 20
0
/* See description in header file. */
void WorkerThread::DoRealWorks()
{
    while (!m_stop)
    {
        int ret = m_param.WaitForAction();
        if (ret)
        {
            continue;
        }
        // PDEBUG ("Thread %lu is working...\n", TID2ULONG(m_tid));
        PDEBUG ("Thread %p is working...\n", this);

        Socket* sock = m_param.m_sock;
        if (!sock)
        {
            continue;
        }

        while (true)
        {
            THMessagePtr msg = sock->Receive();
            if (!msg)
            {
                m_param.m_busy = false;
                sock->Close();
                if (m_pPool)
                {
                    m_pPool->ReturnThread(this);
                }
                PDEBUG ("Socket closed ...\n");
                break;
            }

            // TODO: Add real work here.
            THMessagePtr rsp = HandleRequest(msg);

            // Send it back to client;
            int n = sock->Send(rsp);
        }
    }
}
Ejemplo n.º 21
0
CollAnalyticData* Session::GetCollection(string collectionId, string configId) {
    AuthRequest* authRequest = new AuthRequest(consumerKey, consumerSecret, configId, applicationName);
    QueryMethod method = GET;
    string url = host + "/collection/" + collectionId + "." + format;
    cout << endl << "url: " << url << endl;
    int status = authRequest->authWebRequest(url, method);
    CollAnalyticData* result = new CollAnalyticData();
    if (status <= 202 && "" != authRequest->GetReceivedData()) {
        if (format == "xml") {
            (static_cast<XmlSerializer*>(serializer))->Deserialize(authRequest->GetReceivedData(), result);
        } else {
            (static_cast<JsonSerializer*>(serializer))->Deserialize(authRequest->GetReceivedData(), result);
        }
    }
    HandleRequest(method, url, "");
    HandleConfigurationResponse(status, authRequest);

    delete authRequest;

    return result;
}
Ejemplo n.º 22
0
void CheckForCommands() {
    int result = strlen(recv_buffer);

    if (result == 0) // No pending commands
    { // Keep going till the commands have been received completely (the last character is an endline; recv_buffer better be big enough for at least one entire command)
        do {
            memset(temp_buffer, 0, RECV_BUFFER_SIZE);
            result = NetRecvTCP(interfaceSocket, temp_buffer, RECV_BUFFER_SIZE - strlen(recv_buffer) - 1);
            if (result > 0)
                strcat(recv_buffer, temp_buffer);
        } while (result > 0 && (strlen(recv_buffer) > 0 && strlen(recv_buffer) < RECV_BUFFER_SIZE - 1 && recv_buffer[strlen(recv_buffer) - 1] != '\n'));
    }

    if (result > 0)
        HandleRequest();
    else if (NetCheckForDisconnect()) {
        DebugPrint("Broken connection.");
        connected = false;
        NetCloseTCP(interfaceSocket);
    }
}
Ejemplo n.º 23
0
int Session::QueueBatch(vector<Document*>* documents, string configId) {
    AuthRequest* authRequest = new AuthRequest(consumerKey, consumerSecret, configId, applicationName);
    QueryMethod method = POST;
    string url = host + "/document/batch." + format;
    cout << endl << "url: " << url << endl;
    Stub_Tasks* documentsStub = new Stub_Tasks(documents);
    string body = "";
    if (format == "xml") {
        body = (static_cast<XmlSerializer*>(serializer))->Serialize(documentsStub);
    } else {
        body = (static_cast<JsonSerializer*>(serializer))->Serialize(documentsStub);
    }
    delete documentsStub;

    int result = authRequest->authWebRequest(url, method, body);

    HandleDocAutoResponse(result, authRequest);
    HandleRequest(method, url, body);

    delete authRequest;
    return result;
}
Ejemplo n.º 24
0
Subscription* Session::VerifySubscription() {
    AuthRequest* authRequest = new AuthRequest(consumerKey, consumerSecret, "", applicationName);
    QueryMethod method = GET;
    string url = host + "/subscription." + format;
    cout << endl << "url: " << url << endl;
    int status = authRequest->authWebRequest(url, method);

    Subscription* result = new Subscription();
    if (status <= 202 && "" != authRequest->GetReceivedData()) {
        if (format == "xml") {
            (static_cast<XmlSerializer*>(serializer))->Deserialize(authRequest->GetReceivedData(), result);
        } else {
            (static_cast<JsonSerializer*>(serializer))->Deserialize(authRequest->GetReceivedData(), result);
        }
    }
    HandleRequest(method, url, "");
    HandleConfigurationResponse(status, authRequest);

    delete authRequest;

    return result;
}
Ejemplo n.º 25
0
static int ProxyModel_HandleRequest(const RDMHeader *header,
                                    const uint8_t *param_data) {
  int response_size = 0;
  // The proxy always gets first dibs on responding.
  if (RDMUtil_RequiresAction(g_responder->uid, header->dest_uid)) {
    response_size = HandleRequest(header, param_data);
    if (response_size) {
      return response_size;
    }
  }

  unsigned int i = 0u;
  for (; i < NUMBER_OF_CHILDREN; i++) {
    if (RDMUtil_RequiresAction(g_children[i].responder.uid, header->dest_uid)) {
      RDMResponder_SwitchResponder(&g_children[i].responder);
      int response_size = HandleChildRequest(header, param_data, i);
      RDMResponder_RestoreResponder();
      if (response_size) {
        return response_size;
      }
    }
  }
  return RDM_RESPONDER_NO_RESPONSE;
}
Ejemplo n.º 26
0
unsigned long WINAPI ThreadFunc(LPVOID lpParam)
{
	SOCKET * s = (SOCKET *)lpParam;
	char szTemp[STR_LEN], szRequest[STR_LEN] = {0};
	char szRequestHeader[STR_LEN] = {0}, szRequestBody[STR_LEN] = {0};
	char * pcTemp = 0;
	int ret = 0;
	int len = 0, nHeaderLength = 0, nContentLength = 0;
	
	while (len = recv(*s, szTemp, STR_LEN, 0))
	{
		strncat(szRequest, szTemp, len);
		
		if (szRequestHeader[0] == '\0')
		{
			/* Check if the header was completly received */
			nHeaderLength = (int)(strstr(szRequest, "\r\n\r\n") - szRequest);
			if (nHeaderLength > 0)
			{
				nHeaderLength += 2;
				sprintf(szTemp, "Header length: %d", nHeaderLength);
				Log(szTemp);

				/* Copy the request header aside */
				strncpy(szRequestHeader, szRequest, nHeaderLength);
				
				pcTemp = stristr(szRequestHeader, "Content-Length:");
				if (pcTemp)
				{
					/* Copy the "Content-Length" line */
					strncpy(szTemp, pcTemp, (int)(strchr(pcTemp, '\r') - pcTemp));

					Log(szTemp);

					/* Get the content length */
					len = strspn(&(szTemp[strlen("Content-Length:")]), " \t");
					nContentLength = atoi(&(szTemp[strlen("Content-Length:") + len - 1]));

					sprintf(szTemp, "Content-Length: %d", nContentLength);
					Log(szTemp);
				}
			}
		}

		if (szRequestHeader[0]) /* Header parsing is complete */
		{
			if (nContentLength)
			{
				if (szRequestBody[0] == '\0')
				{
					strcpy(szTemp, &(szRequest[nHeaderLength + 2]));
				}

				if (strlen(szRequestBody) < nContentLength)
				{
					strcat(szRequestBody, szTemp);
				}
			}

			if (strlen(szRequestBody) == nContentLength)
			{
				return HandleRequest(szRequest, szRequestHeader, szRequestBody, s);
			}
		}
	}

	return 0;
}
Ejemplo n.º 27
0
int CWebServer::AnswerToConnection(void *cls, struct MHD_Connection *connection,
                      const char *url, const char *method,
                      const char *version, const char *upload_data,
                      unsigned int *upload_data_size, void **con_cls)
#endif
{
  if (cls == NULL || con_cls == NULL || *con_cls == NULL)
  {
    CLog::Log(LOGERROR, "CWebServer: invalid request received");
    return MHD_NO;
  }

  CWebServer *server = reinterpret_cast<CWebServer*>(cls);
  std::auto_ptr<ConnectionHandler> conHandler(reinterpret_cast<ConnectionHandler*>(*con_cls));
  HTTPMethod methodType = GetMethod(method);
  HTTPRequest request = { server, connection, conHandler->fullUri, url, methodType, version };

  // remember if the request was new
  bool isNewRequest = conHandler->isNew;
  // because now it isn't anymore
  conHandler->isNew = false;

  // reset con_cls and set it if still necessary
  *con_cls = NULL;

#ifdef WEBSERVER_DEBUG
  if (isNewRequest)
  {
    std::multimap<std::string, std::string> headerValues;
    GetRequestHeaderValues(connection, MHD_HEADER_KIND, headerValues);
    std::multimap<std::string, std::string> getValues;
    GetRequestHeaderValues(connection, MHD_GET_ARGUMENT_KIND, getValues);

    CLog::Log(LOGDEBUG, "webserver  [IN] %s %s %s", version, method, request.pathUrlFull.c_str());
    if (!getValues.empty())
    {
      std::string tmp;
      for (std::multimap<std::string, std::string>::const_iterator get = getValues.begin(); get != getValues.end(); ++get)
      {
        if (get != getValues.begin())
          tmp += "; ";
        tmp += get->first + " = " + get->second;
      }
      CLog::Log(LOGDEBUG, "webserver  [IN] Query arguments: %s", tmp.c_str());
    }

    for (std::multimap<std::string, std::string>::const_iterator header = headerValues.begin(); header != headerValues.end(); ++header)
      CLog::Log(LOGDEBUG, "webserver  [IN] %s: %s", header->first.c_str(), header->second.c_str());
  }
#endif

  if (!IsAuthenticated(server, connection)) 
    return AskForAuthentication(connection);

  // check if this is the first call to AnswerToConnection for this request
  if (isNewRequest)
  {
    // parse the Range header and store it in the request object
    CHttpRanges ranges;
    bool ranged = ranges.Parse(GetRequestHeaderValue(connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_RANGE));

    // look for a IHTTPRequestHandler which can take care of the current request
    for (std::vector<IHTTPRequestHandler *>::const_iterator it = m_requestHandlers.begin(); it != m_requestHandlers.end(); ++it)
    {
      IHTTPRequestHandler *requestHandler = *it;
      if (requestHandler->CanHandleRequest(request))
      {
        // we found a matching IHTTPRequestHandler so let's get a new instance for this request
        IHTTPRequestHandler *handler = requestHandler->Create(request);

        // if we got a GET request we need to check if it should be cached
        if (methodType == GET)
        {
          if (handler->CanBeCached())
          {
            bool cacheable = true;

            // handle Cache-Control
            std::string cacheControl = GetRequestHeaderValue(connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_CACHE_CONTROL);
            if (!cacheControl.empty())
            {
              std::vector<std::string> cacheControls = StringUtils::Split(cacheControl, ",");
              for (std::vector<std::string>::const_iterator it = cacheControls.begin(); it != cacheControls.end(); ++it)
              {
                std::string control = *it;
                control = StringUtils::Trim(control);

                // handle no-cache
                if (control.compare(HEADER_VALUE_NO_CACHE) == 0)
                  cacheable = false;
              }
            }

            if (cacheable)
            {
              // handle Pragma (but only if "Cache-Control: no-cache" hasn't been set)
              std::string pragma = GetRequestHeaderValue(connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_PRAGMA);
              if (pragma.compare(HEADER_VALUE_NO_CACHE) == 0)
                cacheable = false;
            }

            CDateTime lastModified;
            if (handler->GetLastModifiedDate(lastModified) && lastModified.IsValid())
            {
              // handle If-Modified-Since or If-Unmodified-Since
              std::string ifModifiedSince = GetRequestHeaderValue(connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_IF_MODIFIED_SINCE);
              std::string ifUnmodifiedSince = GetRequestHeaderValue(connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_IF_UNMODIFIED_SINCE);

              CDateTime ifModifiedSinceDate;
              CDateTime ifUnmodifiedSinceDate;
              // handle If-Modified-Since (but only if the response is cacheable)
              if (cacheable &&
                ifModifiedSinceDate.SetFromRFC1123DateTime(ifModifiedSince) &&
                lastModified.GetAsUTCDateTime() <= ifModifiedSinceDate)
              {
                struct MHD_Response *response = MHD_create_response_from_data(0, NULL, MHD_NO, MHD_NO);
                if (response == NULL)
                {
                  CLog::Log(LOGERROR, "CWebServer: failed to create a HTTP 304 response");
                  return MHD_NO;
                }

                return FinalizeRequest(handler, MHD_HTTP_NOT_MODIFIED, response);
              }
              // handle If-Unmodified-Since
              else if (ifUnmodifiedSinceDate.SetFromRFC1123DateTime(ifUnmodifiedSince) &&
                lastModified.GetAsUTCDateTime() > ifUnmodifiedSinceDate)
                return SendErrorResponse(connection, MHD_HTTP_PRECONDITION_FAILED, methodType);
            }

            // handle If-Range header but only if the Range header is present
            if (ranged && lastModified.IsValid())
            {
              std::string ifRange = GetRequestHeaderValue(connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_IF_RANGE);
              if (!ifRange.empty() && lastModified.IsValid())
              {
                CDateTime ifRangeDate;
                ifRangeDate.SetFromRFC1123DateTime(ifRange);

                // check if the last modification is newer than the If-Range date
                // if so we have to server the whole file instead
                if (lastModified.GetAsUTCDateTime() > ifRangeDate)
                  ranges.Clear();
              }
            }

            // pass the requested ranges on to the request handler
            handler->SetRequestRanged(!ranges.IsEmpty());
          }
        }
        // if we got a POST request we need to take care of the POST data
        else if (methodType == POST)
        {
          conHandler->requestHandler = handler;

          // get the content-type of the POST data
          std::string contentType = GetRequestHeaderValue(connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_CONTENT_TYPE);
          if (!contentType.empty())
          {
            // if the content-type is application/x-ww-form-urlencoded or multipart/form-data we can use MHD's POST processor
            if (StringUtils::EqualsNoCase(contentType, MHD_HTTP_POST_ENCODING_FORM_URLENCODED) ||
                StringUtils::EqualsNoCase(contentType, MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA))
            {
              // Get a new MHD_PostProcessor
              conHandler->postprocessor = MHD_create_post_processor(connection, MAX_POST_BUFFER_SIZE, &CWebServer::HandlePostField, (void*)conHandler.get());

              // MHD doesn't seem to be able to handle this post request
              if (conHandler->postprocessor == NULL)
              {
                CLog::Log(LOGERROR, "CWebServer: unable to create HTTP POST processor for %s", url);

                delete conHandler->requestHandler;

                return SendErrorResponse(connection, MHD_HTTP_INTERNAL_SERVER_ERROR, methodType);
              }
            }
          }

          // otherwise we need to handle the POST data ourselves which is done in the next call to AnswerToConnection
          // as ownership of the connection handler is passed to libmicrohttpd we must not destroy it 
          *con_cls = conHandler.release();

          return MHD_YES;
        }

        return HandleRequest(handler);
      }
    }
  }
  // this is a subsequent call to AnswerToConnection for this request
  else
  {
    // again we need to take special care of the POST data
    if (methodType == POST)
    {
      if (conHandler->requestHandler == NULL)
      {
        CLog::Log(LOGERROR, "CWebServer: cannot handle partial HTTP POST for %s request because there is no valid request handler available", url);
        return SendErrorResponse(connection, MHD_HTTP_INTERNAL_SERVER_ERROR, methodType);
      }

      // we only need to handle POST data if there actually is data left to handle
      if (*upload_data_size > 0)
      {
        // either use MHD's POST processor
        if (conHandler->postprocessor != NULL)
          MHD_post_process(conHandler->postprocessor, upload_data, *upload_data_size);
        // or simply copy the data to the handler
        else
          conHandler->requestHandler->AddPostData(upload_data, *upload_data_size);

        // signal that we have handled the data
        *upload_data_size = 0;

        // we may need to handle more POST data which is done in the next call to AnswerToConnection
        // as ownership of the connection handler is passed to libmicrohttpd we must not destroy it 
        *con_cls = conHandler.release();

        return MHD_YES;
      }
      // we have handled all POST data so it's time to invoke the IHTTPRequestHandler
      else
      {
        if (conHandler->postprocessor != NULL)
          MHD_destroy_post_processor(conHandler->postprocessor);

        return HandleRequest(conHandler->requestHandler);
      }
    }
    // it's unusual to get more than one call to AnswerToConnection for none-POST requests, but let's handle it anyway
    else
    {
      for (std::vector<IHTTPRequestHandler *>::const_iterator it = m_requestHandlers.begin(); it != m_requestHandlers.end(); ++it)
      {
        IHTTPRequestHandler *requestHandler = *it;
        if (requestHandler->CanHandleRequest(request))
          return HandleRequest(requestHandler->Create(request));
      }
    }
  }

  CLog::Log(LOGERROR, "CWebServer: couldn't find any request handler for %s", url);
  return SendErrorResponse(connection, MHD_HTTP_NOT_FOUND, methodType);
}
int JackRequestDecoder::HandleRequest(detail::JackChannelTransactionInterface* socket, int type_aux)
{
    JackRequest::RequestType type = (JackRequest::RequestType)type_aux;

    // Read data
    switch (type) {

        case JackRequest::kClientCheck: {
            jack_log("JackRequest::ClientCheck");
            JackClientCheckRequest req;
            JackClientCheckResult res;
            CheckRead(req, socket);
            res.fResult = fServer->GetEngine()->ClientCheck(req.fName, req.fUUID, res.fName, req.fProtocol, req.fOptions, &res.fStatus);
            CheckWriteName("JackRequest::ClientCheck", socket);
            // Atomic ClientCheck followed by ClientOpen on same socket
            if (req.fOpen) {
                JackRequest header;
                header.Read(socket);
                return HandleRequest(socket, header.fType);
            }
            break;
        }

        case JackRequest::kClientOpen: {
            jack_log("JackRequest::ClientOpen");
            JackClientOpenRequest req;
            JackClientOpenResult res;
            CheckRead(req, socket);
            fHandler->ClientAdd(socket, &req, &res);
            CheckWriteName("JackRequest::ClientOpen", socket);
            break;
        }

        case JackRequest::kClientClose: {
            jack_log("JackRequest::ClientClose");
            JackClientCloseRequest req;
            JackResult res;
            CheckRead(req, socket);
            res.fResult = fServer->GetEngine()->ClientExternalClose(req.fRefNum);
            CheckWriteRefNum("JackRequest::ClientClose", socket);
            fHandler->ClientRemove(socket, req.fRefNum);
            // Will cause the wrapping thread to stop
            return -1;
        }

        case JackRequest::kActivateClient: {
            JackActivateRequest req;
            JackResult res;
            jack_log("JackRequest::ActivateClient");
            CheckRead(req, socket);
            res.fResult = fServer->GetEngine()->ClientActivate(req.fRefNum, req.fIsRealTime);
            CheckWriteRefNum("JackRequest::ActivateClient", socket);
            break;
        }

        case JackRequest::kDeactivateClient: {
            jack_log("JackRequest::DeactivateClient");
            JackDeactivateRequest req;
            JackResult res;
            CheckRead(req, socket);
            res.fResult = fServer->GetEngine()->ClientDeactivate(req.fRefNum);
            CheckWriteRefNum("JackRequest::DeactivateClient", socket);
            break;
        }

        case JackRequest::kRegisterPort: {
            jack_log("JackRequest::RegisterPort");
            JackPortRegisterRequest req;
            JackPortRegisterResult res;
            CheckRead(req, socket);
            res.fResult = fServer->GetEngine()->PortRegister(req.fRefNum, req.fName, req.fPortType, req.fFlags, req.fBufferSize, &res.fPortIndex);
            CheckWriteRefNum("JackRequest::RegisterPort", socket);
            break;
        }

        case JackRequest::kUnRegisterPort: {
            jack_log("JackRequest::UnRegisterPort");
            JackPortUnRegisterRequest req;
            JackResult res;
            CheckRead(req, socket);
            res.fResult = fServer->GetEngine()->PortUnRegister(req.fRefNum, req.fPortIndex);
            CheckWriteRefNum("JackRequest::UnRegisterPort", socket);
            break;
        }

        case JackRequest::kConnectNamePorts: {
            jack_log("JackRequest::ConnectNamePorts");
            JackPortConnectNameRequest req;
            JackResult res;
            CheckRead(req, socket);
            res.fResult = fServer->GetEngine()->PortConnect(req.fRefNum, req.fSrc, req.fDst);
            CheckWriteRefNum("JackRequest::ConnectNamePorts", socket);
            break;
        }

        case JackRequest::kDisconnectNamePorts: {
            jack_log("JackRequest::DisconnectNamePorts");
            JackPortDisconnectNameRequest req;
            JackResult res;
            CheckRead(req, socket);
            res.fResult = fServer->GetEngine()->PortDisconnect(req.fRefNum, req.fSrc, req.fDst);
            CheckWriteRefNum("JackRequest::DisconnectNamePorts", socket);
            break;
        }

        case JackRequest::kConnectPorts: {
            jack_log("JackRequest::ConnectPorts");
            JackPortConnectRequest req;
            JackResult res;
            CheckRead(req, socket);
            res.fResult = fServer->GetEngine()->PortConnect(req.fRefNum, req.fSrc, req.fDst);
            CheckWriteRefNum("JackRequest::ConnectPorts", socket);
            break;
        }

        case JackRequest::kDisconnectPorts: {
            jack_log("JackRequest::DisconnectPorts");
            JackPortDisconnectRequest req;
            JackResult res;
            CheckRead(req, socket);
            res.fResult = fServer->GetEngine()->PortDisconnect(req.fRefNum, req.fSrc, req.fDst);
            CheckWriteRefNum("JackRequest::DisconnectPorts", socket);
            break;
        }

        case JackRequest::kPortRename: {
            jack_log("JackRequest::PortRename");
            JackPortRenameRequest req;
            JackResult res;
            CheckRead(req, socket);
            res.fResult = fServer->GetEngine()->PortRename(req.fRefNum, req.fPort, req.fName);
            CheckWriteRefNum("JackRequest::PortRename", socket);
            break;
        }

        case JackRequest::kSetBufferSize: {
            jack_log("JackRequest::SetBufferSize");
            JackSetBufferSizeRequest req;
            JackResult res;
            CheckRead(req, socket);
            res.fResult = fServer->SetBufferSize(req.fBufferSize);
            CheckWrite("JackRequest::SetBufferSize", socket);
            break;
        }

        case JackRequest::kSetFreeWheel: {
            jack_log("JackRequest::SetFreeWheel");
            JackSetFreeWheelRequest req;
            JackResult res;
            CheckRead(req, socket);
            res.fResult = fServer->SetFreewheel(req.fOnOff);
            CheckWrite("JackRequest::SetFreeWheel", socket);
#ifdef __ANDROID__
#ifdef WORKAROUND_QC_JACK_ALSA
            /* for supporting qualcomm platform */
            if(req.fOnOff == 0) {
                usleep(300 * 1000);
                kill(getpid(), SIGUSR2);  //switch master driver via SIGUSR2 signal
                usleep(300 * 1000);
                kill(getpid(), SIGUSR2);  //switch master driver via SIGUSR2 signal
                usleep(300 * 1000);
                fServer->GetEngine()->PortConnect(0, "out:__system_playback_1", "system:playback_1");
                fServer->GetEngine()->PortConnect(0, "out:__system_playback_2", "system:playback_2");
                fServer->GetEngine()->PortConnect(0, "system:capture_1", "in:__system_capture_1");
                fServer->GetEngine()->PortConnect(0, "system:capture_2", "in:__system_capture_2");
            }
#endif
#endif
            break;
        }

         case JackRequest::kComputeTotalLatencies: {
            jack_log("JackRequest::ComputeTotalLatencies");
            JackComputeTotalLatenciesRequest req;
            JackResult res;
            CheckRead(req, socket);
            res.fResult = fServer->GetEngine()->ComputeTotalLatencies();
            CheckWrite("JackRequest::ComputeTotalLatencies", socket);
            break;
        }

        case JackRequest::kReleaseTimebase: {
            jack_log("JackRequest::ReleaseTimebase");
            JackReleaseTimebaseRequest req;
            JackResult res;
            CheckRead(req, socket);
            res.fResult = fServer->ReleaseTimebase(req.fRefNum);
            CheckWriteRefNum("JackRequest::ReleaseTimebase", socket);
            break;
        }

        case JackRequest::kSetTimebaseCallback: {
            jack_log("JackRequest::SetTimebaseCallback");
            JackSetTimebaseCallbackRequest req;
            JackResult res;
            CheckRead(req, socket);
            res.fResult = fServer->SetTimebaseCallback(req.fRefNum, req.fConditionnal);
            CheckWriteRefNum("JackRequest::SetTimebaseCallback", socket);
            break;
        }

        case JackRequest::kGetInternalClientName: {
            jack_log("JackRequest::GetInternalClientName");
            JackGetInternalClientNameRequest req;
            JackGetInternalClientNameResult res;
            CheckRead(req, socket);
            res.fResult = fServer->GetEngine()->GetInternalClientName(req.fIntRefNum, res.fName);
            CheckWriteRefNum("JackRequest::GetInternalClientName", socket);
            break;
        }

        case JackRequest::kInternalClientHandle: {
            jack_log("JackRequest::InternalClientHandle");
            JackInternalClientHandleRequest req;
            JackInternalClientHandleResult res;
            CheckRead(req, socket);
            res.fResult = fServer->GetEngine()->InternalClientHandle(req.fName, &res.fStatus, &res.fIntRefNum);
            CheckWriteRefNum("JackRequest::InternalClientHandle", socket);
            break;
        }

        case JackRequest::kInternalClientLoad: {
            jack_log("JackRequest::InternalClientLoad");
            JackInternalClientLoadRequest req;
            JackInternalClientLoadResult res;
            CheckRead(req, socket);
            res.fResult = fServer->InternalClientLoad1(req.fName, req.fDllName, req.fLoadInitName, req.fOptions, &res.fIntRefNum, req.fUUID, &res.fStatus);
            CheckWriteName("JackRequest::InternalClientLoad", socket);
            break;
        }

        case JackRequest::kInternalClientUnload: {
            jack_log("JackRequest::InternalClientUnload");
            JackInternalClientUnloadRequest req;
            JackInternalClientUnloadResult res;
            CheckRead(req, socket);
            res.fResult = fServer->GetEngine()->InternalClientUnload(req.fIntRefNum, &res.fStatus);
            CheckWriteRefNum("JackRequest::InternalClientUnload", socket);
            break;
        }

        case JackRequest::kNotification: {
            jack_log("JackRequest::Notification");
            JackClientNotificationRequest req;
            CheckRead(req, socket);
            if (req.fNotify == kQUIT) {
                jack_log("JackRequest::Notification kQUIT");
                throw JackQuitException();
            } else {
                fServer->Notify(req.fRefNum, req.fNotify, req.fValue);
            }
            break;
        }

        case JackRequest::kSessionNotify: {
            jack_log("JackRequest::SessionNotify");
            JackSessionNotifyRequest req;
            CheckRead(req, socket);
            fServer->GetEngine()->SessionNotify(req.fRefNum, req.fDst, req.fEventType, req.fPath, socket, NULL);
            break;
        }

        case JackRequest::kSessionReply: {
            jack_log("JackRequest::SessionReply");
            JackSessionReplyRequest req;
            JackResult res;
            CheckRead(req, socket);
            res.fResult = fServer->GetEngine()->SessionReply(req.fRefNum);
            CheckWrite("JackRequest::SessionReply", socket);
            break;
        }

        case JackRequest::kGetClientByUUID: {
            jack_log("JackRequest::GetClientByUUID");
            JackGetClientNameRequest req;
            JackClientNameResult res;
            CheckRead(req, socket);
            res.fResult = fServer->GetEngine()->GetClientNameForUUID(req.fUUID, res.fName);
            CheckWrite("JackRequest::GetClientByUUID", socket);
            break;
        }

        case JackRequest::kGetUUIDByClient: {
            jack_log("JackRequest::GetUUIDByClient");
            JackGetUUIDRequest req;
            JackUUIDResult res;
            CheckRead(req, socket);
            res.fResult = fServer->GetEngine()->GetUUIDForClientName(req.fName, res.fUUID);
            CheckWrite("JackRequest::GetUUIDByClient", socket);
            break;
        }

        case JackRequest::kReserveClientName: {
            jack_log("JackRequest::ReserveClientName");
            JackReserveNameRequest req;
            JackResult res;
            CheckRead(req, socket);
            res.fResult = fServer->GetEngine()->ReserveClientName(req.fName, req.fUUID);
            CheckWrite("JackRequest::ReserveClientName", socket);
            break;
        }

        case JackRequest::kClientHasSessionCallback: {
            jack_log("JackRequest::ClientHasSessionCallback");
            JackClientHasSessionCallbackRequest req;
            JackResult res;
            CheckRead(req, socket);
            res.fResult = fServer->GetEngine()->ClientHasSessionCallback(req.fName);
            CheckWrite("JackRequest::ClientHasSessionCallback", socket);
            break;
        }

        default:
            jack_error("Unknown request %ld", type);
            return -1;
    }

    return 0;
}
Ejemplo n.º 29
0
void RageWorkerThread::WorkerMain()
{
	while(1)
	{
		bool bTimeToRunHeartbeat = false;
		m_WorkerEvent.Lock();
		while( m_iRequest == REQ_NONE && !bTimeToRunHeartbeat )
		{
			if( !m_WorkerEvent.Wait( m_fHeartbeat != -1? &m_NextHeartbeat:NULL ) )
				bTimeToRunHeartbeat = true;
		}
		const int iRequest = m_iRequest;
		m_iRequest = REQ_NONE;

		m_WorkerEvent.Unlock();

		/* If it's time to run a heartbeat, do so. */
		if( bTimeToRunHeartbeat )
		{
			DoHeartbeat();

			/* Wake up anyone waiting for a heartbeat. */
			m_HeartbeatEvent.Lock();
			m_HeartbeatEvent.Broadcast();
			m_HeartbeatEvent.Unlock();

			/* Schedule the next heartbeat. */
			m_NextHeartbeat.Touch();
			m_NextHeartbeat += m_fHeartbeat;
		}

		if( iRequest != REQ_NONE )
		{
			/* Handle the request. */
			if( iRequest != REQ_SHUTDOWN )
			{
				CHECKPOINT_M( ssprintf("HandleRequest(%i)", iRequest) );
				HandleRequest( iRequest );
				CHECKPOINT_M( ssprintf("HandleRequest(%i) done", iRequest) );
			}

			/* Lock the mutex, to keep DoRequest where it is (if it's still running). */
			/* The request is finished.  If it timed out, clear the timeout flag and
			 * call RequestTimedOut, to allow cleaning up. */
			m_WorkerEvent.Lock();

			if( m_bTimedOut )
			{
				LOG->Trace( "Request %i timed out", iRequest );

				/* The calling thread timed out.  It's already gone and moved on, so
				 * it's our responsibility to clean up.  No new requests will come in
				 * until we clear m_bTimedOut, so we can safely unlock and clean up. */
				m_WorkerEvent.Unlock();

				RequestTimedOut();

				/* Clear the time-out flag, indicating that we can work again. */
				m_bTimedOut = false;

				CHECKPOINT;
			}
			else
			{
				CHECKPOINT_M( ssprintf("HandleRequest(%i) OK", iRequest) );

				m_bRequestFinished = true;

				/* We're finished.  Wake up the requester. */
				m_WorkerEvent.Broadcast();
				m_WorkerEvent.Unlock();
			}
		}

		if( iRequest == REQ_SHUTDOWN )
			break;
	}
}
Ejemplo n.º 30
0
 Response *Route::Call(std::string url, std::string method,
                       std::vector<std::pair<std::string, std::string> > get,
                       std::vector<std::pair<std::string, std::string> > post) {
     return HandleRequest(url, method, get, post);
 }