2009-01-27 00:21 UTC+0100 Viktor Szakats (harbour.01 syenar hu)

* contrib/examples/uhttpd/uhttpd.prg
    + Added callstack in RTE message (ugly but useful).
    ! Fixed RTE when displaying server status.
      (might have broken non-inet-mode)

  * contrib/examples/uhttpd/hbmk_b32.bat
  * contrib/examples/uhttpd/hbmk_vc.bat
    + Trying to shutdown server before build.
This commit is contained in:
Viktor Szakats
2009-01-26 23:23:19 +00:00
parent 913cfad6ba
commit e06dda2c13
4 changed files with 175 additions and 13 deletions

View File

@@ -8,6 +8,16 @@
2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org)
*/
2009-01-27 00:21 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
* contrib/examples/uhttpd/uhttpd.prg
+ Added callstack in RTE message (ugly but useful).
! Fixed RTE when displaying server status.
(might have broken non-inet-mode)
* contrib/examples/uhttpd/hbmk_b32.bat
* contrib/examples/uhttpd/hbmk_vc.bat
+ Trying to shutdown server before build.
2009-01-26 15:07 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
* harbour/contrib/gtwvg/gtwvg.c
* harbour/contrib/gtwvg/gtwvg.h
@@ -18,23 +28,23 @@
behavior in GTWVG with GUI elelments.
2009-01-26 23:37 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
* contrib/examples/uhttpd/hbmk_b32.bat
! Missed update from previous commit.
* contrib/examples/uhttpd/hbmk_b32.bat
! Missed update from previous commit.
2009-01-26 23:32 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
+ contrib/examples/uhttpd/hbmk_vc.bat
+ Added MSVC make file.
+ contrib/examples/uhttpd/hbmk_vc.bat
+ Added MSVC make file.
* contrib/examples/uhttpd/socket.c
! Made it compile with MSVC.
! Added SVN header.
* contrib/examples/uhttpd/socket.c
! Made it compile with MSVC.
! Added SVN header.
* contrib/examples/uhttpd/uhttpd.prg
+ contrib/examples/uhttpd/uhttpdc.c
+ C level stuff moved to separate file.
* contrib/examples/uhttpd/uhttpd.prg
+ contrib/examples/uhttpd/uhttpdc.c
+ C level stuff moved to separate file.
; NOTE: I'm getting an "Argument error: +" when browse
to http://localhost:8082 (using Chrome if that matters).
; NOTE: I'm getting an "Argument error: +" when browse
to http://localhost:8082 (using Chrome if that matters).
2009-01-26 22:57 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
* source/rdd/usrrdd/example/exhsx.prg

View File

@@ -43,6 +43,8 @@ if %UHTTP_GD_SUPPORT%.==yes. SET UHTTP_GD_LIBS=hbgd.lib bgd.lib
if %UHTTP_INET_SUPPORT%.==yes. SET UHTTP_INET_DEF=-DUSE_HB_INET
if %UHTTP_INET_SUPPORT%.==no. SET UHTTP_INET_SOCKET=socket.c
if exist uhttpd.exe uhttpd -s
..\..\..\bin\harbour uhttpd /n /es2 /w3 /i..\..\..\include %UHTTP_GD_DEF% %UHTTP_INET_DEF%
if errorlevel 1 goto DOERROR
bcc32 -O2 -tW -d -a8 -I..\..\..\include -L..\..\..\lib uhttpd.c uhttpdc.c %UHTTP_INET_SOCKET% hbdebug.lib hbvmmt.lib hbrtl.lib gtwvt.lib gtwin.lib gtgui.lib hblang.lib hbrdd.lib hbmacro.lib hbpp.lib rddntx.lib rddcdx.lib rddfpt.lib hbcpage.lib hbsix.lib hbcommon.lib hbpcre.lib hbhsx.lib hbzlib.lib xhb.lib hbct.lib cw32mt.lib %UHTTP_GD_LIBS%

View File

@@ -43,6 +43,8 @@ if %UHTTP_GD_SUPPORT%.==yes. SET UHTTP_GD_LIBS=hbgd.lib bgd.lib
if %UHTTP_INET_SUPPORT%.==yes. SET UHTTP_INET_DEF=-DUSE_HB_INET
if %UHTTP_INET_SUPPORT%.==no. SET UHTTP_INET_SOCKET=socket.c
if exist uhttpd.exe uhttpd -s
..\..\..\bin\harbour uhttpd /n /es2 /w3 /i..\..\..\include %UHTTP_GD_DEF% %UHTTP_INET_DEF%
if errorlevel 1 goto DOERROR
cl -nologo -O2 -W3 -I..\..\..\include uhttpd.c uhttpdc.c %UHTTP_INET_SOCKET% /link /subsystem:windows /libpath:..\..\..\lib hbcpage.lib hbdebug.lib hbvmmt.lib hbrtl.lib gtwin.lib hblang.lib hbrdd.lib hbmacro.lib hbpp.lib rddntx.lib rddcdx.lib rddfpt.lib hbsix.lib hbcommon.lib hbpcre.lib hbzlib.lib user32.lib wsock32.lib advapi32.lib hbct.lib gdi32.lib hbwin.lib hbhsx.lib gtwvt.lib %UHTTP_GD_LIBS% xhb.lib

View File

@@ -84,6 +84,7 @@
#include "fileio.ch"
#include "common.ch"
#include "inkey.ch"
#include "error.ch"
#include "hbextern.ch" // need this to use with HRB
@@ -176,6 +177,8 @@ THREAD STATIC t_hProc
MEMVAR _SERVER, _GET, _POST, _REQUEST, _HTTP_REQUEST, m_cPost
ANNOUNCE ERRORSYS
FUNCTION MAIN( ... )
LOCAL nPort, hListen, hSocket, aRemote, cI, xVal
LOCAL aThreads, nStartThreads, nMaxThreads, nStartServiceThreads
@@ -196,6 +199,8 @@ LOCAL cCmdPort, cCmdDocumentRoot, lCmdIndexes, nCmdStartThreads, nCmdMaxThreads
SysSettings()
ErrorBlock( { | oError | httpd_DefError( oError ) } )
// ----------------------- Parameters defaults -----------------------------
// defaults not changeble via ini file
@@ -652,6 +657,8 @@ LOCAL aI
nThreadId := hb_threadID()
//nThreadIdRef := nThreadId
ErrorBlock( { | oError | httpd_DefError( oError ) } )
WriteToConsole( "Starting ProcessConnections() " + hb_CStr( nThreadId ) )
IF hb_mutexLock( s_hmtxBusy )
@@ -850,6 +857,8 @@ LOCAL nRcvLen, nContLen
LOCAL aI
#endif
ErrorBlock( { | oError | httpd_DefError( oError ) } )
nThreadId := hb_threadID()
//nThreadIdRef := nThreadId
@@ -1670,7 +1679,7 @@ STATIC PROCEDURE ShowServerStatus()
uWrite( '<title>Server Status</title><body><h1>Server Status</h1><pre>')
//uWrite( '<table border="0">')
uWrite( 'SERVER: ' + _SERVER[ "SERVER_SOFTWARE" ] + " Server at " + _SERVER[ "SERVER_NAME" ] + " Port " + LTrim( Str( _SERVER[ "SERVER_PORT" ] ) ) )
uWrite( 'SERVER: ' + _SERVER[ "SERVER_SOFTWARE" ] + " Server at " + _SERVER[ "SERVER_NAME" ] + " Port " + _SERVER[ "SERVER_PORT" ] )
uWrite( '<br>' )
IF hb_mutexLock( s_hmtxBusy )
uWrite( '<br>Thread: ' + Str( s_nThreads ) )
@@ -1947,3 +1956,142 @@ STATIC FUNCTION ParseIni( cConfig )
ENDIF
RETURN hDefault
STATIC FUNCTION httpd_DefError( oError )
LOCAL cMessage
LOCAL cCallstack
LOCAL cDOSError
LOCAL aOptions
LOCAL nChoice
LOCAL n
// By default, division by zero results in zero
IF oError:genCode == EG_ZERODIV .AND. ;
oError:canSubstitute
RETURN 0
ENDIF
// By default, retry on RDD lock error failure */
IF oError:genCode == EG_LOCK .AND. ;
oError:canRetry
// oError:tries++
RETURN .T.
ENDIF
// Set NetErr() of there was a database open error
IF oError:genCode == EG_OPEN .AND. ;
oError:osCode == 32 .AND. ;
oError:canDefault
NetErr( .T. )
RETURN .F.
ENDIF
// Set NetErr() if there was a lock error on dbAppend()
IF oError:genCode == EG_APPENDLOCK .AND. ;
oError:canDefault
NetErr( .T. )
RETURN .F.
ENDIF
cMessage := ErrorMessage( oError )
IF ! Empty( oError:osCode )
cDOSError := "(DOS Error " + hb_NToS( oError:osCode ) + ")"
ENDIF
// ;
cCallstack := ""
n := 1
DO WHILE ! Empty( ProcName( ++n ) )
cCallstack += "Called from " + ProcName( n ) + "(" + hb_NToS( ProcLine( n ) ) + ") "
ENDDO
// Build buttons
aOptions := {}
AAdd( aOptions, "Quit" )
IF oError:canRetry
AAdd( aOptions, "Retry" )
ENDIF
IF oError:canDefault
AAdd( aOptions, "Default" )
ENDIF
// Show alert box
nChoice := 0
DO WHILE nChoice == 0
IF ISNIL( cDOSError )
nChoice := Alert( cMessage + " " + cCallstack, aOptions )
ELSE
nChoice := Alert( cMessage + ";" + cDOSError + " " + cCallstack, aOptions )
ENDIF
ENDDO
IF ! Empty( nChoice )
DO CASE
CASE aOptions[ nChoice ] == "Break"
Break( oError )
CASE aOptions[ nChoice ] == "Retry"
RETURN .T.
CASE aOptions[ nChoice ] == "Default"
RETURN .F.
ENDCASE
ENDIF
// "Quit" selected
IF ! ISNIL( cDOSError )
cMessage += " " + cDOSError
ENDIF
OutErr( hb_OSNewLine() )
OutErr( cMessage )
OutErr( hb_OSNewLine() )
OutErr( cCallstack )
ErrorLevel( 1 )
QUIT
RETURN .F.
STATIC FUNCTION ErrorMessage( oError )
// start error message
LOCAL cMessage := iif( oError:severity > ES_WARNING, "Error", "Warning" ) + " "
// add subsystem name if available
IF ISCHARACTER( oError:subsystem )
cMessage += oError:subsystem()
ELSE
cMessage += "???"
ENDIF
// add subsystem's error code if available
IF ISNUMBER( oError:subCode )
cMessage += "/" + hb_NToS( oError:subCode )
ELSE
cMessage += "/???"
ENDIF
// add error description if available
IF ISCHARACTER( oError:description )
cMessage += " " + oError:description
ENDIF
// add either filename or operation
DO CASE
CASE !Empty( oError:filename )
cMessage += ": " + oError:filename
CASE !Empty( oError:operation )
cMessage += ": " + oError:operation
ENDCASE
RETURN cMessage