cvs commit: apache-2.0/mpm/src/os/beos Makefile.tmpl beosd.c beosd.h iol_socket.c iol_socket.h os-inline.c os.c os.h
dgaudet 99/07/12 15:51:17 Modified:mpm/src CHANGES Configure mpm/src/include ap_config.h httpd.h mpm/src/main util.c Added: mpm/src/os/beos Makefile.tmpl beosd.c beosd.h iol_socket.c iol_socket.h os-inline.c os.c os.h Log: commit David's beos port. Submitted by: David Reid <[EMAIL PROTECTED]> Revision ChangesPath 1.13 +2 -0 apache-2.0/mpm/src/CHANGES Index: CHANGES === RCS file: /home/cvs/apache-2.0/mpm/src/CHANGES,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- CHANGES 1999/07/05 13:00:39 1.12 +++ CHANGES 1999/07/12 22:51:05 1.13 @@ -1,5 +1,7 @@ Changes with MPM +* MPM BEOS port. [David Reid <[EMAIL PROTECTED]>] + * Start to implement module-defined hooks that are a) fast and b) typesafe. Replace pre_connection module call with a register_hook call and implement pre_connection as a hook. The intent is that these hooks will 1.12 +2 -1 apache-2.0/mpm/src/Configure Index: Configure === RCS file: /home/cvs/apache-2.0/mpm/src/Configure,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- Configure 1999/07/11 14:49:03 1.11 +++ Configure 1999/07/12 22:51:06 1.12 @@ -729,7 +729,8 @@ OS='BeOS'; CFLAGS="$CFLAGS -DBEOS" DEF_WANTHSREGEX=yes - ;; + OSDIR='os/beos' + ;; 4850-*.*) OS='NCR MP/RAS' CFLAGS="$CFLAGS -DSVR4 -DMPRAS" 1.3 +3 -0 apache-2.0/mpm/src/include/ap_config.h Index: ap_config.h === RCS file: /home/cvs/apache-2.0/mpm/src/include/ap_config.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ap_config.h 1999/07/12 08:47:47 1.2 +++ ap_config.h 1999/07/12 22:51:08 1.3 @@ -877,6 +877,9 @@ #elif defined(BEOS) #include +#include +#include +#include #define NO_WRITEV #define NO_KILLPG 1.6 +3 -0 apache-2.0/mpm/src/include/httpd.h Index: httpd.h === RCS file: /home/cvs/apache-2.0/mpm/src/include/httpd.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- httpd.h 1999/07/04 09:13:32 1.5 +++ httpd.h 1999/07/12 22:51:09 1.6 @@ -86,6 +86,9 @@ #elif defined(WIN32) /* Set default for Windows file system */ #define HTTPD_ROOT "/apache" +#elif defined (BEOS) +/* Set the default for BeOS */ +#define HTTPD_ROOT "/boot/home/apache" #else #define HTTPD_ROOT "/usr/local/apache" #endif 1.2 +6 -1 apache-2.0/mpm/src/main/util.c Index: util.c === RCS file: /home/cvs/apache-2.0/mpm/src/main/util.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- util.c1999/06/18 18:39:30 1.1 +++ util.c1999/07/12 22:51:10 1.2 @@ -1962,7 +1962,12 @@ struct hostent *p; /* ZZZ change to use AP funcs. */ -if (gethostname(str, sizeof(str) - 1) != 0) { +#ifdef BEOS +if (gethostname(str, sizeof(str) - 1) == 0) +#else +if (gethostname(str, sizeof(str) - 1) != 0) +#endif +{ perror("Unable to gethostname"); exit(1); } 1.1 apache-2.0/mpm/src/os/beos/Makefile.tmpl Index: Makefile.tmpl === CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS) LIBS=$(EXTRA_LIBS) $(LIBS1) INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES) LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS) OBJS= os.o beosd.o iol_socket.o LIB= libos.a all: $(LIB) $(LIB): $(OBJS) rm -f $@ ar cr $@ $(OBJS) $(RANLIB) $@ .c.o: $(CC) -c $(INCLUDES) $(CFLAGS) $< clean: rm -f $(OBJS) $(LIB) distclean: clean -rm -f Makefile # We really don't expect end users to use this rule. It works only with # gcc, and rebuilds Makefile.tmpl. You have to re-run Configure after # using it. depend: cp Makefile.tmpl Makefile.tmpl.bak \ && sed -ne '1,/^# DO NOT REMOVE/p' Makefile.tmpl > Makefile.new \ && gcc -MM $(INCLUDES) $(CFLAGS) *.c >> Makefile.new \ && sed -e '1,$$s: $(INCDIR)/: $$(INCDIR)/:g' \ -e '1,$$s: $(OSDIR)/: $$(OSDIR)/:g' Makefile.new \ > Makefile.tmpl \ && rm Makefile.new $(OBJS): Makefile # DO NOT REMOVE 1.1 apache-2.0/mpm/src/os/beos/beosd.c Index: beosd.c ==
cvs commit: apache-2.0/mpm/src/os/beos - New directory
dgaudet 99/07/12 15:48:54 apache-2.0/mpm/src/os/beos - New directory
cvs commit: apache-apr/include apr_general.h
rbb 99/07/12 11:38:26 Modified:apr configure.in include apr_general.h Log: I'm doing the integer size checks properly now in APR. At least I think I am. :) Revision ChangesPath 1.26 +8 -0 apache-apr/apr/configure.in Index: configure.in === RCS file: /home/cvs/apache-apr/apr/configure.in,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- configure.in 1999/07/01 20:11:06 1.25 +++ configure.in 1999/07/12 18:38:19 1.26 @@ -15,6 +15,14 @@ AC_CHECK_PROG(RM, rm, rm) AC_CHECK_PROG(AR, ar, ar) +dnl Checks for integer size +AC_CHECK_SIZEOF(char, 1) +AC_CHECK_SIZEOF(int, 4) +AC_CHECK_SIZEOF(long, 4) +AC_CHECK_SIZEOF(short, 2) +AC_CHECK_SIZEOF(long double, 12) +AC_CHECK_SIZEOF(long long, 8) + # Use /bin/sh if it exists, otherwise go looking for sh in the path if (test -z "$SH" -a -e /bin/sh); then SH="/bin/sh" 1.21 +20 -6 apache-apr/include/apr_general.h Index: apr_general.h === RCS file: /home/cvs/apache-apr/include/apr_general.h,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- apr_general.h 1999/06/30 19:45:58 1.20 +++ apr_general.h 1999/07/12 18:38:24 1.21 @@ -87,12 +87,26 @@ #define MAXIMUM_WAIT_OBJECTS 64 -typedef short ap_int16_t; -typedef unsigned shortap_uint16_t; -typedef int ap_int32_t; -typedef unsigned int ap_uint32_t; -typedef long ap_int64_t; -typedef unsigned long ap_uint64_t; +#if (SIZEOF_SHORT == 2) +typedef short ap_int16_t; +typedef unsigned short ap_uint16_t; +#endif + +#if (SIZEOF_INT == 4) +typedef intap_int32_t; +typedef unsigned int ap_uint32_t; +#endif + +#if (SIZEOF_LONG == 8) +typedef long ap_int64_t; +typedef unsigned long ap_uint64_t; +#elif (SIZEOF_LONG_LONG == 8) +typedef long long ap_int64_t; +typedef unsigned long long ap_uint64_t; +#elif (SIZEOF_LONG_DOUBLE == 8) +typedef long doubleap_int64_t; +typedef unsigned long double ap_uint64_t; +#endif typedef size_tap_size_t; #ifdef ssize_t
cvs commit: apache-2.0/mpm/src/os/os2 iol_socket.c util_os2.c
bjh 99/07/12 01:47:48 Modified:mpm/src/include ap_config.h mpm/src/os/os2 iol_socket.c util_os2.c Log: OS/2 EMX library's select() isn't thread safe so bypass it and go direct to the OS/2 API call. Unfortunately this only works on socket handles which will break probe_writable_fds() so I'll have to find a way to fix that too. Revision ChangesPath 1.2 +2 -0 apache-2.0/mpm/src/include/ap_config.h Index: ap_config.h === RCS file: /home/cvs/apache-2.0/mpm/src/include/ap_config.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ap_config.h 1999/06/18 18:39:27 1.1 +++ ap_config.h 1999/07/12 08:47:47 1.2 @@ -1163,6 +1163,8 @@ #elif defined(SELECT_NEEDS_CAST) #define ap_select(_a, _b, _c, _d, _e) \ select((_a), (int *)(_b), (int *)(_c), (int *)(_d), (_e)) +#elif defined(OS2) +int ap_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); #else #define ap_select(_a, _b, _c, _d, _e) \ select(_a, _b, _c, _d, _e) 1.2 +1 -1 apache-2.0/mpm/src/os/os2/iol_socket.c Index: iol_socket.c === RCS file: /home/cvs/apache-2.0/mpm/src/os/os2/iol_socket.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- iol_socket.c 1999/07/11 14:49:07 1.1 +++ iol_socket.c 1999/07/12 08:47:47 1.2 @@ -140,7 +140,7 @@ tv.tv_sec = iol->timeout; \ tv.tv_usec = 0; \ do { \ - rv = select(iol->fd + 1, selread, selwrite, NULL, iol->timeout < 0 ? NULL : &tv); \ + rv = ap_select(iol->fd + 1, selread, selwrite, NULL, iol->timeout < 0 ? NULL : &tv); \ } while (rv == -1 && errno == EINTR); \ if (!FD_ISSET(iol->fd, &fdset)) { \ errno = ETIMEDOUT; \ 1.3 +91 -0 apache-2.0/mpm/src/os/os2/util_os2.c Index: util_os2.c === RCS file: /home/cvs/apache-2.0/mpm/src/os/os2/util_os2.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- util_os2.c1999/07/11 14:49:07 1.2 +++ util_os2.c1999/07/12 08:47:48 1.3 @@ -94,3 +94,94 @@ return result; } + + + + +int (*os2_select)( int *, int, int, int, long ) = NULL; +static HMODULE hSO32DLL; + +int ap_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) +{ +int *fds, s, fd_count=0, rc; +int num_read, num_write, num_except; +long ms_timeout = -1; + +if (os2_select == NULL) { +DosEnterCritSec(); /* Stop two threads doing this at the same time */ + +if (os2_select == NULL) { +hSO32DLL = ap_os_dso_load("SO32DLL"); + +if (hSO32DLL) { +os2_select = ap_os_dso_sym(hSO32DLL, "SELECT"); +} +} +DosExitCritSec(); +} + +ap_assert(os2_select != NULL); +fds = alloca(sizeof(int) * nfds); + +if (readfds) { +for (s=0; stv_usec / 1000 + timeout->tv_sec * 1000; + +rc = os2_select(fds, num_read, num_write, num_except, ms_timeout); + +if (rc > 0) { +fd_count = 0; + +if (readfds) { +for (s=0; s
cvs commit: apache-2.0/mpm/src/modules/mpm/spmt_os2 spmt_os2.c
bjh 99/07/12 01:35:39 Modified:mpm/src/modules/mpm/spmt_os2 spmt_os2.c Log: Assorted fixes for the OS/2 mpm: - pchild really should be thread local - clean_child_exit() should call _endthread(), not exit() - Use DosSleep() for delay in wait_or_timeout() instead of ap_select - Rework logic of searching for listen rec in child main, was getting hung in infinite loop when two sockets were being listened to. NOTE: I got it from prefork.c originally so that's probably broken too. - Remove a debugging fprintf I accidentally left in... Revision ChangesPath 1.2 +25 -24apache-2.0/mpm/src/modules/mpm/spmt_os2/spmt_os2.c Index: spmt_os2.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/spmt_os2/spmt_os2.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- spmt_os2.c1999/07/11 14:49:06 1.1 +++ spmt_os2.c1999/07/12 08:35:39 1.2 @@ -151,12 +151,12 @@ #endif static pool *pconf; /* Pool for config stuff */ -static pool *pchild; /* Pool for httpd child stuff */ static int my_pid; /* it seems silly to call getpid all the time */ static scoreboard *ap_scoreboard_image = NULL; static int volatile exit_after_unblock = 0; struct thread_globals { +pool *pchild;/* Pool for httpd child stuff */ int srv; int csd; int requests_this_child; @@ -188,13 +188,12 @@ /* a clean exit from a child with proper cleanup */ -static void clean_child_exit(int code) __attribute__ ((noreturn)); static void clean_child_exit(int code) { -if (pchild) { - ap_destroy_pool(pchild); +if (THREAD_GLOBAL(pchild)) { + ap_destroy_pool(THREAD_GLOBAL(pchild)); } -exit(code); +_endthread(); } @@ -232,7 +231,7 @@ static void accept_mutex_init(pool *p) { int rc = DosCreateMutexSem(NULL, &lock_sem, DC_SEM_SHARED, FALSE); -fprintf(stderr, "Created mutex\n"); + if (rc != 0) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, server_conf, "Parent cannot create lock semaphore, rc=%d", rc); @@ -532,7 +531,6 @@ static int wait_or_timeout(ap_wait_t *status) { -struct timeval tv; int ret; ++wait_or_timeout_counter; @@ -549,9 +547,8 @@ if (ret > 0) { return ret; } -tv.tv_sec = SCOREBOARD_MAINTENANCE_INTERVAL / 100; -tv.tv_usec = SCOREBOARD_MAINTENANCE_INTERVAL % 100; -ap_select(0, NULL, NULL, NULL, &tv); + +DosSleep(SCOREBOARD_MAINTENANCE_INTERVAL / 1000); return -1; } @@ -905,15 +902,15 @@ NET_SIZE_T clen; struct sockaddr sa_server; struct sockaddr sa_client; -ap_listen_rec *lr; -ap_listen_rec *last_lr; +ap_listen_rec *lr = NULL; +ap_listen_rec *first_lr = NULL; pool *ptrans; conn_rec *current_conn; int my_child_num = (int)child_num_arg; ap_iol *iol; +pool *pchild; my_pid = getpid(); -last_lr = NULL; /* Disable the restart signal handlers and enable the just_die stuff. * Note that since restart() just notes that a restart has been @@ -928,6 +925,7 @@ */ pchild = ap_make_sub_pool(pconf); *ppthread_globals = (struct thread_globals *)ap_palloc(pchild, sizeof(struct thread_globals)); +THREAD_GLOBAL(pchild) = pchild; THREAD_GLOBAL(ap_my_generation) = 0; THREAD_GLOBAL(requests_this_child) = 0; THREAD_GLOBAL(csd) = -1; @@ -997,23 +995,27 @@ /* we remember the last_lr we searched last time around so that we don't end up starving any particular listening socket */ - if (last_lr == NULL) { - lr = ap_listeners; + if (first_lr == NULL) { + first_lr = ap_listeners; } - else { - lr = last_lr->next; - } - while (lr != last_lr) { + +lr = first_lr; + + do { if (!lr) { lr = ap_listeners; + } + + if (FD_ISSET(lr->fd, &THREAD_GLOBAL(main_fds))) { +first_lr = lr->next; + break; } - if (FD_ISSET(lr->fd, &THREAD_GLOBAL(main_fds))) break; lr = lr->next; - } - if (lr == last_lr) { + } while (lr != first_lr); + + if (lr == first_lr) { continue; } - last_lr = lr; sd = lr->fd; } else { @@ -1181,7 +1183,6 @@ }