|
From: <sw...@us...> - 2003-11-15 23:20:48
|
Update of /cvsroot/swebs/SWEBS Server/Source
In directory sc8-pr-cvs1:/tmp/cvs-serv27515/Source
Modified Files:
SWEBSConnection.cpp SWEBSGlobals.cpp SWEBSMain.cpp
SWEBSSocket.cpp
Log Message:
Working version with ISAPI enabled. WOOHOO!
Index: SWEBSGlobals.cpp
===================================================================
RCS file: /cvsroot/swebs/SWEBS Server/Source/SWEBSGlobals.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- SWEBSGlobals.cpp 15 Oct 2003 09:29:53 -0000 1.1
+++ SWEBSGlobals.cpp 15 Nov 2003 23:20:24 -0000 1.2
@@ -156,6 +156,48 @@
delete curNode;
}
+ // Loop through with the ISAPI entries
+ int Counter = 0;
+ map <int, string> CGIs;
+ node = xml.SearchForTag(0,"ISAPI");
+ while (node)
+ {
+ // Map Extension to Interpreter
+ node2 = xml.SearchForTag(node, "Extension");
+ string cExt;
+ if (node2)
+ {
+ cExt = node2->get_Content();
+ }
+
+ node2 = xml.SearchForTag(node, "Interpreter");
+ if (node2)
+ {
+ IsapiDLLExtensions[cExt] = node2->get_Content();
+ CGIs[Counter] = cExt;
+ }
+
+ CkXml *curNode = node;
+ Counter++;
+ node = xml.SearchForTag(curNode,"ISAPI");
+ delete curNode;
+ }
+
+ // All the ISAPI dll's have been named etc, lets load them.
+ Counter = 0;
+ while (CGIs[Counter].length() > 0)
+ {
+ IsapiDLL[ CGIs[Counter] ] = LoadLibrary(IsapiDLLExtensions[ CGIs[Counter] ].c_str());
+ if(IsapiDLL[ CGIs[Counter] ] == NULL)
+ {
+ string MsgText = "Could not load ISAPI module ";
+ MsgText += IsapiDLLExtensions[ CGIs[Counter] ];
+ MsgText += "!";
+ MessageBox(NULL, MsgText.c_str(), "SWEBS", MB_OK);
+ }
+ Counter++;
+ }
+
// Index files
node = xml.SearchForTag(0,"IndexFile");
int X = 0;
Index: SWEBSMain.cpp
===================================================================
RCS file: /cvsroot/swebs/SWEBS Server/Source/SWEBSMain.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- SWEBSMain.cpp 1 Nov 2003 01:22:13 -0000 1.5
+++ SWEBSMain.cpp 15 Nov 2003 23:20:24 -0000 1.6
@@ -345,11 +345,11 @@
SWEBSGlobals.ErrorCodes[302] = "Moved Temporarily";
SWEBSGlobals.ErrorCodes[500] = "Internal Server Error";
- //!=============================================================================
+ /*//!=============================================================================
// This is for ISAPI testing, remove after
SWEBSGlobals.IsapiDLLExtensions["php"] = "C:\\PHP\\php-4.3.1-Win32\\SAPI\\php4isapi.dll";
- SWEBSGlobals.IsapiDLL["php"]= LoadLibrary(SWEBSGlobals.IsapiDLLExtensions["php"].c_str());// Loads the DLL
+ SWEBSGlobals.IsapiDLL["php"]= LoadLibrary(SWEBSGlobals.IsapiDLLExtensions["php"].c_str());// Loads the DLL*/
//------------------------------------------------------------------------------
// Step 3: Start web server
@@ -464,14 +464,6 @@
CONNECTION NewConn(Arg->SFD, Arg->CLA);
NewConn.ReadRequest(); // Read in the request
NewConn.HandleRequest(); // Handle the request
-
- /*while (NewConn.ConnectionType == "Keep-Alive")
- {
- NewConn.Clear();
- NewConn.ReadRequest();
- NewConn.HandleRequest();
- else break;
- }*/
closesocket(Arg->SFD);
return 0;
}
Index: SWEBSSocket.cpp
===================================================================
RCS file: /cvsroot/swebs/SWEBS Server/Source/SWEBSSocket.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- SWEBSSocket.cpp 1 Nov 2003 01:22:13 -0000 1.3
+++ SWEBSSocket.cpp 15 Nov 2003 23:20:24 -0000 1.4
@@ -18,6 +18,16 @@
using namespace std;
#pragma comment(lib, "wsock32.lib")
+DWORD WINAPI TimeoutThread(LPVOID lpParam);
+
+DWORD WINAPI TimeoutThread(LPVOID lpParam)
+{
+ int SFD = (int)lpParam;
+ Sleep(60000);
+ closesocket(SFD);
+ return true;
+}
+
//----------------------------------------------------------------------------------
// Send()
// Our own version of send(), so that we can keep track of whats being sent
@@ -44,6 +54,23 @@
{
string Temp;
char Buffer[0x1000] = "";
+ DWORD dwThreadId;
+ HANDLE hThread;
+
+ // Before we start reading, create our timeout thread
+ hThread = CreateThread(
+ NULL, // default security attributes
+ 0, // use default stack size
+ TimeoutThread, // thread function
+ &SFD, // argument to thread function
+ 0, // use default creation flags
+ &dwThreadId
+ ); // returns the thread identifier
+
+ if (hThread != NULL) // If the thread was created, destroy it
+ {
+ CloseHandle( hThread );
+ }
int X = recv(SFD, Buffer, 0x1000, 0);
while ( X > 0 )
|