dgaudet 98/03/07 20:25:59
Modified: src CHANGES PORTING src/include conf.h src/main http_main.c Log: http_main is way too big. Bleh. Some clean up on scoreboard stuff. Revision Changes Path 1.693 +4 -0 apache-1.3/src/CHANGES Index: CHANGES =================================================================== RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.692 retrieving revision 1.693 diff -u -r1.692 -r1.693 --- CHANGES 1998/03/06 12:52:55 1.692 +++ CHANGES 1998/03/08 04:25:53 1.693 @@ -1,5 +1,9 @@ Changes with Apache 1.3b6 + *) Minor cleanup in http_main -- split QNX and OS2 specific "mmap" + scoreboard code into separate #defines -- USE_POSIX_SCOREBOARD + and USE_OS2_SCOREBOARD. [Dean Gaudet] + *) Fix one more special locking problem for RewriteMap programs in mod_rewrite: According to the documentation of flock(), "Locks are on files, not file descriptors. That is, file descriptors duplicated 1.21 +8 -0 apache-1.3/src/PORTING Index: PORTING =================================================================== RCS file: /export/home/cvs/apache-1.3/src/PORTING,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- PORTING 1998/01/25 02:07:43 1.20 +++ PORTING 1998/03/08 04:25:54 1.21 @@ -223,6 +223,14 @@ is defined, a file-based scoreboard will be used and SCOREBOARD_FILE will automatically be defined >> + USE_POSIX_SCOREBOARD: + Defined on QNX currently where the shared memory scoreboard follows + the POSIX 1003.4 spec. + + USE_OS2_SCOREBOARD: + Defined on OS2, uses OS2 primitives to construct shared memory for + the scoreboard. + USE_LONGJMP: Define to use the longjmp() call instead of siglongjmp() (as well as setjmp() instead of sigsetjmp()). 1.189 +2 -3 apache-1.3/src/include/conf.h Index: conf.h =================================================================== RCS file: /export/home/cvs/apache-1.3/src/include/conf.h,v retrieving revision 1.188 retrieving revision 1.189 diff -u -r1.188 -r1.189 --- conf.h 1998/03/05 18:58:33 1.188 +++ conf.h 1998/03/08 04:25:56 1.189 @@ -585,7 +585,7 @@ #define HAVE_SYS_SELECT_H 1 #include <unix.h> #define HAVE_MMAP 1 -#define USE_MMAP_SCOREBOARD +#define USE_POSIX_SCOREBOARD #define HAVE_SYSLOG 1 #elif defined(LYNXOS) @@ -637,8 +637,7 @@ #define chdir _chdir2 #include <sys/time.h> #define MAXSOCKETS 4096 -#define HAVE_MMAP 1 -#define USE_MMAP_SCOREBOARD +#define USE_OS2_SCOREBOARD #define NO_RELIABLE_PIPED_LOGS #elif defined(__MACHTEN__) 1.300 +111 -92 apache-1.3/src/main/http_main.c Index: http_main.c =================================================================== RCS file: /export/home/cvs/apache-1.3/src/main/http_main.c,v retrieving revision 1.299 retrieving revision 1.300 diff -u -r1.299 -r1.300 --- http_main.c 1998/03/04 02:28:15 1.299 +++ http_main.c 1998/03/08 04:25:57 1.300 @@ -171,9 +171,8 @@ long _stksize = 32768; #endif -#ifdef __EMX__ +#ifdef USE_OS2_SCOREBOARD /* Add MMAP style functionality to OS/2 */ -#ifdef USE_MMAP_SCOREBOARD #define INCL_DOSMEMMGR #include <os2.h> #include <umalloc.h> @@ -181,7 +180,6 @@ caddr_t create_shared_heap(const char *, size_t); caddr_t get_shared_heap(const char *); #endif -#endif DEF_Explain @@ -1320,8 +1318,6 @@ * malloc. But let the routines that follow, think that you have * shared memory (so they use memcpy etc.) */ -#undef USE_MMAP_SCOREBOARD -#define USE_MMAP_SCOREBOARD 1 void reinit_scoreboard(pool *p) { @@ -1343,20 +1339,55 @@ #else /* MULTITHREAD */ -#if defined(USE_MMAP_SCOREBOARD) +#if defined(USE_OS2_SCOREBOARD) -#ifdef QNX -static void cleanup_shared_mem(void *d) +/* The next two routines are used to access shared memory under OS/2. */ +/* This requires EMX v09c to be installed. */ + +caddr_t create_shared_heap(const char *name, size_t size) { - shm_unlink(scoreboard_fname); + ULONG rc; + void *mem; + Heap_t h; + + rc = DosAllocSharedMem(&mem, name, size, + PAG_COMMIT | PAG_READ | PAG_WRITE); + if (rc != 0) + return NULL; + h = _ucreate(mem, size, !_BLOCK_CLEAN, _HEAP_REGULAR | _HEAP_SHARED, + NULL, NULL); + if (h == NULL) + DosFreeMem(mem); + return (caddr_t) h; +} + +caddr_t get_shared_heap(const char *Name) +{ + + PVOID BaseAddress; /* Pointer to the base address of + the shared memory object */ + ULONG AttributeFlags; /* Flags describing characteristics + of the shared memory object */ + APIRET rc; /* Return code */ + + /* Request read and write access to */ + /* the shared memory object */ + AttributeFlags = PAG_WRITE | PAG_READ; + + rc = DosGetNamedSharedMem(&BaseAddress, Name, AttributeFlags); + + if (rc != 0) { + printf("DosGetNamedSharedMem error: return code = %ld", rc); + return 0; + } + + return BaseAddress; } -#endif static void setup_shared_mem(pool *p) { caddr_t m; -#ifdef __EMX__ char errstr[MAX_STRING_LEN]; int rc; @@ -1370,8 +1401,26 @@ if (rc != 0) { fprintf(stderr, "httpd: Could not uopen() newly created OS/2 Shared memory pool.\n"); } + scoreboard_image = (scoreboard *) m; + scoreboard_image->global.exit_generation = 0; +} + +void reopen_scoreboard(pool *p) +{ + caddr_t m; + int rc; + + m = (caddr_t) get_shared_heap("\\SHAREMEM\\SCOREBOARD"); + if (m == 0) { + fprintf(stderr, "httpd: Could not find existing OS/2 Shared memory pool.\n"); + exit(1); + } + + rc = _uopen((Heap_t) m); + scoreboard_image = (scoreboard *) m; +} -#elif defined(QNX) +#elif defined(USE_POSIX_SCOREBOARD) /* * POSIX 1003.4 style * @@ -1400,6 +1449,15 @@ * June 5, 1997, * Igor N. Kovalenko -- [EMAIL PROTECTED] */ + +static void cleanup_shared_mem(void *d) +{ + shm_unlink(scoreboard_fname); +} + +static void setup_shared_mem(pool *p) +{ + caddr_t m; int fd; fd = shm_open(scoreboard_fname, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); @@ -1421,8 +1479,21 @@ } close(fd); register_cleanup(p, NULL, cleanup_shared_mem, null_cleanup); + scoreboard_image = (scoreboard *) m; + scoreboard_image->global.exit_generation = 0; +} -#elif defined(MAP_ANON) || defined(MAP_FILE) +void reopen_scoreboard(pool *p) +{ +} + +#elif defined(USE_MMAP_SCOREBOARD) + +static void setup_shared_mem(pool *p) +{ + caddr_t m; + +#if defined(MAP_ANON) || defined(MAP_FILE) /* BSD style */ #ifdef CONVEXOS11 /* @@ -1473,6 +1544,10 @@ scoreboard_image->global.exit_generation = 0; } +void reopen_scoreboard(pool *p) +{ +} + #elif defined(USE_SHMGET_SCOREBOARD) static key_t shmkey = IPC_PRIVATE; static int shmid = -1; @@ -1560,6 +1635,10 @@ scoreboard_image->global.exit_generation = 0; } +void reopen_scoreboard(pool *p) +{ +} + #else #define SCOREBOARD_FILE static scoreboard _scoreboard_image; @@ -1602,6 +1681,19 @@ { unlink(scoreboard_fname); } + +void reopen_scoreboard(pool *p) +{ + if (scoreboard_fd != -1) + pclosef(p, scoreboard_fd); + + scoreboard_fd = popenf(p, scoreboard_fname, O_CREAT | O_BINARY | O_RDWR, 0666); + if (scoreboard_fd == -1) { + perror(scoreboard_fname); + fprintf(stderr, "Cannot open scoreboard file:\n"); + clean_child_exit(1); + } +} #endif /* Called by parent process */ @@ -1635,38 +1727,6 @@ #endif } -/* called by child */ -void reopen_scoreboard(pool *p) -{ -#ifdef SCOREBOARD_FILE - if (scoreboard_fd != -1) - pclosef(p, scoreboard_fd); - - scoreboard_fd = popenf(p, scoreboard_fname, O_CREAT | O_BINARY | O_RDWR, 0666); - if (scoreboard_fd == -1) { - perror(scoreboard_fname); - fprintf(stderr, "Cannot open scoreboard file:\n"); - clean_child_exit(1); - } -#else -#ifdef __EMX__ -#ifdef USE_MMAP_SCOREBOARD - caddr_t m; - int rc; - - m = (caddr_t) get_shared_heap("\\SHAREMEM\\SCOREBOARD"); - if (m == 0) { - fprintf(stderr, "httpd: Could not find existing OS/2 Shared memory pool.\n"); - exit(1); - } - - rc = _uopen((Heap_t) m); - scoreboard_image = (scoreboard *) m; -#endif -#endif -#endif -} - /* Routines called to deal with the scoreboard image * --- note that we do *not* need write locks, since update_child_status * only updates a *single* record in place, and only one process writes to @@ -2836,6 +2896,12 @@ #ifdef USE_SHMGET_SCOREBOARD printf(" -D USE_SHMGET_SCOREBOARD\n"); #endif +#ifdef USE_OS2_SCOREBOARD + printf(" -D USE_OS2_SCOREBOARD\n"); +#endif +#ifdef USE_POSIX_SCOREBOARD + printf(" -D USE_POSIX_SCOREBOARD\n"); +#endif #ifdef USE_MMAP_FILES printf(" -D USE_MMAP_FILES\n"); #ifdef MMAP_SEGMENT_SIZE @@ -3933,53 +3999,6 @@ } exit(0); } - -#ifdef __EMX__ -#ifdef USE_MMAP_SCOREBOARD -/* The next two routines are used to access shared memory under OS/2. */ -/* This requires EMX v09c to be installed. */ - -caddr_t create_shared_heap(const char *name, size_t size) -{ - ULONG rc; - void *mem; - Heap_t h; - - rc = DosAllocSharedMem(&mem, name, size, - PAG_COMMIT | PAG_READ | PAG_WRITE); - if (rc != 0) - return NULL; - h = _ucreate(mem, size, !_BLOCK_CLEAN, _HEAP_REGULAR | _HEAP_SHARED, - NULL, NULL); - if (h == NULL) - DosFreeMem(mem); - return (caddr_t) h; -} - -caddr_t get_shared_heap(const char *Name) -{ - - PVOID BaseAddress; /* Pointer to the base address of - the shared memory object */ - ULONG AttributeFlags; /* Flags describing characteristics - of the shared memory object */ - APIRET rc; /* Return code */ - - /* Request read and write access to */ - /* the shared memory object */ - AttributeFlags = PAG_WRITE | PAG_READ; - - rc = DosGetNamedSharedMem(&BaseAddress, Name, AttributeFlags); - - if (rc != 0) { - printf("DosGetNamedSharedMem error: return code = %ld", rc); - return 0; - } - - return BaseAddress; -} -#endif -#endif #else /* ndef MULTITHREAD */