1 #include "NyLPC_cHttpd_protected.h"
\r
2 #include "NyLPC_cHttpdConnection.h"
\r
3 #include "NyLPC_cHttpdConnection_protected.h"
\r
4 #include "NyLPC_cHttpdThread_protected.h"
\r
7 static int server(void* p);
\r
9 void NyLPC_cHttpdThread_initialize(NyLPC_TcHttpdThread_t* i_inst,NyLPC_TcHttpd_t* i_parent,NyLPC_TInt32 i_prio)
\r
11 NyLPC_cHttpdConnection_initialize(&(i_inst->_connection),i_parent);
\r
12 NyLPC_cThread_initialize(&(i_inst->_super),NyLPC_cHttpdThread_SIZE_OF_THREAD_STACK,i_prio);
\r
14 void NyLPC_cHttpdThread_finalize(NyLPC_TcHttpdThread_t* i_inst)
\r
16 NyLPC_cThread_finalize(&i_inst->_super);
\r
17 NyLPC_cHttpdConnection_finalize(&(i_inst->_connection));
\r
20 NyLPC_TBool NyLPC_cHttpdThread_start(NyLPC_TcHttpdThread_t* i_inst,NyLPC_TcTcpListener_t* i_listener)
\r
23 if(!NyLPC_cThread_isTerminated(&(i_inst->_super))){
\r
24 return NyLPC_TBool_FALSE;
\r
27 if(!NyLPC_cHttpdConnection_listenSocket(&(i_inst->_connection),i_listener)){
\r
28 return NyLPC_TBool_FALSE;
\r
31 NyLPC_cThread_start(&(i_inst->_super),server,&i_inst->_connection);
\r
32 return NyLPC_TBool_TRUE;
\r
40 static int server(void* p)
\r
42 NyLPC_TcHttpdConnection_t* inst=(NyLPC_TcHttpdConnection_t*)p;
\r
44 if(!NyLPC_cHttpdConnection_acceptSocket(inst)){
\r
45 NyLPC_OnErrorGoto(Error);
\r
48 NyLPC_cHttpd_incNumOfConnection(inst->_parent_httpd);
\r
54 if(!NyLPC_cHttpdConnection_prefetch(inst)){
\r
55 //Prefetch出来ないならループ終了。
\r
59 if(NyLPC_cHttpd_getNumOfConnection(inst->_parent_httpd)>NyLPC_cHttpd_MAX_PERSISTENT_CONNECTION){
\r
60 NyLPC_cHttpdConnection_setConnectionMode(inst,NyLPC_TcHttpdConnection_CONNECTION_MODE_CLOSE);
\r
62 NyLPC_cHttpdConnection_setConnectionMode(inst,NyLPC_TcHttpdConnection_CONNECTION_MODE_CONTINUE);
\r
65 (inst->_parent_httpd->function.onRequest)(inst);
\r
68 if(!NyLPC_cHttpdConnection_closeResponse(inst)){
\r
72 if(!NyLPC_cHttpdConnection_prevNextPrefetch(inst)){
\r
76 NyLPC_cHttpd_decNumOfConnection(inst->_parent_httpd);
\r
77 NyLPC_cHttpdConnection_closeSocket(inst);
\r
80 NyLPC_cHttpdConnection_closeSocket(inst);
\r