[PHP-DEV] CVS update: php31/main From: shane (php-dev <email protected>)
Date: 05/31/98

Date: Sunday May 31, 1998 @ 16:23
Author: shane

Update of /repository/php31/main
In directory asf:/tmp/cvs-serv28442/main

Modified Files:
        alloc.c main.c main.h php3_threads.c php3_threads.h tls.h
Log Message:
Fix sapi cgi. fixes to mutex and critical sections code.

Index: php31/main/alloc.c
diff -c php31/main/alloc.c:1.4 php31/main/alloc.c:1.5
*** php31/main/alloc.c:1.4 Sun May 31 15:43:59 1998
--- php31/main/alloc.c Sun May 31 16:23:24 1998
***************
*** 358,375 ****
  #if DEBUG
                  /* does not use php3_error() *intentionally* */
                  if (GLOBAL(error_reporting) & E_WARNING && GLOBAL(shutdown_requested)!=ABNORMAL_SHUTDOWN) {
! # if APACHE /* log into the errorlog, since at this time we can't send messages to the browser */
! char memory_leak_buf[512];
!
! snprintf(memory_leak_buf,512,"Possible PHP3 memory leak detected (harmless): %d bytes from %s:%d",t->size,t->filename,t->lineno);
! #if MODULE_MAGIC_NUMBER >= 19970831
! aplog_error(NULL, 0, APLOG_ERR | APLOG_NOERRNO, GLOBAL(php3_rqst)->server, memory_leak_buf);
! #else
! log_error(memory_leak_buf,GLOBAL(php3_rqst)->server);
! #endif
! # else
! php3_printf("Freeing %x (%d bytes), allocated in %s on line %d<br>\n",(void *)((char *)t+sizeof(mem_header)+PLATFORM_PADDING),t->size,t->filename,t->lineno);
! # endif
                  }
  #endif
                  p = t->pNext;
--- 358,366 ----
  #if DEBUG
                  /* does not use php3_error() *intentionally* */
                  if (GLOBAL(error_reporting) & E_WARNING && GLOBAL(shutdown_requested)!=ABNORMAL_SHUTDOWN) {
! # if CRASH_DETECTION /* log into the errorlog, since at this time we can't send messages to the browser */
! debug_log("Possible PHP3 memory leak detected (harmless): %d bytes from %s:%d",t->size,t->filename,t->lineno);
! # endif
                  }
  #endif
                  p = t->pNext;
Index: php31/main/main.c
diff -c php31/main/main.c:1.16 php31/main/main.c:1.17
*** php31/main/main.c:1.16 Sun May 31 15:44:00 1998
--- php31/main/main.c Sun May 31 16:23:24 1998
***************
*** 29,35 ****
     +----------------------------------------------------------------------+
   */
  
! /* $Id: main.c,v 1.16 1998/05/31 19:44:00 shane Exp $ */
  
  /* #define CRASH_DETECTION */
  
--- 29,35 ----
     +----------------------------------------------------------------------+
   */
  
! /* $Id: main.c,v 1.17 1998/05/31 20:23:24 shane Exp $ */
  
  /* #define CRASH_DETECTION */
  
***************
*** 132,137 ****
--- 132,139 ----
  #if defined(CRASH_DETECTION)
  /******************************************************************************
  /* function to log debug messages
+ /* we may have to throw some server specific stuff into this
+ /* function for debugging purposes.
  /*****************************************************************************/
  void debug_log(const char *format,...)
  {
Index: php31/main/main.h
diff -c php31/main/main.h:1.1.1.1 php31/main/main.h:1.2
*** php31/main/main.h:1.1.1.1 Tue May 26 22:27:01 1998
--- php31/main/main.h Sun May 31 16:23:25 1998
***************
*** 29,35 ****
   */
  
  
! /* $Id: main.h,v 1.1.1.1 1998/05/27 02:27:01 rasmus Exp $ */
  
  
  #ifndef _MAIN_H
--- 29,35 ----
   */
  
  
! /* $Id: main.h,v 1.2 1998/05/31 20:23:25 shane Exp $ */
  
  
  #ifndef _MAIN_H
***************
*** 75,80 ****
--- 75,82 ----
  
  extern int php3_get_lineno(int lineno);
  extern char *php3_get_filename(int lineno);
+
+ extern void debug_log(const char *format,...);
  
  #ifndef THREAD_SAFE
  extern int shutdown_requested;
Index: php31/main/php3_threads.c
diff -c php31/main/php3_threads.c:1.4 php31/main/php3_threads.c:1.5
*** php31/main/php3_threads.c:1.4 Sat May 30 16:50:03 1998
--- php31/main/php3_threads.c Sun May 31 16:23:25 1998
***************
*** 9,28 ****
  PHPAPI MUTEX_T php3_mutex_alloc( void )
  {
     MUTEX_T mutexp;
! /* Allocate memory for the mutex and initialize it */
! /* cant use emalloc because we may allocate mutexes before
! the memory manager is started */
! if ( (mutexp = malloc( sizeof(MUTEX_T) )) != NULL ) {
! MUTEX_INIT( mutexp, NULL );
! }
     return( mutexp );
  }
  
  /* Function for freeing mutexes */
  PHPAPI void php3_mutex_free( MUTEX_T mutexp )
  {
! MUTEX_DESTROY(mutexp);
! free (mutexp);
  }
  
  PHPAPI int php3_mutex_lock( MUTEX_T mutexp )
--- 9,24 ----
  PHPAPI MUTEX_T php3_mutex_alloc( void )
  {
     MUTEX_T mutexp;
! MUTEX_INIT( mutexp, NULL );
     return( mutexp );
  }
  
  /* Function for freeing mutexes */
  PHPAPI void php3_mutex_free( MUTEX_T mutexp )
  {
! if(mutexp){
! MUTEX_DESTROY(mutexp);
! }
  }
  
  PHPAPI int php3_mutex_lock( MUTEX_T mutexp )
***************
*** 37,55 ****
  
  CRITICAL_SECT_T php3_critical_alloc( void ){
          CRITICAL_SECT_T csect;
!
! /* Allocate memory for the mutex and initialize it */
! /* cant use emalloc because we may allocate mutexes before
! the memory manager is started */
! if ( (csect = malloc( sizeof(CRITICAL_SECT_T) )) != NULL ) {
! CRITICAL_INIT( csect );
! }
! return( csect );
  }
  
  PHPAPI void php3_critical_free( CRITICAL_SECT_T critvar ){
          CRITICAL_DELETE(critvar);
- free(critvar);
  }
  
  PHPAPI void php3_critical_enter( CRITICAL_SECT_T critvar ){
--- 33,44 ----
  
  CRITICAL_SECT_T php3_critical_alloc( void ){
          CRITICAL_SECT_T csect;
! CRITICAL_INIT( csect );
! return( csect );
  }
  
  PHPAPI void php3_critical_free( CRITICAL_SECT_T critvar ){
          CRITICAL_DELETE(critvar);
  }
  
  PHPAPI void php3_critical_enter( CRITICAL_SECT_T critvar ){
Index: php31/main/php3_threads.h
diff -c php31/main/php3_threads.h:1.5 php31/main/php3_threads.h:1.6
*** php31/main/php3_threads.h:1.5 Sat May 30 20:32:04 1998
--- php31/main/php3_threads.h Sun May 31 16:23:25 1998
***************
*** 11,21 ****
  # define MUTEX_DESTROY(a) CloseHandle(a)
  # define MUTEX_LOCK(a) WaitForSingleObject(a,INFINITE)
  # define MUTEX_UNLOCK(a) ReleaseMutex(a)
! # define CRITICAL_SECT_T LPCRITICAL_SECTION
! # define CRITICAL_INIT(a) InitializeCriticalSection(a)
! # define CRITICAL_ENTER(a) EnterCriticalSection(a)
! # define CRITICAL_LEAVE(a) LeaveCriticalSection(a)
! # define CRITICAL_DELETE(a) DeleteCriticalSection(a)
  # define TLS_T DWORD
  # define TLS_ALLOC(a) (a=TlsAlloc())
  # define TLS_NOT_ALLOCED 0xFFFFFFFF
--- 11,21 ----
  # define MUTEX_DESTROY(a) CloseHandle(a)
  # define MUTEX_LOCK(a) WaitForSingleObject(a,INFINITE)
  # define MUTEX_UNLOCK(a) ReleaseMutex(a)
! # define CRITICAL_SECT_T CRITICAL_SECTION
! # define CRITICAL_INIT(a) InitializeCriticalSection(&a)
! # define CRITICAL_ENTER(a) EnterCriticalSection(&a)
! # define CRITICAL_LEAVE(a) LeaveCriticalSection(&a)
! # define CRITICAL_DELETE(a) DeleteCriticalSection(&a)
  # define TLS_T DWORD
  # define TLS_ALLOC(a) (a=TlsAlloc())
  # define TLS_NOT_ALLOCED 0xFFFFFFFF
Index: php31/main/tls.h
diff -c php31/main/tls.h:1.9 php31/main/tls.h:1.10
*** php31/main/tls.h:1.9 Sat May 30 20:48:54 1998
--- php31/main/tls.h Sun May 31 16:23:25 1998
***************
*** 40,48 ****
  #include "ext/standard/number.h"
  #include "constants.h"
  #include <sys/stat.h>
- #if USE_SAPI
  #include "sapi/sapi.h"
- #endif
  #include "mod_php3.h"
  
  typedef struct php3_global_struct{
--- 40,46 ----
***************
*** 114,125 ****
          int in_eval;
          int php3_display_source;
          int php3_preprocess;
- #if APACHE
- request_rec *php3_rqst;
- #endif
- #if USE_SAPI
          struct sapi_request_info *sapi_rqst;
- #endif
  #if WIN32|WINNT
          unsigned int wintimer_counter;
          unsigned int wintimer;
--- 112,118 ----
***************
*** 164,173 ****
          int php3_PrintHeader;
          char *cont_type;
          int header_called;
- /*info.c*/
- #if APACHE
- module *top_module;
- #endif
          /*pageinfo.c*/
          long page_uid;
          long page_inode;
--- 157,162 ----