From e8ec7aa8e38a93f5b034ac74cebce5de23710317 Mon Sep 17 00:00:00 2001 From: hongbotian Date: Mon, 30 Nov 2015 01:45:08 -0500 Subject: upload http JIRA: BOTTLENECK-10 Change-Id: I7598427ff904df438ce77c2819ee48ac75ffa8da Signed-off-by: hongbotian --- .../srclib/apr-util/misc/.libs/apr_date.o | Bin 0 -> 18976 bytes .../srclib/apr-util/misc/.libs/apr_queue.o | Bin 0 -> 18544 bytes .../srclib/apr-util/misc/.libs/apr_reslist.o | Bin 0 -> 25200 bytes .../srclib/apr-util/misc/.libs/apr_rmm.o | Bin 0 -> 28768 bytes .../srclib/apr-util/misc/.libs/apu_version.o | Bin 0 -> 4016 bytes .../app/httpd-2.0.64/srclib/apr-util/misc/Makefile | 8 + .../httpd-2.0.64/srclib/apr-util/misc/Makefile.in | 8 + .../httpd-2.0.64/srclib/apr-util/misc/apr_date.c | 616 +++++++++++++++++++++ .../httpd-2.0.64/srclib/apr-util/misc/apr_date.lo | 12 + .../httpd-2.0.64/srclib/apr-util/misc/apr_date.o | Bin 0 -> 18448 bytes .../httpd-2.0.64/srclib/apr-util/misc/apr_queue.c | 392 +++++++++++++ .../httpd-2.0.64/srclib/apr-util/misc/apr_queue.lo | 12 + .../httpd-2.0.64/srclib/apr-util/misc/apr_queue.o | Bin 0 -> 18496 bytes .../srclib/apr-util/misc/apr_reslist.c | 375 +++++++++++++ .../srclib/apr-util/misc/apr_reslist.lo | 12 + .../srclib/apr-util/misc/apr_reslist.o | Bin 0 -> 25056 bytes .../httpd-2.0.64/srclib/apr-util/misc/apr_rmm.c | 428 ++++++++++++++ .../httpd-2.0.64/srclib/apr-util/misc/apr_rmm.lo | 12 + .../httpd-2.0.64/srclib/apr-util/misc/apr_rmm.o | Bin 0 -> 29384 bytes .../srclib/apr-util/misc/apu_version.c | 37 ++ .../srclib/apr-util/misc/apu_version.lo | 12 + .../srclib/apr-util/misc/apu_version.o | Bin 0 -> 3976 bytes 22 files changed, 1924 insertions(+) create mode 100644 rubbos/app/httpd-2.0.64/srclib/apr-util/misc/.libs/apr_date.o create mode 100644 rubbos/app/httpd-2.0.64/srclib/apr-util/misc/.libs/apr_queue.o create mode 100644 rubbos/app/httpd-2.0.64/srclib/apr-util/misc/.libs/apr_reslist.o create mode 100644 rubbos/app/httpd-2.0.64/srclib/apr-util/misc/.libs/apr_rmm.o create mode 100644 rubbos/app/httpd-2.0.64/srclib/apr-util/misc/.libs/apu_version.o create mode 100644 rubbos/app/httpd-2.0.64/srclib/apr-util/misc/Makefile create mode 100644 rubbos/app/httpd-2.0.64/srclib/apr-util/misc/Makefile.in create mode 100644 rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_date.c create mode 100644 rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_date.lo create mode 100644 rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_date.o create mode 100644 rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_queue.c create mode 100644 rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_queue.lo create mode 100644 rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_queue.o create mode 100644 rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_reslist.c create mode 100644 rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_reslist.lo create mode 100644 rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_reslist.o create mode 100644 rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_rmm.c create mode 100644 rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_rmm.lo create mode 100644 rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_rmm.o create mode 100644 rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apu_version.c create mode 100644 rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apu_version.lo create mode 100644 rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apu_version.o (limited to 'rubbos/app/httpd-2.0.64/srclib/apr-util/misc') diff --git a/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/.libs/apr_date.o b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/.libs/apr_date.o new file mode 100644 index 00000000..8d660c0c Binary files /dev/null and b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/.libs/apr_date.o differ diff --git a/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/.libs/apr_queue.o b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/.libs/apr_queue.o new file mode 100644 index 00000000..dddfa1f3 Binary files /dev/null and b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/.libs/apr_queue.o differ diff --git a/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/.libs/apr_reslist.o b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/.libs/apr_reslist.o new file mode 100644 index 00000000..cb01aecd Binary files /dev/null and b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/.libs/apr_reslist.o differ diff --git a/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/.libs/apr_rmm.o b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/.libs/apr_rmm.o new file mode 100644 index 00000000..a54d3310 Binary files /dev/null and b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/.libs/apr_rmm.o differ diff --git a/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/.libs/apu_version.o b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/.libs/apu_version.o new file mode 100644 index 00000000..936c54e4 Binary files /dev/null and b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/.libs/apu_version.o differ diff --git a/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/Makefile b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/Makefile new file mode 100644 index 00000000..4ad97fc1 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/Makefile @@ -0,0 +1,8 @@ + + +INCLUDES = -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/include -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/include/private -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/include -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/lib + +TARGETS = apr_date.lo apr_rmm.lo apr_reslist.lo apr_queue.lo apu_version.lo + +# bring in rules.mk for standard functionality +include /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/build/rules.mk diff --git a/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/Makefile.in b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/Makefile.in new file mode 100644 index 00000000..993648ef --- /dev/null +++ b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/Makefile.in @@ -0,0 +1,8 @@ +VPATH = @srcdir@ + +INCLUDES = @APRUTIL_PRIV_INCLUDES@ @APR_INCLUDES@ @APRUTIL_INCLUDES@ + +TARGETS = apr_date.lo apr_rmm.lo apr_reslist.lo apr_queue.lo apu_version.lo + +# bring in rules.mk for standard functionality +@INCLUDE_RULES@ diff --git a/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_date.c b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_date.c new file mode 100644 index 00000000..f584e093 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_date.c @@ -0,0 +1,616 @@ +/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * 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. + */ + +/* + * apr_date.c: date parsing utility routines + * These routines are (hopefully) platform independent. + * + * 27 Oct 1996 Roy Fielding + * Extracted (with many modifications) from mod_proxy.c and + * tested with over 50,000 randomly chosen valid date strings + * and several hundred variations of invalid date strings. + * + */ + +#include "apr.h" +#include "apr_lib.h" + +#define APR_WANT_STRFUNC +#include "apr_want.h" + +#if APR_HAVE_STDLIB_H +#include +#endif + +#if APR_HAVE_CTYPE_H +#include +#endif + +#include "apr_date.h" + +/* + * Compare a string to a mask + * Mask characters (arbitrary maximum is 256 characters, just in case): + * @ - uppercase letter + * $ - lowercase letter + * & - hex digit + * # - digit + * ~ - digit or space + * * - swallow remaining characters + * - exact match for any other character + */ +APU_DECLARE(int) apr_date_checkmask(const char *data, const char *mask) +{ + int i; + char d; + + for (i = 0; i < 256; i++) { + d = data[i]; + switch (mask[i]) { + case '\0': + return (d == '\0'); + + case '*': + return 1; + + case '@': + if (!apr_isupper(d)) + return 0; + break; + case '$': + if (!apr_islower(d)) + return 0; + break; + case '#': + if (!apr_isdigit(d)) + return 0; + break; + case '&': + if (!apr_isxdigit(d)) + return 0; + break; + case '~': + if ((d != ' ') && !apr_isdigit(d)) + return 0; + break; + default: + if (mask[i] != d) + return 0; + break; + } + } + return 0; /* We only get here if mask is corrupted (exceeds 256) */ +} + +/* + * Parses an HTTP date in one of three standard forms: + * + * Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 + * Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036 + * Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format + * + * and returns the apr_time_t number of microseconds since 1 Jan 1970 GMT, + * or APR_DATE_BAD if this would be out of range or if the date is invalid. + * + * The restricted HTTP syntax is + * + * HTTP-date = rfc1123-date | rfc850-date | asctime-date + * + * rfc1123-date = wkday "," SP date1 SP time SP "GMT" + * rfc850-date = weekday "," SP date2 SP time SP "GMT" + * asctime-date = wkday SP date3 SP time SP 4DIGIT + * + * date1 = 2DIGIT SP month SP 4DIGIT + * ; day month year (e.g., 02 Jun 1982) + * date2 = 2DIGIT "-" month "-" 2DIGIT + * ; day-month-year (e.g., 02-Jun-82) + * date3 = month SP ( 2DIGIT | ( SP 1DIGIT )) + * ; month day (e.g., Jun 2) + * + * time = 2DIGIT ":" 2DIGIT ":" 2DIGIT + * ; 00:00:00 - 23:59:59 + * + * wkday = "Mon" | "Tue" | "Wed" + * | "Thu" | "Fri" | "Sat" | "Sun" + * + * weekday = "Monday" | "Tuesday" | "Wednesday" + * | "Thursday" | "Friday" | "Saturday" | "Sunday" + * + * month = "Jan" | "Feb" | "Mar" | "Apr" + * | "May" | "Jun" | "Jul" | "Aug" + * | "Sep" | "Oct" | "Nov" | "Dec" + * + * However, for the sake of robustness (and Netscapeness), we ignore the + * weekday and anything after the time field (including the timezone). + * + * This routine is intended to be very fast; 10x faster than using sscanf. + * + * Originally from Andrew Daviel , 29 Jul 96 + * but many changes since then. + * + */ +APU_DECLARE(apr_time_t) apr_date_parse_http(const char *date) +{ + apr_time_exp_t ds; + apr_time_t result; + int mint, mon; + const char *monstr, *timstr; + static const int months[12] = + { + ('J' << 16) | ('a' << 8) | 'n', ('F' << 16) | ('e' << 8) | 'b', + ('M' << 16) | ('a' << 8) | 'r', ('A' << 16) | ('p' << 8) | 'r', + ('M' << 16) | ('a' << 8) | 'y', ('J' << 16) | ('u' << 8) | 'n', + ('J' << 16) | ('u' << 8) | 'l', ('A' << 16) | ('u' << 8) | 'g', + ('S' << 16) | ('e' << 8) | 'p', ('O' << 16) | ('c' << 8) | 't', + ('N' << 16) | ('o' << 8) | 'v', ('D' << 16) | ('e' << 8) | 'c'}; + + if (!date) + return APR_DATE_BAD; + + while (*date && apr_isspace(*date)) /* Find first non-whitespace char */ + ++date; + + if (*date == '\0') + return APR_DATE_BAD; + + if ((date = strchr(date, ' ')) == NULL) /* Find space after weekday */ + return APR_DATE_BAD; + + ++date; /* Now pointing to first char after space, which should be */ + + /* start of the actual date information for all 4 formats. */ + + if (apr_date_checkmask(date, "## @$$ #### ##:##:## *")) { + /* RFC 1123 format with two days */ + ds.tm_year = ((date[7] - '0') * 10 + (date[8] - '0') - 19) * 100; + if (ds.tm_year < 0) + return APR_DATE_BAD; + + ds.tm_year += ((date[9] - '0') * 10) + (date[10] - '0'); + + ds.tm_mday = ((date[0] - '0') * 10) + (date[1] - '0'); + + monstr = date + 3; + timstr = date + 12; + } + else if (apr_date_checkmask(date, "##-@$$-## ##:##:## *")) { + /* RFC 850 format */ + ds.tm_year = ((date[7] - '0') * 10) + (date[8] - '0'); + if (ds.tm_year < 70) + ds.tm_year += 100; + + ds.tm_mday = ((date[0] - '0') * 10) + (date[1] - '0'); + + monstr = date + 3; + timstr = date + 10; + } + else if (apr_date_checkmask(date, "@$$ ~# ##:##:## ####*")) { + /* asctime format */ + ds.tm_year = ((date[16] - '0') * 10 + (date[17] - '0') - 19) * 100; + if (ds.tm_year < 0) + return APR_DATE_BAD; + + ds.tm_year += ((date[18] - '0') * 10) + (date[19] - '0'); + + if (date[4] == ' ') + ds.tm_mday = 0; + else + ds.tm_mday = (date[4] - '0') * 10; + + ds.tm_mday += (date[5] - '0'); + + monstr = date; + timstr = date + 7; + } + else if (apr_date_checkmask(date, "# @$$ #### ##:##:## *")) { + /* RFC 1123 format with one day */ + ds.tm_year = ((date[6] - '0') * 10 + (date[7] - '0') - 19) * 100; + if (ds.tm_year < 0) + return APR_DATE_BAD; + + ds.tm_year += ((date[8] - '0') * 10) + (date[9] - '0'); + + ds.tm_mday = (date[0] - '0'); + + monstr = date + 2; + timstr = date + 11; + } + else + return APR_DATE_BAD; + + if (ds.tm_mday <= 0 || ds.tm_mday > 31) + return APR_DATE_BAD; + + ds.tm_hour = ((timstr[0] - '0') * 10) + (timstr[1] - '0'); + ds.tm_min = ((timstr[3] - '0') * 10) + (timstr[4] - '0'); + ds.tm_sec = ((timstr[6] - '0') * 10) + (timstr[7] - '0'); + + if ((ds.tm_hour > 23) || (ds.tm_min > 59) || (ds.tm_sec > 61)) + return APR_DATE_BAD; + + mint = (monstr[0] << 16) | (monstr[1] << 8) | monstr[2]; + for (mon = 0; mon < 12; mon++) + if (mint == months[mon]) + break; + + if (mon == 12) + return APR_DATE_BAD; + + if ((ds.tm_mday == 31) && (mon == 3 || mon == 5 || mon == 8 || mon == 10)) + return APR_DATE_BAD; + + /* February gets special check for leapyear */ + if ((mon == 1) && + ((ds.tm_mday > 29) || + ((ds.tm_mday == 29) + && ((ds.tm_year & 3) + || (((ds.tm_year % 100) == 0) + && (((ds.tm_year % 400) != 100))))))) + return APR_DATE_BAD; + + ds.tm_mon = mon; + + /* ap_mplode_time uses tm_usec and tm_gmtoff fields, but they haven't + * been set yet. + * It should be safe to just zero out these values. + * tm_usec is the number of microseconds into the second. HTTP only + * cares about second granularity. + * tm_gmtoff is the number of seconds off of GMT the time is. By + * definition all times going through this function are in GMT, so this + * is zero. + */ + ds.tm_usec = 0; + ds.tm_gmtoff = 0; + if (apr_time_exp_get(&result, &ds) != APR_SUCCESS) + return APR_DATE_BAD; + + return result; +} + +/* + * Parses a string resembling an RFC 822 date. This is meant to be + * leinent in its parsing of dates. Hence, this will parse a wider + * range of dates than apr_date_parse_http. + * + * The prominent mailer (or poster, if mailer is unknown) that has + * been seen in the wild is included for the unknown formats. + * + * Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 + * Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036 + * Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format + * Sun, 6 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 + * Sun, 06 Nov 94 08:49:37 GMT ; RFC 822 + * Sun, 6 Nov 94 08:49:37 GMT ; RFC 822 + * Sun, 06 Nov 94 08:49 GMT ; Unknown [drtr@ast.cam.ac.uk] + * Sun, 6 Nov 94 08:49 GMT ; Unknown [drtr@ast.cam.ac.uk] + * Sun, 06 Nov 94 8:49:37 GMT ; Unknown [Elm 70.85] + * Sun, 6 Nov 94 8:49:37 GMT ; Unknown [Elm 70.85] + * Mon, 7 Jan 2002 07:21:22 GMT ; Unknown [Postfix] + * Sun, 06-Nov-1994 08:49:37 GMT ; RFC 850 with four digit years + * + */ + +#define TIMEPARSE(ds,hr10,hr1,min10,min1,sec10,sec1) \ + { \ + ds.tm_hour = ((hr10 - '0') * 10) + (hr1 - '0'); \ + ds.tm_min = ((min10 - '0') * 10) + (min1 - '0'); \ + ds.tm_sec = ((sec10 - '0') * 10) + (sec1 - '0'); \ + } +#define TIMEPARSE_STD(ds,timstr) \ + { \ + TIMEPARSE(ds, timstr[0],timstr[1], \ + timstr[3],timstr[4], \ + timstr[6],timstr[7]); \ + } + +APU_DECLARE(apr_time_t) apr_date_parse_rfc(const char *date) +{ + apr_time_exp_t ds; + apr_time_t result; + int mint, mon; + const char *monstr, *timstr, *gmtstr; + static const int months[12] = + { + ('J' << 16) | ('a' << 8) | 'n', ('F' << 16) | ('e' << 8) | 'b', + ('M' << 16) | ('a' << 8) | 'r', ('A' << 16) | ('p' << 8) | 'r', + ('M' << 16) | ('a' << 8) | 'y', ('J' << 16) | ('u' << 8) | 'n', + ('J' << 16) | ('u' << 8) | 'l', ('A' << 16) | ('u' << 8) | 'g', + ('S' << 16) | ('e' << 8) | 'p', ('O' << 16) | ('c' << 8) | 't', + ('N' << 16) | ('o' << 8) | 'v', ('D' << 16) | ('e' << 8) | 'c' }; + + if (!date) + return APR_DATE_BAD; + + /* Not all dates have text months at the beginning. */ + if (!apr_isdigit(date[0])) + { + while (*date && apr_isspace(*date)) /* Find first non-whitespace char */ + ++date; + + if (*date == '\0') + return APR_DATE_BAD; + + if ((date = strchr(date, ' ')) == NULL) /* Find space after weekday */ + return APR_DATE_BAD; + + ++date; /* Now pointing to first char after space, which should be */ } + + /* start of the actual date information for all 11 formats. */ + if (apr_date_checkmask(date, "## @$$ #### ##:##:## *")) { /* RFC 1123 format */ + ds.tm_year = ((date[7] - '0') * 10 + (date[8] - '0') - 19) * 100; + + if (ds.tm_year < 0) + return APR_DATE_BAD; + + ds.tm_year += ((date[9] - '0') * 10) + (date[10] - '0'); + + ds.tm_mday = ((date[0] - '0') * 10) + (date[1] - '0'); + + monstr = date + 3; + timstr = date + 12; + gmtstr = date + 20; + + TIMEPARSE_STD(ds, timstr); + } + else if (apr_date_checkmask(date, "##-@$$-## ##:##:## *")) {/* RFC 850 format */ + ds.tm_year = ((date[7] - '0') * 10) + (date[8] - '0'); + + if (ds.tm_year < 70) + ds.tm_year += 100; + + ds.tm_mday = ((date[0] - '0') * 10) + (date[1] - '0'); + + monstr = date + 3; + timstr = date + 10; + gmtstr = date + 19; + + TIMEPARSE_STD(ds, timstr); + } + else if (apr_date_checkmask(date, "@$$ ~# ##:##:## ####*")) { + /* asctime format */ + ds.tm_year = ((date[16] - '0') * 10 + (date[17] - '0') - 19) * 100; + if (ds.tm_year < 0) + return APR_DATE_BAD; + + ds.tm_year += ((date[18] - '0') * 10) + (date[19] - '0'); + + if (date[4] == ' ') + ds.tm_mday = 0; + else + ds.tm_mday = (date[4] - '0') * 10; + + ds.tm_mday += (date[5] - '0'); + + monstr = date; + timstr = date + 7; + gmtstr = NULL; + + TIMEPARSE_STD(ds, timstr); + } + else if (apr_date_checkmask(date, "# @$$ #### ##:##:## *")) { + /* RFC 1123 format*/ + ds.tm_year = ((date[6] - '0') * 10 + (date[7] - '0') - 19) * 100; + + if (ds.tm_year < 0) + return APR_DATE_BAD; + + ds.tm_year += ((date[8] - '0') * 10) + (date[9] - '0'); + ds.tm_mday = (date[0] - '0'); + + monstr = date + 2; + timstr = date + 11; + gmtstr = date + 20; + + TIMEPARSE_STD(ds, timstr); + } + else if (apr_date_checkmask(date, "## @$$ ## ##:##:## *")) { + /* This is the old RFC 1123 date format - many many years ago, people + * used two-digit years. Oh, how foolish. */ + ds.tm_year = ((date[7] - '0') * 10) + (date[8] - '0'); + + if (ds.tm_year < 70) + ds.tm_year += 100; + + ds.tm_mday = ((date[0] - '0') * 10) + (date[1] - '0'); + + monstr = date + 3; + timstr = date + 10; + gmtstr = date + 19; + + TIMEPARSE_STD(ds, timstr); + } + else if (apr_date_checkmask(date, "# @$$ ## ##:##:## *")) { + /* This is the old RFC 1123 date format - many many years ago, people + * used two-digit years. Oh, how foolish. */ + ds.tm_year = ((date[6] - '0') * 10) + (date[7] - '0'); + + if (ds.tm_year < 70) + ds.tm_year += 100; + + ds.tm_mday = (date[0] - '0'); + + monstr = date + 2; + timstr = date + 9; + gmtstr = date + 18; + + TIMEPARSE_STD(ds, timstr); + } + else if (apr_date_checkmask(date, "## @$$ ## ##:## *")) { + /* Loser format. This is quite bogus. */ + ds.tm_year = ((date[7] - '0') * 10) + (date[8] - '0'); + + if (ds.tm_year < 70) + ds.tm_year += 100; + + ds.tm_mday = ((date[0] - '0') * 10) + (date[1] - '0'); + + monstr = date + 3; + timstr = date + 10; + gmtstr = NULL; + + TIMEPARSE(ds, timstr[0],timstr[1], timstr[3],timstr[4], '0','0'); + } + else if (apr_date_checkmask(date, "# @$$ ## ##:## *")) { + /* Loser format. This is quite bogus. */ + ds.tm_year = ((date[6] - '0') * 10) + (date[7] - '0'); + + if (ds.tm_year < 70) + ds.tm_year += 100; + + ds.tm_mday = (date[0] - '0'); + + monstr = date + 2; + timstr = date + 9; + gmtstr = NULL; + + TIMEPARSE(ds, timstr[0],timstr[1], timstr[3],timstr[4], '0','0'); + } + else if (apr_date_checkmask(date, "## @$$ ## #:##:## *")) { + /* Loser format. This is quite bogus. */ + ds.tm_year = ((date[7] - '0') * 10) + (date[8] - '0'); + + if (ds.tm_year < 70) + ds.tm_year += 100; + + ds.tm_mday = ((date[0] - '0') * 10) + (date[1] - '0'); + + monstr = date + 3; + timstr = date + 9; + gmtstr = date + 18; + + TIMEPARSE(ds, '0',timstr[1], timstr[3],timstr[4], timstr[6],timstr[7]); + } + else if (apr_date_checkmask(date, "# @$$ ## #:##:## *")) { + /* Loser format. This is quite bogus. */ + ds.tm_year = ((date[6] - '0') * 10) + (date[7] - '0'); + + if (ds.tm_year < 70) + ds.tm_year += 100; + + ds.tm_mday = (date[0] - '0'); + + monstr = date + 2; + timstr = date + 8; + gmtstr = date + 17; + + TIMEPARSE(ds, '0',timstr[1], timstr[3],timstr[4], timstr[6],timstr[7]); + } + else if (apr_date_checkmask(date, " # @$$ #### ##:##:## *")) { + /* RFC 1123 format with a space instead of a leading zero. */ + ds.tm_year = ((date[7] - '0') * 10 + (date[8] - '0') - 19) * 100; + + if (ds.tm_year < 0) + return APR_DATE_BAD; + + ds.tm_year += ((date[9] - '0') * 10) + (date[10] - '0'); + + ds.tm_mday = (date[1] - '0'); + + monstr = date + 3; + timstr = date + 12; + gmtstr = date + 20; + + TIMEPARSE_STD(ds, timstr); + } + else if (apr_date_checkmask(date, "##-@$$-#### ##:##:## *")) { + /* RFC 1123 with dashes instead of spaces between date/month/year + * This also looks like RFC 850 with four digit years. + */ + ds.tm_year = ((date[7] - '0') * 10 + (date[8] - '0') - 19) * 100; + if (ds.tm_year < 0) + return APR_DATE_BAD; + + ds.tm_year += ((date[9] - '0') * 10) + (date[10] - '0'); + + ds.tm_mday = ((date[0] - '0') * 10) + (date[1] - '0'); + + monstr = date + 3; + timstr = date + 12; + gmtstr = date + 21; + + TIMEPARSE_STD(ds, timstr); + } + else + return APR_DATE_BAD; + + if (ds.tm_mday <= 0 || ds.tm_mday > 31) + return APR_DATE_BAD; + + if ((ds.tm_hour > 23) || (ds.tm_min > 59) || (ds.tm_sec > 61)) + return APR_DATE_BAD; + + mint = (monstr[0] << 16) | (monstr[1] << 8) | monstr[2]; + for (mon = 0; mon < 12; mon++) + if (mint == months[mon]) + break; + + if (mon == 12) + return APR_DATE_BAD; + + if ((ds.tm_mday == 31) && (mon == 3 || mon == 5 || mon == 8 || mon == 10)) + return APR_DATE_BAD; + + /* February gets special check for leapyear */ + + if ((mon == 1) && + ((ds.tm_mday > 29) + || ((ds.tm_mday == 29) + && ((ds.tm_year & 3) + || (((ds.tm_year % 100) == 0) + && (((ds.tm_year % 400) != 100))))))) + return APR_DATE_BAD; + + ds.tm_mon = mon; + + /* tm_gmtoff is the number of seconds off of GMT the time is. + * + * We only currently support: [+-]ZZZZ where Z is the offset in + * hours from GMT. + * + * If there is any confusion, tm_gmtoff will remain 0. + */ + ds.tm_gmtoff = 0; + if (gmtstr && *gmtstr != '\0') { + /* Do we have a GMT? */ + if (*(++gmtstr) != '\0') { + int offset; + switch (*(gmtstr++)) { + case '-': + offset = atoi(gmtstr); + ds.tm_gmtoff -= (offset / 100) * 60 * 60; + ds.tm_gmtoff -= (offset % 100) * 60; + break; + case '+': + offset = atoi(gmtstr); + ds.tm_gmtoff += (offset / 100) * 60 * 60; + ds.tm_gmtoff += (offset % 100) * 60; + break; + } + } + } + + /* apr_time_exp_get uses tm_usec field, but it hasn't been set yet. + * It should be safe to just zero out this value. + * tm_usec is the number of microseconds into the second. HTTP only + * cares about second granularity. + */ + ds.tm_usec = 0; + + if (apr_time_exp_gmt_get(&result, &ds) != APR_SUCCESS) + return APR_DATE_BAD; + + return result; +} diff --git a/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_date.lo b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_date.lo new file mode 100644 index 00000000..83a18a4c --- /dev/null +++ b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_date.lo @@ -0,0 +1,12 @@ +# apr_date.lo - a libtool object file +# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.493 2008/02/01 16:58:18) +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/apr_date.o' + +# Name of the non-PIC object. +non_pic_object='apr_date.o' + diff --git a/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_date.o b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_date.o new file mode 100644 index 00000000..08839f99 Binary files /dev/null and b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_date.o differ diff --git a/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_queue.c b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_queue.c new file mode 100644 index 00000000..0d75f001 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_queue.c @@ -0,0 +1,392 @@ +/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * 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. + */ + +#include "apr.h" + +#if APR_HAVE_STDIO_H +#include +#endif +#if APR_HAVE_STDLIB_H +#include +#endif +#if APR_HAVE_UNISTD_H +#include +#endif + +#include "apu.h" +#include "apr_portable.h" +#include "apr_thread_mutex.h" +#include "apr_thread_cond.h" +#include "apr_errno.h" +#include "apr_queue.h" + +#if APR_HAS_THREADS +/* + * define this to get debug messages + * +#define QUEUE_DEBUG + */ + +struct apr_queue_t { + void **data; + unsigned int nelts; /**< # elements */ + unsigned int in; /**< next empty location */ + unsigned int out; /**< next filled location */ + unsigned int bounds;/**< max size of queue */ + unsigned int full_waiters; + unsigned int empty_waiters; + apr_thread_mutex_t *one_big_mutex; + apr_thread_cond_t *not_empty; + apr_thread_cond_t *not_full; + int terminated; +}; + +#ifdef QUEUE_DEBUG +static void Q_DBG(char*msg, apr_queue_t *q) { + fprintf(stderr, "%ld\t#%d in %d out %d\t%s\n", + apr_os_thread_current(), + q->nelts, q->in, q->out, + msg + ); +} +#else +#define Q_DBG(x,y) +#endif + +/** + * Detects when the apr_queue_t is full. This utility function is expected + * to be called from within critical sections, and is not threadsafe. + */ +#define apr_queue_full(queue) ((queue)->nelts == (queue)->bounds) + +/** + * Detects when the apr_queue_t is empty. This utility function is expected + * to be called from within critical sections, and is not threadsafe. + */ +#define apr_queue_empty(queue) ((queue)->nelts == 0) + +/** + * Callback routine that is called to destroy this + * apr_queue_t when its pool is destroyed. + */ +static apr_status_t queue_destroy(void *data) +{ + apr_queue_t *queue = data; + + /* Ignore errors here, we can't do anything about them anyway. */ + + apr_thread_cond_destroy(queue->not_empty); + apr_thread_cond_destroy(queue->not_full); + apr_thread_mutex_destroy(queue->one_big_mutex); + + return APR_SUCCESS; +} + +/** + * Initialize the apr_queue_t. + */ +APU_DECLARE(apr_status_t) apr_queue_create(apr_queue_t **q, + unsigned int queue_capacity, + apr_pool_t *a) +{ + apr_status_t rv; + apr_queue_t *queue; + queue = apr_palloc(a, sizeof(apr_queue_t)); + *q = queue; + + /* nested doesn't work ;( */ + rv = apr_thread_mutex_create(&queue->one_big_mutex, + APR_THREAD_MUTEX_UNNESTED, + a); + if (rv != APR_SUCCESS) { + return rv; + } + + rv = apr_thread_cond_create(&queue->not_empty, a); + if (rv != APR_SUCCESS) { + return rv; + } + + rv = apr_thread_cond_create(&queue->not_full, a); + if (rv != APR_SUCCESS) { + return rv; + } + + /* Set all the data in the queue to NULL */ + queue->data = apr_pcalloc(a, queue_capacity * sizeof(void*)); + queue->bounds = queue_capacity; + queue->nelts = 0; + queue->in = 0; + queue->out = 0; + queue->terminated = 0; + queue->full_waiters = 0; + queue->empty_waiters = 0; + + apr_pool_cleanup_register(a, queue, queue_destroy, apr_pool_cleanup_null); + + return APR_SUCCESS; +} + +/** + * Push new data onto the queue. Blocks if the queue is full. Once + * the push operation has completed, it signals other threads waiting + * in apr_queue_pop() that they may continue consuming sockets. + */ +APU_DECLARE(apr_status_t) apr_queue_push(apr_queue_t *queue, void *data) +{ + apr_status_t rv; + + if (queue->terminated) { + return APR_EOF; /* no more elements ever again */ + } + + rv = apr_thread_mutex_lock(queue->one_big_mutex); + if (rv != APR_SUCCESS) { + return rv; + } + + if (apr_queue_full(queue)) { + if (!queue->terminated) { + queue->full_waiters++; + rv = apr_thread_cond_wait(queue->not_full, queue->one_big_mutex); + queue->full_waiters--; + if (rv != APR_SUCCESS) { + apr_thread_mutex_unlock(queue->one_big_mutex); + return rv; + } + } + /* If we wake up and it's still empty, then we were interrupted */ + if (apr_queue_full(queue)) { + Q_DBG("queue full (intr)", queue); + rv = apr_thread_mutex_unlock(queue->one_big_mutex); + if (rv != APR_SUCCESS) { + return rv; + } + if (queue->terminated) { + return APR_EOF; /* no more elements ever again */ + } + else { + return APR_EINTR; + } + } + } + + queue->data[queue->in] = data; + queue->in = (queue->in + 1) % queue->bounds; + queue->nelts++; + + if (queue->empty_waiters) { + Q_DBG("sig !empty", queue); + rv = apr_thread_cond_signal(queue->not_empty); + if (rv != APR_SUCCESS) { + apr_thread_mutex_unlock(queue->one_big_mutex); + return rv; + } + } + + rv = apr_thread_mutex_unlock(queue->one_big_mutex); + return rv; +} + +/** + * Push new data onto the queue. Blocks if the queue is full. Once + * the push operation has completed, it signals other threads waiting + * in apr_queue_pop() that they may continue consuming sockets. + */ +APU_DECLARE(apr_status_t) apr_queue_trypush(apr_queue_t *queue, void *data) +{ + apr_status_t rv; + + if (queue->terminated) { + return APR_EOF; /* no more elements ever again */ + } + + rv = apr_thread_mutex_lock(queue->one_big_mutex); + if (rv != APR_SUCCESS) { + return rv; + } + + if (apr_queue_full(queue)) { + rv = apr_thread_mutex_unlock(queue->one_big_mutex); + return APR_EAGAIN; + } + + queue->data[queue->in] = data; + queue->in = (queue->in + 1) % queue->bounds; + queue->nelts++; + + if (queue->empty_waiters) { + Q_DBG("sig !empty", queue); + rv = apr_thread_cond_signal(queue->not_empty); + if (rv != APR_SUCCESS) { + apr_thread_mutex_unlock(queue->one_big_mutex); + return rv; + } + } + + rv = apr_thread_mutex_unlock(queue->one_big_mutex); + return rv; +} + +/** + * not thread safe + */ +APU_DECLARE(unsigned int) apr_queue_size(apr_queue_t *queue) { + return queue->nelts; +} + +/** + * Retrieves the next item from the queue. If there are no + * items available, it will block until one becomes available. + * Once retrieved, the item is placed into the address specified by + * 'data'. + */ +APU_DECLARE(apr_status_t) apr_queue_pop(apr_queue_t *queue, void **data) +{ + apr_status_t rv; + + if (queue->terminated) { + return APR_EOF; /* no more elements ever again */ + } + + rv = apr_thread_mutex_lock(queue->one_big_mutex); + if (rv != APR_SUCCESS) { + return rv; + } + + /* Keep waiting until we wake up and find that the queue is not empty. */ + if (apr_queue_empty(queue)) { + if (!queue->terminated) { + queue->empty_waiters++; + rv = apr_thread_cond_wait(queue->not_empty, queue->one_big_mutex); + queue->empty_waiters--; + if (rv != APR_SUCCESS) { + apr_thread_mutex_unlock(queue->one_big_mutex); + return rv; + } + } + /* If we wake up and it's still empty, then we were interrupted */ + if (apr_queue_empty(queue)) { + Q_DBG("queue empty (intr)", queue); + rv = apr_thread_mutex_unlock(queue->one_big_mutex); + if (rv != APR_SUCCESS) { + return rv; + } + if (queue->terminated) { + return APR_EOF; /* no more elements ever again */ + } + else { + return APR_EINTR; + } + } + } + + *data = queue->data[queue->out]; + queue->nelts--; + + queue->out = (queue->out + 1) % queue->bounds; + if (queue->full_waiters) { + Q_DBG("signal !full", queue); + rv = apr_thread_cond_signal(queue->not_full); + if (rv != APR_SUCCESS) { + apr_thread_mutex_unlock(queue->one_big_mutex); + return rv; + } + } + + rv = apr_thread_mutex_unlock(queue->one_big_mutex); + return rv; +} + +/** + * Retrieves the next item from the queue. If there are no + * items available, it will block until one becomes available. + * Once retrieved, the item is placed into the address specified by + * 'data'. + */ +APU_DECLARE(apr_status_t) apr_queue_trypop(apr_queue_t *queue, void **data) +{ + apr_status_t rv; + + if (queue->terminated) { + return APR_EOF; /* no more elements ever again */ + } + + rv = apr_thread_mutex_lock(queue->one_big_mutex); + if (rv != APR_SUCCESS) { + return rv; + } + + /* Keep waiting until we wake up and find that the queue is not empty. */ + if (apr_queue_empty(queue)) { + rv = apr_thread_mutex_unlock(queue->one_big_mutex); + return APR_EAGAIN; + } + + *data = queue->data[queue->out]; + queue->nelts--; + + queue->out = (queue->out + 1) % queue->bounds; + if (queue->full_waiters) { + Q_DBG("signal !full", queue); + rv = apr_thread_cond_signal(queue->not_full); + if (rv != APR_SUCCESS) { + apr_thread_mutex_unlock(queue->one_big_mutex); + return rv; + } + } + + rv = apr_thread_mutex_unlock(queue->one_big_mutex); + return rv; +} + +APU_DECLARE(apr_status_t) apr_queue_interrupt_all(apr_queue_t *queue) +{ + apr_status_t rv; + Q_DBG("intr all", queue); + if ((rv = apr_thread_mutex_lock(queue->one_big_mutex)) != APR_SUCCESS) { + return rv; + } + apr_thread_cond_broadcast(queue->not_empty); + apr_thread_cond_broadcast(queue->not_full); + + if ((rv = apr_thread_mutex_unlock(queue->one_big_mutex)) != APR_SUCCESS) { + return rv; + } + + return APR_SUCCESS; +} + +APU_DECLARE(apr_status_t) apr_queue_term(apr_queue_t *queue) +{ + apr_status_t rv; + + if ((rv = apr_thread_mutex_lock(queue->one_big_mutex)) != APR_SUCCESS) { + return rv; + } + + /* we must hold one_big_mutex when setting this... otherwise, + * we could end up setting it and waking everybody up just after a + * would-be popper checks it but right before they block + */ + queue->terminated = 1; + if ((rv = apr_thread_mutex_unlock(queue->one_big_mutex)) != APR_SUCCESS) { + return rv; + } + return apr_queue_interrupt_all(queue); +} + +#endif /* APR_HAS_THREADS */ diff --git a/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_queue.lo b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_queue.lo new file mode 100644 index 00000000..c23cf9f8 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_queue.lo @@ -0,0 +1,12 @@ +# apr_queue.lo - a libtool object file +# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.493 2008/02/01 16:58:18) +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/apr_queue.o' + +# Name of the non-PIC object. +non_pic_object='apr_queue.o' + diff --git a/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_queue.o b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_queue.o new file mode 100644 index 00000000..7e51f1f8 Binary files /dev/null and b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_queue.o differ diff --git a/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_reslist.c b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_reslist.c new file mode 100644 index 00000000..9bb5de90 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_reslist.c @@ -0,0 +1,375 @@ +/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * 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. + */ + +#include + +#include "apu.h" +#include "apr_reslist.h" +#include "apr_errno.h" +#include "apr_strings.h" +#include "apr_thread_mutex.h" +#include "apr_thread_cond.h" +#include "apr_ring.h" + +#if APR_HAS_THREADS + +/** + * A single resource element. + */ +struct apr_res_t { + apr_time_t freed; + void *opaque; + APR_RING_ENTRY(apr_res_t) link; +}; +typedef struct apr_res_t apr_res_t; + +/** + * A ring of resources representing the list of available resources. + */ +APR_RING_HEAD(apr_resring_t, apr_res_t); +typedef struct apr_resring_t apr_resring_t; + +struct apr_reslist_t { + apr_pool_t *pool; /* the pool used in constructor and destructor calls */ + int ntotal; /* total number of resources managed by this list */ + int nidle; /* number of available resources */ + int min; /* desired minimum number of available resources */ + int smax; /* soft maximum on the total number of resources */ + int hmax; /* hard maximum on the total number of resources */ + apr_interval_time_t ttl; /* TTL when we have too many resources */ + apr_interval_time_t timeout; /* Timeout for waiting on resource */ + apr_reslist_constructor constructor; + apr_reslist_destructor destructor; + void *params; /* opaque data passed to constructor and destructor calls */ + apr_resring_t avail_list; + apr_resring_t free_list; + apr_thread_mutex_t *listlock; + apr_thread_cond_t *avail; +}; + +/** + * Grab a resource from the front of the resource list. + * Assumes: that the reslist is locked. + */ +static apr_res_t *pop_resource(apr_reslist_t *reslist) +{ + apr_res_t *res; + res = APR_RING_FIRST(&reslist->avail_list); + APR_RING_REMOVE(res, link); + reslist->nidle--; + return res; +} + +/** + * Add a resource to the end of the list, set the time at which + * it was added to the list. + * Assumes: that the reslist is locked. + */ +static void push_resource(apr_reslist_t *reslist, apr_res_t *resource) +{ + APR_RING_INSERT_TAIL(&reslist->avail_list, resource, apr_res_t, link); + resource->freed = apr_time_now(); + reslist->nidle++; +} + +/** + * Get an empty resource container from the free list. + */ +static apr_res_t *get_container(apr_reslist_t *reslist) +{ + apr_res_t *res; + + assert(!APR_RING_EMPTY(&reslist->free_list, apr_res_t, link)); + + res = APR_RING_FIRST(&reslist->free_list); + APR_RING_REMOVE(res, link); + + return res; +} + +/** + * Free up a resource container by placing it on the free list. + */ +static void free_container(apr_reslist_t *reslist, apr_res_t *container) +{ + APR_RING_INSERT_TAIL(&reslist->free_list, container, apr_res_t, link); +} + +/** + * Create a new resource and return it. + * Assumes: that the reslist is locked. + */ +static apr_status_t create_resource(apr_reslist_t *reslist, apr_res_t **ret_res) +{ + apr_status_t rv; + apr_res_t *res; + + res = apr_pcalloc(reslist->pool, sizeof(*res)); + + rv = reslist->constructor(&res->opaque, reslist->params, reslist->pool); + + *ret_res = res; + return rv; +} + +/** + * Destroy a single idle resource. + * Assumes: that the reslist is locked. + */ +static apr_status_t destroy_resource(apr_reslist_t *reslist, apr_res_t *res) +{ + return reslist->destructor(res->opaque, reslist->params, reslist->pool); +} + +static apr_status_t reslist_cleanup(void *data_) +{ + apr_status_t rv; + apr_reslist_t *rl = data_; + apr_res_t *res; + + apr_thread_mutex_lock(rl->listlock); + + while (rl->nidle > 0) { + res = pop_resource(rl); + rl->ntotal--; + rv = destroy_resource(rl, res); + if (rv != APR_SUCCESS) { + return rv; + } + free_container(rl, res); + } + + assert(rl->nidle == 0); + assert(rl->ntotal == 0); + + apr_thread_mutex_destroy(rl->listlock); + apr_thread_cond_destroy(rl->avail); + + return APR_SUCCESS; +} + +/** + * Perform routine maintenance on the resource list. This call + * may instantiate new resources or expire old resources. + */ +static apr_status_t reslist_maint(apr_reslist_t *reslist) +{ + apr_time_t now; + apr_status_t rv; + apr_res_t *res; + int created_one = 0; + + apr_thread_mutex_lock(reslist->listlock); + + /* Check if we need to create more resources, and if we are allowed to. */ + while (reslist->nidle < reslist->min && reslist->ntotal <= reslist->hmax) { + /* Create the resource */ + rv = create_resource(reslist, &res); + if (rv != APR_SUCCESS) { + free_container(reslist, res); + apr_thread_mutex_unlock(reslist->listlock); + return rv; + } + /* Add it to the list */ + push_resource(reslist, res); + /* Update our counters */ + reslist->ntotal++; + /* If someone is waiting on that guy, wake them up. */ + rv = apr_thread_cond_signal(reslist->avail); + if (rv != APR_SUCCESS) { + apr_thread_mutex_unlock(reslist->listlock); + return rv; + } + created_one++; + } + + /* We don't need to see if we're over the max if we were under it before */ + if (created_one) { + apr_thread_mutex_unlock(reslist->listlock); + return APR_SUCCESS; + } + + /* Check if we need to expire old resources */ + now = apr_time_now(); + while (reslist->nidle > reslist->smax && reslist->nidle > 0) { + /* Peak at the first resource in the list */ + res = APR_RING_FIRST(&reslist->avail_list); + /* See if the oldest entry should be expired */ + if (now - res->freed < reslist->ttl) { + /* If this entry is too young, none of the others + * will be ready to be expired either, so we are done. */ + break; + } + res = pop_resource(reslist); + reslist->ntotal--; + rv = destroy_resource(reslist, res); + if (rv != APR_SUCCESS) { + apr_thread_mutex_unlock(reslist->listlock); + return rv; + } + free_container(reslist, res); + } + + apr_thread_mutex_unlock(reslist->listlock); + return APR_SUCCESS; +} + +APU_DECLARE(apr_status_t) apr_reslist_create(apr_reslist_t **reslist, + int min, int smax, int hmax, + apr_interval_time_t ttl, + apr_reslist_constructor con, + apr_reslist_destructor de, + void *params, + apr_pool_t *pool) +{ + apr_status_t rv; + apr_reslist_t *rl; + + /* Do some sanity checks so we don't thrash around in the + * maintenance routine later. */ + if (min > smax || min > hmax || smax > hmax || ttl < 0) { + return APR_EINVAL; + } + + rl = apr_pcalloc(pool, sizeof(*rl)); + rl->pool = pool; + rl->min = min; + rl->smax = smax; + rl->hmax = hmax; + rl->ttl = ttl; + rl->constructor = con; + rl->destructor = de; + rl->params = params; + + APR_RING_INIT(&rl->avail_list, apr_res_t, link); + APR_RING_INIT(&rl->free_list, apr_res_t, link); + + rv = apr_thread_mutex_create(&rl->listlock, APR_THREAD_MUTEX_DEFAULT, + pool); + if (rv != APR_SUCCESS) { + return rv; + } + rv = apr_thread_cond_create(&rl->avail, pool); + if (rv != APR_SUCCESS) { + return rv; + } + + rv = reslist_maint(rl); + if (rv != APR_SUCCESS) { + return rv; + } + + apr_pool_cleanup_register(rl->pool, rl, reslist_cleanup, + apr_pool_cleanup_null); + + *reslist = rl; + + return APR_SUCCESS; +} + +APU_DECLARE(apr_status_t) apr_reslist_destroy(apr_reslist_t *reslist) +{ + return apr_pool_cleanup_run(reslist->pool, reslist, reslist_cleanup); +} + +APU_DECLARE(apr_status_t) apr_reslist_acquire(apr_reslist_t *reslist, + void **resource) +{ + apr_status_t rv; + apr_res_t *res; + + apr_thread_mutex_lock(reslist->listlock); + /* If there are idle resources on the available list, use + * them right away. */ + if (reslist->nidle > 0) { + /* Pop off the first resource */ + res = pop_resource(reslist); + *resource = res->opaque; + free_container(reslist, res); + apr_thread_mutex_unlock(reslist->listlock); + return APR_SUCCESS; + } + /* If we've hit our max, block until we're allowed to create + * a new one, or something becomes free. */ + else while (reslist->ntotal >= reslist->hmax + && reslist->nidle <= 0) { + if (reslist->timeout) { + if ((rv = apr_thread_cond_timedwait(reslist->avail, + reslist->listlock, reslist->timeout)) != APR_SUCCESS) { + apr_thread_mutex_unlock(reslist->listlock); + return rv; + } + } + else + apr_thread_cond_wait(reslist->avail, reslist->listlock); + } + /* If we popped out of the loop, first try to see if there + * are new resources available for immediate use. */ + if (reslist->nidle > 0) { + res = pop_resource(reslist); + *resource = res->opaque; + free_container(reslist, res); + apr_thread_mutex_unlock(reslist->listlock); + return APR_SUCCESS; + } + /* Otherwise the reason we dropped out of the loop + * was because there is a new slot available, so create + * a resource to fill the slot and use it. */ + else { + rv = create_resource(reslist, &res); + if (rv == APR_SUCCESS) { + reslist->ntotal++; + *resource = res->opaque; + } + free_container(reslist, res); + apr_thread_mutex_unlock(reslist->listlock); + return rv; + } +} + +APU_DECLARE(apr_status_t) apr_reslist_release(apr_reslist_t *reslist, + void *resource) +{ + apr_res_t *res; + + apr_thread_mutex_lock(reslist->listlock); + res = get_container(reslist); + res->opaque = resource; + push_resource(reslist, res); + apr_thread_cond_signal(reslist->avail); + apr_thread_mutex_unlock(reslist->listlock); + + return reslist_maint(reslist); +} + +APU_DECLARE(void) apr_reslist_timeout_set(apr_reslist_t *reslist, + apr_interval_time_t timeout) +{ + reslist->timeout = timeout; +} + +APU_DECLARE(apr_status_t) apr_reslist_invalidate(apr_reslist_t *reslist, + void *resource) +{ + apr_status_t ret; + apr_thread_mutex_lock(reslist->listlock); + ret = reslist->destructor(resource, reslist->params, reslist->pool); + reslist->ntotal--; + apr_thread_mutex_unlock(reslist->listlock); + return ret; +} + +#endif /* APR_HAS_THREADS */ diff --git a/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_reslist.lo b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_reslist.lo new file mode 100644 index 00000000..dbd705a1 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_reslist.lo @@ -0,0 +1,12 @@ +# apr_reslist.lo - a libtool object file +# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.493 2008/02/01 16:58:18) +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/apr_reslist.o' + +# Name of the non-PIC object. +non_pic_object='apr_reslist.o' + diff --git a/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_reslist.o b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_reslist.o new file mode 100644 index 00000000..a65ef873 Binary files /dev/null and b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_reslist.o differ diff --git a/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_rmm.c b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_rmm.c new file mode 100644 index 00000000..ec09c6bc --- /dev/null +++ b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_rmm.c @@ -0,0 +1,428 @@ +/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * 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. + */ + +#include "apr_general.h" +#include "apr_rmm.h" +#include "apr_errno.h" +#include "apr_lib.h" +#include "apr_strings.h" + +typedef struct rmm_block_t { + apr_size_t size; + apr_rmm_off_t prev; + apr_rmm_off_t next; +} rmm_block_t; + +/* Always at our apr_rmm_off(0): + */ +typedef struct rmm_hdr_block_t { + apr_size_t abssize; + apr_rmm_off_t /* rmm_block_t */ firstused; + apr_rmm_off_t /* rmm_block_t */ firstfree; +} rmm_hdr_block_t; + +#define RMM_HDR_BLOCK_SIZE (APR_ALIGN_DEFAULT(sizeof(rmm_hdr_block_t))) +#define RMM_BLOCK_SIZE (APR_ALIGN_DEFAULT(sizeof(rmm_block_t))) + +struct apr_rmm_t { + apr_pool_t *p; + rmm_hdr_block_t *base; + apr_size_t size; + apr_anylock_t lock; +}; + +static apr_rmm_off_t find_block_by_offset(apr_rmm_t *rmm, apr_rmm_off_t next, + apr_rmm_off_t find, int includes) +{ + apr_rmm_off_t prev = 0; + + while (next) { + struct rmm_block_t *blk = (rmm_block_t*)((char*)rmm->base + next); + + if (find == next) + return next; + + /* Overshot? */ + if (find < next) + return includes ? prev : 0; + + prev = next; + next = blk->next; + } + return includes ? prev : 0; +} + +static apr_rmm_off_t find_block_of_size(apr_rmm_t *rmm, apr_size_t size) +{ + apr_rmm_off_t next = rmm->base->firstfree; + apr_rmm_off_t best = 0; + apr_rmm_off_t bestsize = 0; + + while (next) { + struct rmm_block_t *blk = (rmm_block_t*)((char*)rmm->base + next); + + if (blk->size == size) + return next; + + if (blk->size >= size) { + /* XXX: sub optimal algorithm + * We need the most thorough best-fit logic, since we can + * never grow our rmm, we are SOL when we hit the wall. + */ + if (!bestsize || (blk->size < bestsize)) { + bestsize = blk->size; + best = next; + } + } + + next = blk->next; + } + + if (bestsize > RMM_BLOCK_SIZE + size) { + struct rmm_block_t *blk = (rmm_block_t*)((char*)rmm->base + best); + struct rmm_block_t *new = (rmm_block_t*)((char*)rmm->base + best + size); + + new->size = blk->size - size; + new->next = blk->next; + new->prev = best; + + blk->size = size; + blk->next = best + size; + + if (new->next) { + blk = (rmm_block_t*)((char*)rmm->base + new->next); + blk->prev = best + size; + } + } + + return best; +} + +static void move_block(apr_rmm_t *rmm, apr_rmm_off_t this, int free) +{ + struct rmm_block_t *blk = (rmm_block_t*)((char*)rmm->base + this); + + /* close the gap */ + if (blk->prev) { + struct rmm_block_t *prev = (rmm_block_t*)((char*)rmm->base + blk->prev); + prev->next = blk->next; + } + else { + if (free) { + rmm->base->firstused = blk->next; + } + else { + rmm->base->firstfree = blk->next; + } + } + if (blk->next) { + struct rmm_block_t *next = (rmm_block_t*)((char*)rmm->base + blk->next); + next->prev = blk->prev; + } + + /* now find it in the other list, pushing it to the head if required */ + if (free) { + blk->prev = find_block_by_offset(rmm, rmm->base->firstfree, this, 1); + if (!blk->prev) { + blk->next = rmm->base->firstfree; + rmm->base->firstfree = this; + } + } + else { + blk->prev = find_block_by_offset(rmm, rmm->base->firstused, this, 1); + if (!blk->prev) { + blk->next = rmm->base->firstused; + rmm->base->firstused = this; + } + } + + /* and open it up */ + if (blk->prev) { + struct rmm_block_t *prev = (rmm_block_t*)((char*)rmm->base + blk->prev); + if (free && (blk->prev + prev->size == this)) { + /* Collapse us into our predecessor */ + prev->size += blk->size; + this = blk->prev; + blk = prev; + } + else { + blk->next = prev->next; + prev->next = this; + } + } + + if (blk->next) { + struct rmm_block_t *next = (rmm_block_t*)((char*)rmm->base + blk->next); + if (free && (this + blk->size == blk->next)) { + /* Collapse us into our successor */ + blk->size += next->size; + blk->next = next->next; + if (blk->next) { + next = (rmm_block_t*)((char*)rmm->base + blk->next); + next->prev = this; + } + } + else { + next->prev = this; + } + } +} + +APU_DECLARE(apr_status_t) apr_rmm_init(apr_rmm_t **rmm, apr_anylock_t *lock, + void *base, apr_size_t size, + apr_pool_t *p) +{ + apr_status_t rv; + rmm_block_t *blk; + apr_anylock_t nulllock; + + if (!lock) { + nulllock.type = apr_anylock_none; + nulllock.lock.pm = NULL; + lock = &nulllock; + } + if ((rv = APR_ANYLOCK_LOCK(lock)) != APR_SUCCESS) + return rv; + + (*rmm) = (apr_rmm_t *)apr_pcalloc(p, sizeof(apr_rmm_t)); + (*rmm)->p = p; + (*rmm)->base = base; + (*rmm)->size = size; + (*rmm)->lock = *lock; + + (*rmm)->base->abssize = size; + (*rmm)->base->firstused = 0; + (*rmm)->base->firstfree = RMM_HDR_BLOCK_SIZE; + + blk = (rmm_block_t *)((char*)base + (*rmm)->base->firstfree); + + blk->size = size - (*rmm)->base->firstfree; + blk->prev = 0; + blk->next = 0; + + return APR_ANYLOCK_UNLOCK(lock); +} + +APU_DECLARE(apr_status_t) apr_rmm_destroy(apr_rmm_t *rmm) +{ + apr_status_t rv; + rmm_block_t *blk; + + if ((rv = APR_ANYLOCK_LOCK(&rmm->lock)) != APR_SUCCESS) { + return rv; + } + /* Blast it all --- no going back :) */ + if (rmm->base->firstused) { + apr_rmm_off_t this = rmm->base->firstused; + do { + blk = (rmm_block_t *)((char*)rmm->base + this); + this = blk->next; + blk->next = blk->prev = 0; + } while (this); + rmm->base->firstused = 0; + } + if (rmm->base->firstfree) { + apr_rmm_off_t this = rmm->base->firstfree; + do { + blk = (rmm_block_t *)((char*)rmm->base + this); + this = blk->next; + blk->next = blk->prev = 0; + } while (this); + rmm->base->firstfree = 0; + } + rmm->base->abssize = 0; + rmm->size = 0; + + return APR_ANYLOCK_UNLOCK(&rmm->lock); +} + +APU_DECLARE(apr_status_t) apr_rmm_attach(apr_rmm_t **rmm, apr_anylock_t *lock, + void *base, apr_pool_t *p) +{ + apr_anylock_t nulllock; + + if (!lock) { + nulllock.type = apr_anylock_none; + nulllock.lock.pm = NULL; + lock = &nulllock; + } + + /* sanity would be good here */ + (*rmm) = (apr_rmm_t *)apr_pcalloc(p, sizeof(apr_rmm_t)); + (*rmm)->p = p; + (*rmm)->base = base; + (*rmm)->size = (*rmm)->base->abssize; + (*rmm)->lock = *lock; + return APR_SUCCESS; +} + +APU_DECLARE(apr_status_t) apr_rmm_detach(apr_rmm_t *rmm) +{ + /* A noop until we introduce locked/refcounts */ + return APR_SUCCESS; +} + +APU_DECLARE(apr_rmm_off_t) apr_rmm_malloc(apr_rmm_t *rmm, apr_size_t reqsize) +{ + apr_size_t size; + apr_rmm_off_t this; + + size = APR_ALIGN_DEFAULT(reqsize) + RMM_BLOCK_SIZE; + if (size < reqsize) { + return 0; + } + + APR_ANYLOCK_LOCK(&rmm->lock); + + this = find_block_of_size(rmm, size); + + if (this) { + move_block(rmm, this, 0); + this += RMM_BLOCK_SIZE; + } + + APR_ANYLOCK_UNLOCK(&rmm->lock); + return this; +} + +APU_DECLARE(apr_rmm_off_t) apr_rmm_calloc(apr_rmm_t *rmm, apr_size_t reqsize) +{ + apr_size_t size; + apr_rmm_off_t this; + + size = APR_ALIGN_DEFAULT(reqsize) + RMM_BLOCK_SIZE; + if (size < reqsize) { + return 0; + } + + APR_ANYLOCK_LOCK(&rmm->lock); + + this = find_block_of_size(rmm, size); + + if (this) { + move_block(rmm, this, 0); + this += RMM_BLOCK_SIZE; + memset((char*)rmm->base + this, 0, size - RMM_BLOCK_SIZE); + } + + APR_ANYLOCK_UNLOCK(&rmm->lock); + return this; +} + +APU_DECLARE(apr_rmm_off_t) apr_rmm_realloc(apr_rmm_t *rmm, void *entity, + apr_size_t reqsize) +{ + apr_rmm_off_t this; + apr_rmm_off_t old; + struct rmm_block_t *blk; + apr_size_t size, oldsize; + + if (!entity) { + return apr_rmm_malloc(rmm, reqsize); + } + + size = APR_ALIGN_DEFAULT(reqsize); + if (size < reqsize) { + return 0; + } + old = apr_rmm_offset_get(rmm, entity); + + if ((this = apr_rmm_malloc(rmm, size)) == 0) { + return 0; + } + + blk = (rmm_block_t*)((char*)rmm->base + old - RMM_BLOCK_SIZE); + oldsize = blk->size; + + memcpy(apr_rmm_addr_get(rmm, this), + apr_rmm_addr_get(rmm, old), oldsize < size ? oldsize : size); + apr_rmm_free(rmm, old); + + return this; +} + +APU_DECLARE(apr_status_t) apr_rmm_free(apr_rmm_t *rmm, apr_rmm_off_t this) +{ + apr_status_t rv; + struct rmm_block_t *blk; + + /* A little sanity check is always healthy, especially here. + * If we really cared, we could make this compile-time + */ + if (this < RMM_HDR_BLOCK_SIZE + RMM_BLOCK_SIZE) { + return APR_EINVAL; + } + + this -= RMM_BLOCK_SIZE; + + blk = (rmm_block_t*)((char*)rmm->base + this); + + if ((rv = APR_ANYLOCK_LOCK(&rmm->lock)) != APR_SUCCESS) { + return rv; + } + if (blk->prev) { + struct rmm_block_t *prev = (rmm_block_t*)((char*)rmm->base + blk->prev); + if (prev->next != this) { + APR_ANYLOCK_UNLOCK(&rmm->lock); + return APR_EINVAL; + } + } + else { + if (rmm->base->firstused != this) { + APR_ANYLOCK_UNLOCK(&rmm->lock); + return APR_EINVAL; + } + } + + if (blk->next) { + struct rmm_block_t *next = (rmm_block_t*)((char*)rmm->base + blk->next); + if (next->prev != this) { + APR_ANYLOCK_UNLOCK(&rmm->lock); + return APR_EINVAL; + } + } + + /* Ok, it remained [apparently] sane, so unlink it + */ + move_block(rmm, this, 1); + + return APR_ANYLOCK_UNLOCK(&rmm->lock); +} + +APU_DECLARE(void *) apr_rmm_addr_get(apr_rmm_t *rmm, apr_rmm_off_t entity) +{ + /* debug-sanity checking here would be good + */ + return (void*)((char*)rmm->base + entity); +} + +APU_DECLARE(apr_rmm_off_t) apr_rmm_offset_get(apr_rmm_t *rmm, void* entity) +{ + /* debug, or always, sanity checking here would be good + * since the primitive is apr_rmm_off_t, I don't mind penalizing + * inverse conversions for safety, unless someone can prove that + * there is no choice in some cases. + */ + return ((char*)entity - (char*)rmm->base); +} + +APU_DECLARE(apr_size_t) apr_rmm_overhead_get(int n) +{ + /* overhead per block is at most APR_ALIGN_DEFAULT(1) wasted bytes + * for alignment overhead, plus the size of the rmm_block_t + * structure. */ + return RMM_HDR_BLOCK_SIZE + n * (RMM_BLOCK_SIZE + APR_ALIGN_DEFAULT(1)); +} diff --git a/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_rmm.lo b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_rmm.lo new file mode 100644 index 00000000..facd7478 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_rmm.lo @@ -0,0 +1,12 @@ +# apr_rmm.lo - a libtool object file +# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.493 2008/02/01 16:58:18) +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/apr_rmm.o' + +# Name of the non-PIC object. +non_pic_object='apr_rmm.o' + diff --git a/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_rmm.o b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_rmm.o new file mode 100644 index 00000000..6a0e1874 Binary files /dev/null and b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apr_rmm.o differ diff --git a/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apu_version.c b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apu_version.c new file mode 100644 index 00000000..dab34b71 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apu_version.c @@ -0,0 +1,37 @@ +/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * 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. + */ + +#include "apr_general.h" /* for APR_STRINGIFY */ + +#include "apu.h" +#include "apu_version.h" + +APU_DECLARE(void) apu_version(apr_version_t *pvsn) +{ + pvsn->major = APU_MAJOR_VERSION; + pvsn->minor = APU_MINOR_VERSION; + pvsn->patch = APU_PATCH_VERSION; +#ifdef APU_IS_DEV_VERSION + pvsn->is_dev = 1; +#else + pvsn->is_dev = 0; +#endif +} + +APU_DECLARE(const char *) apu_version_string(void) +{ + return APU_VERSION_STRING; +} diff --git a/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apu_version.lo b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apu_version.lo new file mode 100644 index 00000000..3c72fd09 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apu_version.lo @@ -0,0 +1,12 @@ +# apu_version.lo - a libtool object file +# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.493 2008/02/01 16:58:18) +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/apu_version.o' + +# Name of the non-PIC object. +non_pic_object='apu_version.o' + diff --git a/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apu_version.o b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apu_version.o new file mode 100644 index 00000000..cc0201b8 Binary files /dev/null and b/rubbos/app/httpd-2.0.64/srclib/apr-util/misc/apu_version.o differ -- cgit 1.2.3-korg