Ejemplo n.º 1
0
/*********************************************************************
 * Function:        void HTTPServer(void)
 *
 * PreCondition:    HTTPInit() must already be called.
 *
 * Input:           None
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        Browse through each connection and try to bring
 *					it a step closer to completion.
 *
 * Note:            This function acts as a task (similar to one in
 *                  RTOS).  This function performs its task in
 *                  co-operative manner.  Main application must call
 *                  this function repeatdly to ensure all open
 *                  or new connections are served on time.
 ********************************************************************/
void HTTPServer(void)
{
	BYTE conn;

	for(conn = 0; conn < MAX_HTTP_CONNECTIONS; conn++)
	{
		if(httpStubs[conn].socket == INVALID_SOCKET)
			continue;
		
		// Determine if this connection is eligible for processing
		if(httpStubs[conn].sm != SM_HTTP_IDLE || TCPIsGetReady(httpStubs[conn].socket))
		{
			HTTPLoadConn(conn);
			HTTPProcess();
		}
	}
}
Ejemplo n.º 2
0
Archivo: HTTP.c Proyecto: sonite/mGit
/*********************************************************************
 * Function:        void HTTPServer(void)
 *
 * PreCondition:    HTTPInit() must already be called.
 *
 * Input:           None
 *
 * Output:          Opened HTTP connections are served.
 *
 * Side Effects:    None
 *
 * Overview:        Browse through each connections and let it
 *                  handle its connection.
 *                  If a connection is not finished, do not process
 *                  next connections.  This must be done, all
 *                  connections use some static variables that are
 *                  common.
 *
 * Note:            This function acts as a task (similar to one in
 *                  RTOS).  This function performs its task in
 *                  co-operative manner.  Main application must call
 *                  this function repeatdly to ensure all open
 *                  or new connections are served on time.
 ********************************************************************/
void HTTP_Server(BOOL available)
{
    BYTE conn = MAX_HTTP_CONNECTIONS;
	
	do
    {
		HTTPLoadConn(--conn);
		
		if(HTTP.StateMachine == SM_HTTP_UNINITIALIZED)
		{
			HTTPInit();
		}
		
		HTTP_Process(available);
	}
	while(conn);
}
Ejemplo n.º 3
0
Archivo: HTTP.c Proyecto: sonite/mGit
/*********************************************************************
 * Forcibly shut down all connections with open files when the file
 * system is dismounted
 *********************************************************************/
void HTTP_FileSystemReset(BOOL safe)
{
	BYTE index = MAX_HTTP_CONNECTIONS;

	do
	{
		HTTPLoadConn(--index);

		if(HTTP.file)
		{
			TCPFlush(HTTP.socket);
			TCPDisconnect(HTTP.socket);
			HTTP.StateMachine = SM_HTTP_IDLE;

			// Should the file be properly closed or just throw it away?
			if(safe)
				FSfclose(HTTP.file);
			HTTP.file = NULL;
		}
	}
	while(index);
}