tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/jk/native/netscape nsapi.dsp
Date Sat, 05 Feb 2005 19:40:19 GMT
mturk       2005/02/05 11:40:19

  Modified:    jk/native/apache-1.3 Makefile.vc mod_jk.dsp
               jk/native/apache-2.0 Makefile.vc NWGNUmakefile mod_jk.dsp
               jk/native/common list.mk.in
               jk/native/iis isapi.dsp
               jk/native/netscape nsapi.dsp
  Added:       jk/native/common jk_shm.c jk_shm.h
  Log:
  Add shared memory support.
  
  Revision  Changes    Path
  1.3       +8 -0      jakarta-tomcat-connectors/jk/native/apache-1.3/Makefile.vc
  
  Index: Makefile.vc
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/apache-1.3/Makefile.vc,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Makefile.vc	27 Dec 2004 08:46:57 -0000	1.2
  +++ Makefile.vc	5 Feb 2005 19:40:19 -0000	1.3
  @@ -51,6 +51,7 @@
   	-@erase "$(INTDIR)\jk_md5.obj"
   	-@erase "$(INTDIR)\jk_msg_buff.obj"
   	-@erase "$(INTDIR)\jk_pool.obj"
  +	-@erase "$(INTDIR)\jk_shm.obj"
   	-@erase "$(INTDIR)\jk_sockbuf.obj"
   	-@erase "$(INTDIR)\jk_uri_worker_map.obj"
   	-@erase "$(INTDIR)\jk_util.obj"
  @@ -87,6 +88,7 @@
   	"$(INTDIR)\jk_md5.obj" \
   	"$(INTDIR)\jk_msg_buff.obj" \
   	"$(INTDIR)\jk_pool.obj" \
  +	"$(INTDIR)\jk_shm.obj" \
   	"$(INTDIR)\jk_sockbuf.obj" \
   	"$(INTDIR)\jk_uri_worker_map.obj" \
   	"$(INTDIR)\jk_util.obj" \
  @@ -226,6 +228,12 @@
   	$(CPP) $(CPP_PROJ) $(SOURCE)
   
   
  +SOURCE=..\common\jk_shm.c
  +
  +"$(INTDIR)\jk_shm.obj" : $(SOURCE) "$(INTDIR)"
  +	$(CPP) $(CPP_PROJ) $(SOURCE)
  +
  +
   SOURCE=..\common\jk_sockbuf.c
   
   "$(INTDIR)\jk_sockbuf.obj" : $(SOURCE) "$(INTDIR)"
  
  
  
  1.8       +46 -40    jakarta-tomcat-connectors/jk/native/apache-1.3/mod_jk.dsp
  
  Index: mod_jk.dsp
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/apache-1.3/mod_jk.dsp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- mod_jk.dsp	23 Dec 2004 14:20:44 -0000	1.7
  +++ mod_jk.dsp	5 Feb 2005 19:40:19 -0000	1.8
  @@ -42,8 +42,8 @@
   # PROP Intermediate_Dir "Release"
   # PROP Ignore_Export_Lib 0
   # PROP Target_Dir ""
  -# ADD BASE CPP /nologo /MD /W3 /O2 /Zi /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS"
/D "_USRDLL" /D "MOD_JK_EXPORTS" /FD /c
  -# ADD CPP /nologo /MD /W3 /O2 /Zi /I "..\common" /I "$(APACHE1_HOME)\include" /I "$(APACHE1_HOME)\src\include"
/I "$(APACHE1_HOME)\src\os\win32" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32"
/D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MOD_JK_EXPORTS" /Fd"Release\mod_jk_src"
/FD /c
  +# ADD BASE CPP /nologo /MD /W3 /Zi /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS"
/D "_USRDLL" /D "MOD_JK_EXPORTS" /FD /c
  +# ADD CPP /nologo /MD /W3 /Zi /O2 /I "..\common" /I "$(APACHE1_HOME)\include" /I "$(APACHE1_HOME)\src\include"
/I "$(APACHE1_HOME)\src\os\win32" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32"
/D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MOD_JK_EXPORTS" /Fd"Release\mod_jk_src"
/FD /c
   # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
   # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
   # ADD BASE RSC /l 0x409 /d "NDEBUG"
  @@ -53,7 +53,7 @@
   # ADD BSC32 /nologo
   LINK32=link.exe
   # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib
shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
  -# ADD LINK32 ApacheCore.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
/nologo /base:"0x6A6B0000" /subsystem:windows /dll /incremental:no /debug /machine:I386 /out:"Release/mod_jk.so"
/opt:ref /libpath:"$(APACHE1_HOME)\libexec" /libpath:"$(APACHE1_HOME)\src\CoreR" /libpath:"$(APACHE1_HOME)\src\Release"
  +# ADD LINK32 ApacheCore.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
/nologo /base:"0x6A6B0000" /subsystem:windows /dll /debug /machine:I386 /out:"Release/mod_jk.so"
/libpath:"$(APACHE1_HOME)\libexec" /libpath:"$(APACHE1_HOME)\src\CoreR" /libpath:"$(APACHE1_HOME)\src\Release"
/opt:ref
   
   !ELSEIF  "$(CFG)" == "mod_jk - Win32 Debug"
   
  @@ -104,10 +104,26 @@
   # End Source File
   # Begin Source File
   
  +SOURCE=..\common\jk_ajp14.c
  +# End Source File
  +# Begin Source File
  +
  +SOURCE=..\common\jk_ajp14_worker.c
  +# End Source File
  +# Begin Source File
  +
  +SOURCE=..\common\jk_ajp_common.c
  +# End Source File
  +# Begin Source File
  +
   SOURCE=..\common\jk_connect.c
   # End Source File
   # Begin Source File
   
  +SOURCE=..\common\jk_context.c
  +# End Source File
  +# Begin Source File
  +
   SOURCE=..\common\jk_jni_worker.c
   # End Source File
   # Begin Source File
  @@ -120,6 +136,10 @@
   # End Source File
   # Begin Source File
   
  +SOURCE=..\common\jk_md5.c
  +# End Source File
  +# Begin Source File
  +
   SOURCE=..\common\jk_msg_buff.c
   # End Source File
   # Begin Source File
  @@ -128,6 +148,10 @@
   # End Source File
   # Begin Source File
   
  +SOURCE=..\common\jk_shm.c
  +# End Source File
  +# Begin Source File
  +
   SOURCE=..\common\jk_sockbuf.c
   # End Source File
   # Begin Source File
  @@ -146,46 +170,41 @@
   
   SOURCE=.\mod_jk.c
   # End Source File
  -# Begin Source File
  +# End Group
  +# Begin Group "Header Files"
   
  -SOURCE=..\common\jk_ajp14.c
  -# End Source File
  +# PROP Default_Filter "h;hpp;hxx;hm;inl"
   # Begin Source File
   
  -SOURCE=..\common\jk_ajp14_worker.c
  +SOURCE=..\common\jk_ajp12_worker.h
   # End Source File
   # Begin Source File
   
  -SOURCE=..\common\jk_md5.c
  +SOURCE=..\common\jk_ajp13.h
   # End Source File
   # Begin Source File
   
  -SOURCE=..\common\jk_context.c
  +SOURCE=..\common\jk_ajp13_worker.h
   # End Source File
   # Begin Source File
   
  -SOURCE=..\common\jk_ajp_common.c
  +SOURCE=..\common\jk_ajp14.h
   # End Source File
  -# End Group
  -
  -# Begin Group "Header Files"
  -
  -# PROP Default_Filter "h;hpp;hxx;hm;inl"
   # Begin Source File
   
  -SOURCE=..\common\jk_ajp12_worker.h
  +SOURCE=..\common\jk_ajp14_worker.h
   # End Source File
   # Begin Source File
   
  -SOURCE=..\common\jk_ajp13.h
  +SOURCE=..\common\jk_ajp_common.h
   # End Source File
   # Begin Source File
   
  -SOURCE=..\common\jk_ajp13_worker.h
  +SOURCE=..\common\jk_connect.h
   # End Source File
   # Begin Source File
   
  -SOURCE=..\common\jk_connect.h
  +SOURCE=..\common\jk_context.h
   # End Source File
   # Begin Source File
   
  @@ -209,6 +228,10 @@
   # End Source File
   # Begin Source File
   
  +SOURCE=..\common\jk_md5.h
  +# End Source File
  +# Begin Source File
  +
   SOURCE=..\common\jk_msg_buff.h
   # End Source File
   # Begin Source File
  @@ -225,6 +248,10 @@
   # End Source File
   # Begin Source File
   
  +SOURCE=..\common\jk_shm.h
  +# End Source File
  +# Begin Source File
  +
   SOURCE=..\common\jk_sockbuf.h
   # End Source File
   # Begin Source File
  @@ -243,28 +270,7 @@
   
   SOURCE=..\common\jk_worker_list.h
   # End Source File
  -# Begin Source File
  -
  -SOURCE=..\common\jk_ajp14.h
  -# End Source File
  -# Begin Source File
  -
  -SOURCE=..\common\jk_ajp14_worker.h
  -# End Source File
  -# Begin Source File
  -
  -SOURCE=..\common\jk_md5.h
  -# End Source File
  -# Begin Source File
  -
  -SOURCE=..\common\jk_context.h
  -# End Source File
  -# Begin Source File
  -
  -SOURCE=..\common\jk_ajp_common.h
  -# End Source File
   # End Group
  -
   # Begin Group "Resource Files"
   
   # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
  
  
  
  1.3       +8 -0      jakarta-tomcat-connectors/jk/native/apache-2.0/Makefile.vc
  
  Index: Makefile.vc
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/apache-2.0/Makefile.vc,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Makefile.vc	27 Dec 2004 08:46:58 -0000	1.2
  +++ Makefile.vc	5 Feb 2005 19:40:19 -0000	1.3
  @@ -51,6 +51,7 @@
   	-@erase "$(INTDIR)\jk_md5.obj"
   	-@erase "$(INTDIR)\jk_msg_buff.obj"
   	-@erase "$(INTDIR)\jk_pool.obj"
  +	-@erase "$(INTDIR)\jk_shm.obj"
   	-@erase "$(INTDIR)\jk_sockbuf.obj"
   	-@erase "$(INTDIR)\jk_uri_worker_map.obj"
   	-@erase "$(INTDIR)\jk_util.obj"
  @@ -87,6 +88,7 @@
   	"$(INTDIR)\jk_md5.obj" \
   	"$(INTDIR)\jk_msg_buff.obj" \
   	"$(INTDIR)\jk_pool.obj" \
  +	"$(INTDIR)\jk_shm.obj" \
   	"$(INTDIR)\jk_sockbuf.obj" \
   	"$(INTDIR)\jk_uri_worker_map.obj" \
   	"$(INTDIR)\jk_util.obj" \
  @@ -226,6 +228,12 @@
   	$(CPP) $(CPP_PROJ) $(SOURCE)
   
   
  +SOURCE=..\common\jk_shm.c
  +
  +"$(INTDIR)\jk_shm.obj" : $(SOURCE) "$(INTDIR)"
  +	$(CPP) $(CPP_PROJ) $(SOURCE)
  +
  +
   SOURCE=..\common\jk_sockbuf.c
   
   "$(INTDIR)\jk_sockbuf.obj" : $(SOURCE) "$(INTDIR)"
  
  
  
  1.5       +1 -0      jakarta-tomcat-connectors/jk/native/apache-2.0/NWGNUmakefile
  
  Index: NWGNUmakefile
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/apache-2.0/NWGNUmakefile,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- NWGNUmakefile	9 Dec 2004 08:16:44 -0000	1.4
  +++ NWGNUmakefile	5 Feb 2005 19:40:19 -0000	1.5
  @@ -208,6 +208,7 @@
   	$(OBJDIR)/jk_md5.o \
   	$(OBJDIR)/jk_msg_buff.o \
   	$(OBJDIR)/jk_pool.o \
  +	$(OBJDIR)/jk_shm.o \
   	$(OBJDIR)/jk_sockbuf.o \
   	$(OBJDIR)/jk_uri_worker_map.o \
   	$(OBJDIR)/jk_util.o \
  
  
  
  1.9       +11 -3     jakarta-tomcat-connectors/jk/native/apache-2.0/mod_jk.dsp
  
  Index: mod_jk.dsp
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/apache-2.0/mod_jk.dsp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- mod_jk.dsp	23 Dec 2004 14:20:44 -0000	1.8
  +++ mod_jk.dsp	5 Feb 2005 19:40:19 -0000	1.9
  @@ -43,7 +43,7 @@
   # PROP Ignore_Export_Lib 0
   # PROP Target_Dir ""
   # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
  -# ADD CPP /nologo /MD /W3 /Zi /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /I "..\common" /I
"$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /I "$(APACHE2_HOME)\include" /I "$(APACHE2_HOME)\srclib\apr\include"
/I "$(APACHE2_HOME)\srclib\apr-util\include" /Fd"Release/mod_jk_src" /FD /c
  +# ADD CPP /nologo /MD /W3 /Zi /O2 /I "..\common" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32"
/I "$(APACHE2_HOME)\include" /I "$(APACHE2_HOME)\srclib\apr\include" /I "$(APACHE2_HOME)\srclib\apr-util\include"
/D "NDEBUG" /D "WIN32" /D "_WINDOWS" /Fd"Release/mod_jk_src" /FD /c
   # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
   # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
   # ADD BASE RSC /l 0x409 /d "NDEBUG"
  @@ -53,7 +53,7 @@
   # ADD BSC32 /nologo
   LINK32=link.exe
   # ADD BASE LINK32 kernel32.lib user32.lib advapi32.lib /nologo /dll /machine:I386
  -# ADD LINK32 libhttpd.lib libapr.lib libaprutil.lib kernel32.lib user32.lib advapi32.lib
wsock32.lib /nologo /base:"0x6A6B0000" /subsystem:windows /dll /incremental:no /debug /machine:I386
/out:"Release/mod_jk.so" /opt:ref /libpath:"$(APACHE2_HOME)\Release" /libpath:"$(APACHE2_HOME)\srclib\apr\Release"
/libpath:"$(APACHE2_HOME)\srclib\apr-util\Release" /libpath:"$(APACHE2_HOME)\lib"
  +# ADD LINK32 libhttpd.lib libapr.lib libaprutil.lib kernel32.lib user32.lib advapi32.lib
wsock32.lib /nologo /base:"0x6A6B0000" /subsystem:windows /dll /debug /machine:I386 /out:"Release/mod_jk.so"
/libpath:"$(APACHE2_HOME)\Release" /libpath:"$(APACHE2_HOME)\srclib\apr\Release" /libpath:"$(APACHE2_HOME)\srclib\apr-util\Release"
/libpath:"$(APACHE2_HOME)\lib" /opt:ref
   
   !ELSEIF  "$(CFG)" == "apache - Win32 Debug"
   
  @@ -69,7 +69,7 @@
   # PROP Ignore_Export_Lib 0
   # PROP Target_Dir ""
   # ADD BASE CPP /nologo /MDd /W3 /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c
  -# ADD CPP /nologo /MDd /W3 /GX /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /I "..\common"
/I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /I "$(APACHE2_HOME)\include" /I
"$(APACHE2_HOME)\srclib\apr\include" /I "$(APACHE2_HOME)\srclib\apr-util\include" /Fd"Debug/mod_jk_src"
/FD /c
  +# ADD CPP /nologo /MDd /W3 /GX /Zi /Od /I "..\common" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32"
/I "$(APACHE2_HOME)\include" /I "$(APACHE2_HOME)\srclib\apr\include" /I "$(APACHE2_HOME)\srclib\apr-util\include"
/D "_DEBUG" /D "WIN32" /D "_WINDOWS" /Fd"Debug/mod_jk_src" /FD /c
   # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
   # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
   # ADD BASE RSC /l 0x409 /d "_DEBUG"
  @@ -148,6 +148,10 @@
   # End Source File
   # Begin Source File
   
  +SOURCE=..\common\jk_shm.c
  +# End Source File
  +# Begin Source File
  +
   SOURCE=..\common\jk_sockbuf.c
   # End Source File
   # Begin Source File
  @@ -248,6 +252,10 @@
   # End Source File
   # Begin Source File
   
  +SOURCE=..\common\jk_shm.h
  +# End Source File
  +# Begin Source File
  +
   SOURCE=..\common\jk_sockbuf.h
   # End Source File
   # Begin Source File
  
  
  
  1.8       +1 -1      jakarta-tomcat-connectors/jk/native/common/list.mk.in
  
  Index: list.mk.in
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/list.mk.in,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- list.mk.in	4 Dec 2001 19:44:23 -0000	1.7
  +++ list.mk.in	5 Feb 2005 19:40:19 -0000	1.8
  @@ -6,5 +6,5 @@
                   ${JK}jk_lb_worker${OEXT} ${JK}jk_sockbuf${OEXT} \
                   ${JK}jk_map${OEXT} ${JK}jk_uri_worker_map${OEXT} \
                   ${JK}jk_ajp14${OEXT} ${JK}jk_ajp14_worker${OEXT} \
  -                ${JK}jk_md5${OEXT} @JK_JNI_WORKER@ \
  +                ${JK}jk_md5${OEXT} ${JK}jk_shm${OEXT} @JK_JNI_WORKER@ \
                   ${JK}jk_ajp_common${OEXT} ${JK}jk_context${OEXT}
  
  
  
  1.1                  jakarta-tomcat-connectors/jk/native/common/jk_shm.c
  
  Index: jk_shm.c
  ===================================================================
  /*
   *  Copyright 1999-2005 The Apache Software Foundation
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  
  /***************************************************************************
   * Description: Shared Memory support                                      *
   * Author:      Mladen Turk <mturk@jboss.com>                              *
   * Version:     $Revision: 1.1 $                                           *
   ***************************************************************************/
  
  #include "jk_pool.h"
  #include "jk_shm.h"
  
  const char shm_signature[] = { JK_SHM_MAGIC };
  
  #if defined (WIN32) || defined(NETWARE)
  
  /* Simulate file */
  static jk_shm_t *jk_global_shm = NULL;
  
  /* Use plain memory */
  jk_shm_t *jk_shm_open(const char *fname, int workers, int dynamic, jk_pool_t *p)
  {
      jk_shm_t *shm;
      jk_shm_h_rec_t *hdr;
  
      if (jk_global_shm)
          return jk_global_shm;
      shm = jk_pool_alloc(p, sizeof(jk_shm_t));
  
      shm->size = sizeof(jk_shm_h_rec_t) + (workers + dynamic) * sizeof(jk_shm_w_rec_t);
  
      shm->base = calloc(1, shm->size);
      if (!shm->base)
          return NULL;
      shm->filename = fname;
      shm->fd = -1;
      shm->attached = 0;
  
      hdr = (jk_shm_h_rec_t *)shm->base;
  
      memcpy(hdr->magic, shm_signature, 8);
      hdr->workers = workers;
      hdr->dynamic = dynamic;
  
      jk_global_shm = shm;
      return shm;
  }
  
  jk_shm_t *jk_shm_attach(const char *fname, int workers, int dynamic, jk_pool_t *p)
  {
      jk_shm_t *shm = jk_shm_open(fname, workers, dynamic, p);
  
      if (shm) {
          shm->attached = 1;
      }
      return shm;
  }
  
  void jk_shm_close(jk_shm_t *shm)
  {
      if (shm) {
          if (shm->base)
              free(shm->base);
          shm->base = NULL;
      }
  }
  
  
  
  #else
  
  #include <unistd.h>
  #include <fcntl.h>
  #include <errno.h>
  #include <sys/stat.h>
  #include <sys/mman.h>
  #include <sys/uio.h>
  
  #ifndef MAP_FAILED
  #define MAP_FAILED  (-1)
  #endif
  
  #ifndef MAP_FILE
  #define MAP_FILE    (0)
  #endif
  
  static jk_shm_t *do_shm_open(const char *fname, int workers, int dynamic,
                               jk_pool_t *p, int attached)
  {
      jk_shm_t *shm;
      int fd;
      int flags = O_RDWR;
  
      if (!attached)
          flags |= (O_CREAT|O_TRUNC);
      fd = open(fname, flags, 0666);
      if (fd == -1)
          return NULL;
      shm = jk_pool_alloc(p, sizeof(jk_shm_t));
      shm->size = sizeof(jk_shm_h_rec_t) + (workers + dynamic) * sizeof(jk_shm_w_rec_t);
  
      if (!attached) {
          size_t size = lseek(fd, 0, SEEK_END);
          if (size < shm->size) {
              size = shm->size;
              if (ftruncate(fd, shm->size)) {
                  close(fd);
                  return NULL;
              }
          }
      }
      if (lseek(fd, 0, SEEK_SET) != 0) {
          close(fd);
          return NULL;
      }
  
      shm->base = mmap(NULL, shm->size,
                      PROT_READ | PROT_WRITE,
                      MAP_FILE | MAP_SHARED,
                      fd, 0);
      if (shm->base == (void *)MAP_FAILED) {
          shm->base = NULL;
      }
      if (!shm->base) {
          close(fd);
          return NULL;
      }
      shm->filename = fname;
      shm->fd = fd;
      shm->attached = attached;
  
      /* Clear shared memory */
      if (!attached) {
          jk_shm_h_rec *hdr;
  
          memset(shm->base, 0, size);
          hdr = (jk_shm_h_rec_t *)shm->base;
  
          memcpy(hdr->magic, shm_signature, 8);
          hdr->workers = workers;
          hdr->dynamic = dynamic;
      }
      else {
          /* TODO: check header magic */
      }
  
      return shm;
  }
  
  jk_shm_t *jk_shm_open(const char *fname, int workers, int dynamic, jk_pool_t *p)
  {
      return do_shm_open(fname, workers, dynamic, p, 0);
  }
  
  jk_shm_t *jk_shm_attach(const char *fname, int workers, int dynamic, jk_pool_t *p)
  {
      return do_shm_open(fname, workers, dynamic, p, 1);
  }
  
  void jk_shm_close(jk_shm_t *shm)
  {
      if (shm) {
          if (shm->base)
              munmap(shm->base, shm->size);
              close(shm->fd);
          }
          shm->base = NULL;
          shm->fd = -1;
      }
  }
  
  
  #endif
  
  jk_shm_h_rec_t *jk_shm_header(jk_shm_t *shm)
  {
      if (shm && shm->base) {
          return (jk_shm_h_rec_t *)shm->base;
      }
      else
          return NULL;
  }
  
  jk_shm_w_rec_t *jk_shm_worker(jk_shm_t *shm, int id)
  {
      jk_shm_w_rec_t *w = NULL;
      if (shm && shm->base && id >= 0) {
          jk_shm_h_rec_t *hdr = (jk_shm_h_rec_t *)shm->base;
          if (id < (hdr->workers + hdr->dynamic)) {
              unsigned char *base = (unsigned char *)shm->base;
              base += (sizeof(jk_shm_h_rec_t) + id * sizeof(jk_shm_w_rec_t));
              w = (jk_shm_w_rec_t *)base;
              /* Check worker id */
              if (id < hdr->workers && id != w->id)
                  w = NULL;
          }
  
      }
      return w;
  }
  
  
  
  1.1                  jakarta-tomcat-connectors/jk/native/common/jk_shm.h
  
  Index: jk_shm.h
  ===================================================================
  /*
   *  Copyright 1999-2005 The Apache Software Foundation
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  
  /***************************************************************************
   * Description: Shared Memory object header file                           *
   * Author:      Mladen Turk <mturk@jboss.com>                              *
   * Version:     $Revision: 1.1 $                                           *
   ***************************************************************************/
  #ifndef _JK_SHM_H
  #define _JK_SHM_H
  
  #include "jk_global.h"
  
  #ifdef __cplusplus
  extern "C"
  {
  #endif                          /* __cplusplus */
  
  /**
   * @file jk_shm.h
   * @brief Jk shared memory management
   *
   *
   */
  
  #define JK_SHM_MAJOR    '1'
  #define JK_SHM_MINOR    '0'
  #define JK_SHM_STR_SIZ  63
  #define JK_SHM_DYNAMIC  16
  #define JK_SHM_MAGIC    '!', 'J', 'K', 'S', 'H', 'M', JK_SHM_MAJOR, JK_SHM_MINOR
  
  /** jk shm structure */
  struct jk_shm
  {
      size_t     size;
      const char *filename;
      int        fd;
      void       *base;
      int        attached;
  };
  
  typedef struct jk_shm jk_shm_t;
  
  /** jk shm header record structure */
  struct jk_shm_h_rec
  {
      /* Shared memory magic JK_SHM_MAGIC */
      char    magic[8];
      int     workers;
      int     dynamic;
  
      /* Align to 128 bytes */
  
      /* XXX:  the following should be #if sizeof(int) == 4 */
  #if 1
      char    reserved[112];
  #else
      char    reserved[104];
  #endif
  };
  
  typedef struct jk_shm_h_rec jk_shm_h_rec_t;
  
  /** jk shm worker record structure */
  struct jk_shm_w_rec
  {
      int     id;
      /* Number of currently busy channels */
      int     busy;
      /* Number of currently idle channels */
      int     idle;
      /* Maximum number of channels */
      int     max_conn;
      /* worker name */
      char    route[JK_SHM_STR_SIZ+1];
      /* worker domain */
      char    domain[JK_SHM_STR_SIZ+1];
      /* worker redirect route */
      char    redirect_route[JK_SHM_STR_SIZ+1];
      /* current status of the worker */
      int     status;
      /* Current lb factor */
      int     lb_factor;
      /* Current lb value  */
      int     lb_value;
      int     is_local_worker;
      int     is_local_domain;
      int     in_error_state;
      int     in_recovering;
      int     in_local_worker_mode;
      int     local_worker_only;
      int     sticky_session;
      int     recover_wait_time;
      int     error_time;
      /* Number of bytes read from remote */
      int     readed;
      /* Number of bytes transferred to remote */
      int     transferred;
      /* Number of times the worker was elected */
      int     elected;
      /* Number of non 200 responses */
      int     errors;
      /* Align to 512 bytes */
  
      /* XXX:  the following should be #if sizeof(int) == 4 */
  #if 1
      char    reserved[244];
  #else
      char    reserved[168];
  #endif
  
  };
  
  typedef struct jk_shm_w_rec jk_shm_w_rec_t;
  
  /* Open the shared memory creating file if needed
   */
  jk_shm_t *jk_shm_open(const char *fname, int workers, int dynamic, jk_pool_t *p);
  
  /* Close the shared memory
   */
  void jk_shm_close(jk_shm_t *shm);
  
  /* Attach the shared memory in child process.
   * File has to be opened in parent.
   */
  jk_shm_t *jk_shm_attach(const char *fname, int workers, int dynamic, jk_pool_t *p);
  
  
  /* Return shm header record
   */
  jk_shm_h_rec_t *jk_shm_header(jk_shm_t *shm);
  
  /* Return shm worker record
   */
  jk_shm_w_rec_t *jk_shm_worker(jk_shm_t *shm, int id);
  
  
  #ifdef __cplusplus
  }
  #endif  /* __cplusplus */
  #endif  /* _JK_SHM_H */
  
  
  
  1.11      +8 -0      jakarta-tomcat-connectors/jk/native/iis/isapi.dsp
  
  Index: isapi.dsp
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/iis/isapi.dsp,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- isapi.dsp	23 Dec 2004 13:28:00 -0000	1.10
  +++ isapi.dsp	5 Feb 2005 19:40:19 -0000	1.11
  @@ -156,6 +156,10 @@
   # End Source File
   # Begin Source File
   
  +SOURCE=..\common\jk_shm.c
  +# End Source File
  +# Begin Source File
  +
   SOURCE=..\common\jk_sockbuf.c
   # End Source File
   # Begin Source File
  @@ -252,6 +256,10 @@
   # End Source File
   # Begin Source File
   
  +SOURCE=..\common\jk_shm.h
  +# End Source File
  +# Begin Source File
  +
   SOURCE=..\common\jk_uri_worker_map.h
   # End Source File
   # Begin Source File
  
  
  
  1.10      +8 -0      jakarta-tomcat-connectors/jk/native/netscape/nsapi.dsp
  
  Index: nsapi.dsp
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/netscape/nsapi.dsp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- nsapi.dsp	3 Jan 2005 08:31:37 -0000	1.9
  +++ nsapi.dsp	5 Feb 2005 19:40:19 -0000	1.10
  @@ -154,6 +154,10 @@
   # End Source File
   # Begin Source File
   
  +SOURCE=..\common\jk_shm.c
  +# End Source File
  +# Begin Source File
  +
   SOURCE=..\common\jk_sockbuf.c
   # End Source File
   # Begin Source File
  @@ -242,6 +246,10 @@
   # End Source File
   # Begin Source File
   
  +SOURCE=..\common\jk_shm.h
  +# End Source File
  +# Begin Source File
  +
   SOURCE=..\common\jk_uri_worker_map.h
   # End Source File
   # Begin Source File
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message