Author: adrian.chadd
Date: Mon May 25 08:13:42 2009
New Revision: 14072
Modified:
playpen/LUSCA_HEAD_http_vector/libhttp/HttpHdrCc.c
playpen/LUSCA_HEAD_http_vector/libhttp/HttpHdrContRange.c
playpen/LUSCA_HEAD_http_vector/libhttp/HttpHdrRange.c
playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeader.c
playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeader.h
playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderEntry.c
playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderFieldInfo.c
playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderGet.c
playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderList.c
playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderMask.c
playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderParse.c
playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderPut.c
playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderStats.c
playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderTools.c
playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderVars.c
playpen/LUSCA_HEAD_http_vector/libhttp/HttpMsg.c
Log:
Hand merge in stuff from the old "http_work" branch. This code converts the
HttpHeaderEntry array of pointers to a Vector. This Vector type handles
the array entries itself.
A few shortcuts:
* the header repack code has been NULLed out, I need to think of how
to test that
* the sanity checks in the http header parsing code have been NULLed
out; I have to seriously rejig how all of that crap happens before
this code can be used outside of basic testing
TODO:
* fix the above shortcuts
* tidy up the whole httpHeaderParse() and subsequent mess
Maybe:
* Add a routine which deletes a http header entry and if its the last
one in the list, calls some vector routine to shrink the vector by
The parser can use this to parse and then delete entries that are
invalid. It -should- however sanity check the entries before
appending.
Modified: playpen/LUSCA_HEAD_http_vector/libhttp/HttpHdrCc.c
==============================================================================
--- playpen/LUSCA_HEAD_http_vector/libhttp/HttpHdrCc.c (original)
+++ playpen/LUSCA_HEAD_http_vector/libhttp/HttpHdrCc.c Mon May 25 08:13:42
2009
@@ -47,6 +47,7 @@
#include "../include/Array.h"
#include "../include/Stack.h"
+#include "../include/Vector.h"
#include "../include/util.h"
#include "../libcore/valgrind.h"
#include "../libcore/varargs.h"
Modified: playpen/LUSCA_HEAD_http_vector/libhttp/HttpHdrContRange.c
==============================================================================
--- playpen/LUSCA_HEAD_http_vector/libhttp/HttpHdrContRange.c (original)
+++ playpen/LUSCA_HEAD_http_vector/libhttp/HttpHdrContRange.c Mon May 25
08:13:42 2009
@@ -47,6 +47,7 @@
#include "../include/Array.h"
#include "../include/Stack.h"
+#include "../include/Vector.h"
#include "../include/util.h"
#include "../libcore/valgrind.h"
#include "../libcore/varargs.h"
Modified: playpen/LUSCA_HEAD_http_vector/libhttp/HttpHdrRange.c
==============================================================================
--- playpen/LUSCA_HEAD_http_vector/libhttp/HttpHdrRange.c (original)
+++ playpen/LUSCA_HEAD_http_vector/libhttp/HttpHdrRange.c Mon May 25
08:13:42 2009
@@ -47,6 +47,7 @@
#include "../include/Array.h"
#include "../include/Stack.h"
+#include "../include/Vector.h"
#include "../include/util.h"
#include "../libcore/valgrind.h"
#include "../libcore/varargs.h"
Modified: playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeader.c
==============================================================================
--- playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeader.c (original)
+++ playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeader.c Mon May 25 08:13:42
2009
@@ -47,6 +47,7 @@
#include "../include/Array.h"
#include "../include/Stack.h"
#include "../include/util.h"
+#include "../include/Vector.h"
#include "../libcore/valgrind.h"
#include "../libcore/varargs.h"
#include "../libcore/debug.h"
@@ -166,7 +167,7 @@
debug(55, 7) ("init-ing hdr: %p owner: %d\n", hdr, owner);
memset(hdr, 0, sizeof(*hdr));
hdr->owner = owner;
- arrayInit(&hdr->entries);
+ vector_init(&hdr->entries, sizeof(HttpHeaderEntry), 16);
}
/*!
@@ -208,10 +209,10 @@
* has been used. As a hack, just never count zero-sized header
* arrays.
*/
- if (0 != hdr->entries.count)
- statHistCount(&HttpHeaderStats[hdr->owner].hdrUCountDistr,
hdr->entries.count);
+ if (vector_numentries(&hdr->entries))
+ statHistCount(&HttpHeaderStats[hdr->owner].hdrUCountDistr,
vector_numentries(&hdr->entries));
HttpHeaderStats[hdr->owner].destroyedCount++;
- HttpHeaderStats[hdr->owner].busyDestroyedCount += hdr->entries.count >
0;
+ HttpHeaderStats[hdr->owner].busyDestroyedCount +=
vector_numentries(&hdr->entries) > 0;
while ((e = httpHeaderGetEntry(hdr, &pos))) {
/* tmp hack to try to avoid coredumps */
if (e->id >= HDR_ENUM_END) {
@@ -221,10 +222,9 @@
statHistCount(&HttpHeaderStats[hdr->owner].fieldTypeDistr,
e->id);
/* yes, this destroy() leaves us in an inconsistent state */
httpHeaderEntryDestroy(e);
- memPoolFree(pool_http_header_entry, e);
}
}
- arrayClean(&hdr->entries);
+ vector_done(&hdr->entries);
}
/* just handy in parsing: resets and returns false */
@@ -275,15 +275,24 @@
hdr->len += strLen(e->name) + 2 + strLen(e->value) + 2;
}
-/* appends an entry;
- * does not call httpHeaderEntryClone() so one should not reuse "*e"
- */
-void
-httpHeaderAddEntry(HttpHeader * hdr, HttpHeaderEntry * e)
+HttpHeaderEntry *
+httpHeaderAllocNewEntry(HttpHeader *hdr)
{
- debug(55, 7) ("%p adding entry: %d at %d\n", hdr, e->id,
hdr->entries.count);
- httpHeaderAddInfo(hdr, e);
- arrayAppend(&hdr->entries, e);
+ HttpHeaderEntry *e;
+
+ e = vector_append(&hdr->entries);
+ e->active = 0;
+ return e;
+}
+
+HttpHeaderEntry *
+httpHeaderAllocInsertEntry(HttpHeader *hdr, int pos)
+{
+ HttpHeaderEntry *e;
+
+ e = vector_insert(&hdr->entries, pos);
+ e->active = 0;
+ return e;
}
/*!
@@ -319,18 +328,18 @@
HttpHeaderEntry *
httpHeaderAddEntryStr2(HttpHeader *hdr, http_hdr_type id, const char *a,
int al, const char *v, int vl)
{
- HttpHeaderEntry *e = memPoolAlloc(pool_http_header_entry);
+ HttpHeaderEntry *e = httpHeaderAllocNewEntry(hdr);
httpHeaderEntryCreate(e, id, a, al, v, vl);
- httpHeaderAddEntry(hdr, e);
+ httpHeaderAddInfo(hdr, e);
return e;
}
void
httpHeaderAddEntryString(HttpHeader *hdr, http_hdr_type id, const String
*a, const String *v)
{
- HttpHeaderEntry *e = memPoolAlloc(pool_http_header_entry);
+ HttpHeaderEntry *e = httpHeaderAllocNewEntry(hdr);
httpHeaderEntryCreateStr(e, id, a, v);
- httpHeaderAddEntry(hdr, e);
+ httpHeaderAddInfo(hdr, e);
}
/*!
@@ -358,31 +367,23 @@
void
httpHeaderInsertEntryStr(HttpHeader *hdr, int pos, http_hdr_type id, const
char *attrib, const char *value)
{
- HttpHeaderEntry *e = memPoolAlloc(pool_http_header_entry);
+ HttpHeaderEntry *e = httpHeaderAllocInsertEntry(hdr, pos);
httpHeaderEntryCreate(e, id, attrib, -1, value, -1);
- httpHeaderInsertEntry(hdr, e, pos);
+ httpHeaderAddInfo(hdr, e);
}
-/* inserts an entry at the given position;
- * does not call httpHeaderEntryClone() so one should not reuse "*e"
- */
-void
-httpHeaderInsertEntry(HttpHeader * hdr, HttpHeaderEntry * e, int pos)
-{
- debug(55, 7) ("%p adding entry: %d at %d\n", hdr, e->id,
hdr->entries.count);
- httpHeaderAddInfo(hdr, e);
- arrayInsert(&hdr->entries, e, pos);
-}
/* returns next valid entry */
HttpHeaderEntry *
httpHeaderGetEntry(const HttpHeader * hdr, HttpHeaderPos * pos)
{
+ HttpHeaderEntry *e;
assert(hdr && pos);
- assert(*pos >= HttpHeaderInitPos && *pos < hdr->entries.count);
- for ((*pos)++; *pos < hdr->entries.count; (*pos)++) {
- if (hdr->entries.items[*pos])
- return hdr->entries.items[*pos];
+ assert(*pos >= HttpHeaderInitPos && *pos <
vector_numentries(&hdr->entries));
+ for ((*pos)++; *pos < vector_numentries(&hdr->entries); (*pos)++) {
+ e = vector_get(&hdr->entries, *pos);
+ if (e->active)
+ return e;
}
return NULL;
}
@@ -390,9 +391,9 @@
void
httpHeaderAddClone(HttpHeader * hdr, const HttpHeaderEntry * e)
{
- HttpHeaderEntry *ne = memPoolAlloc(pool_http_header_entry);
+ HttpHeaderEntry *ne = httpHeaderAllocNewEntry(hdr);
httpHeaderEntryClone(ne, e);
- httpHeaderAddEntry(hdr, ne);
+ httpHeaderAddInfo(hdr, ne);
}
/*!
@@ -478,14 +479,11 @@
httpHeaderDelAt(HttpHeader * hdr, HttpHeaderPos pos)
{
HttpHeaderEntry *e;
- assert(pos >= HttpHeaderInitPos && pos < hdr->entries.count);
- e = hdr->entries.items[pos];
- hdr->entries.items[pos] = NULL;
- /* decrement header length, allow for ": " and crlf */
+ assert(pos >= HttpHeaderInitPos && pos <
vector_numentries(&hdr->entries));
+ e = vector_get(&hdr->entries, pos);
hdr->len -= strLen(e->name) + 2 + strLen(e->value) + 2;
assert(hdr->len >= 0);
httpHeaderEntryDestroy(e);
- memPoolFree(pool_http_header_entry, e);
}
int
@@ -629,7 +627,8 @@
/* XXX breaks layering for now! ie, getting grubby fingers in without
httpHeaderEntryGet() */
dp = 0;
pos = 0;
- while (dp < hdr->entries.count) {
+#if 0 /* XXX disabled for now; will have to think of the -right- way
to
do this */
+ while (dp < vector_numentries(&hdr->entries)) {
for (; dp < hdr->entries.count && hdr->entries.items[dp] == NULL;
dp++);
if (dp >= hdr->entries.count)
break;
@@ -640,6 +639,7 @@
dp++;
}
arrayShrink(&hdr->entries, pos);
+#endif
}
/* use fresh entries to replace old ones */
Modified: playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeader.h
==============================================================================
--- playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeader.h (original)
+++ playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeader.h Mon May 25 08:13:42
2009
@@ -13,7 +13,7 @@
struct _HttpHeader {
/* protected, do not use these, use interface functions instead */
- Array entries; /* parsed entries in raw format */
+ Vector entries; /* parsed entries in raw format */
HttpHeaderMask mask; /* bit set <=> entry present */
http_hdr_owner_type owner; /* request or reply */
int len; /* length when packed, not counting
terminating '\0' */
@@ -29,7 +29,6 @@
typedef struct _TimeOrTag TimeOrTag;
extern HttpHeaderFieldInfo *Headers;
-extern MemPool * pool_http_header_entry;
/* XXX as mentioned in HttpHeader.c ; these probably shouldn't be here? */
extern HttpHeaderMask ListHeadersMask;
@@ -48,8 +47,6 @@
extern void httpHeaderClean(HttpHeader * hdr);
extern int httpHeaderReset(HttpHeader * hdr);
extern void httpHeaderAddClone(HttpHeader * hdr, const HttpHeaderEntry *
e);
-extern void httpHeaderAddEntry(HttpHeader * hdr, HttpHeaderEntry * e);
-extern void httpHeaderInsertEntry(HttpHeader * hdr, HttpHeaderEntry * e,
int pos);
extern void httpHeaderAppend(HttpHeader * dest, const HttpHeader * src);
extern HttpHeaderEntry *httpHeaderGetEntry(const HttpHeader * hdr,
HttpHeaderPos * pos);
extern HttpHeaderEntry *httpHeaderFindEntry(const HttpHeader * hdr,
http_hdr_type id);
@@ -72,5 +69,10 @@
extern void httpHeaderRefreshMask(HttpHeader * hdr);
/* append/update */
extern void httpHeaderUpdate(HttpHeader * old, const HttpHeader * fresh,
const HttpHeaderMask * denied_mask);
+
+/* new stuff */
+extern HttpHeaderEntry * httpHeaderAllocNewEntry(HttpHeader *hdr);
+extern HttpHeaderEntry * httpHeaderAllocInsertEntry(HttpHeader *hdr, int
pos);
+
#endif
Modified: playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderEntry.c
==============================================================================
--- playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderEntry.c (original)
+++ playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderEntry.c Mon May 25
08:13:42 2009
@@ -46,6 +46,7 @@
#include "../include/Array.h"
#include "../include/Stack.h"
+#include "../include/Vector.h"
#include "../include/util.h"
#include "../libcore/valgrind.h"
#include "../libcore/varargs.h"
Modified: playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderFieldInfo.c
==============================================================================
--- playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderFieldInfo.c
(original)
+++ playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderFieldInfo.c Mon May
25
08:13:42 2009
@@ -46,6 +46,7 @@
#include "../include/Array.h"
#include "../include/Stack.h"
+#include "../include/Vector.h"
#include "../include/util.h"
#include "../libcore/valgrind.h"
#include "../libcore/varargs.h"
Modified: playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderGet.c
==============================================================================
--- playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderGet.c (original)
+++ playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderGet.c Mon May 25
08:13:42 2009
@@ -47,6 +47,7 @@
#include "../include/Array.h"
#include "../include/Stack.h"
+#include "../include/Vector.h"
#include "../include/util.h"
#include "../libcore/valgrind.h"
#include "../libcore/varargs.h"
Modified: playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderList.c
==============================================================================
--- playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderList.c (original)
+++ playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderList.c Mon May 25
08:13:42 2009
@@ -46,6 +46,7 @@
#include "../include/Array.h"
#include "../include/Stack.h"
+#include "../include/Vector.h"
#include "../include/util.h"
#include "../libcore/valgrind.h"
#include "../libcore/varargs.h"
Modified: playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderMask.c
==============================================================================
--- playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderMask.c (original)
+++ playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderMask.c Mon May 25
08:13:42 2009
@@ -46,6 +46,7 @@
#include "../include/Array.h"
#include "../include/Stack.h"
+#include "../include/Vector.h"
#include "../include/util.h"
#include "../libcore/valgrind.h"
#include "../libcore/varargs.h"
Modified: playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderParse.c
==============================================================================
--- playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderParse.c (original)
+++ playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderParse.c Mon May 25
08:13:42 2009
@@ -47,6 +47,7 @@
#include "../include/Array.h"
#include "../include/Stack.h"
+#include "../include/Vector.h"
#include "../include/util.h"
#include "../libcore/valgrind.h"
#include "../libcore/varargs.h"
@@ -197,11 +198,14 @@
charBufferSize(field_start, field_end), field_start);
debug(55, httpConfig_relaxed_parser <= 0 ? 1 : 2)
(" in {%.*s}\n", charBufferSize(header_start, header_end),
header_start);
+#if 0 /* XXX just for now; is horrible */
if (httpConfig_relaxed_parser)
continue;
else
+#endif
return httpHeaderReset(hdr);
}
+#if 0
r = httpHeaderParseCheckEntry(hdr, e->id, &e->name, &e->value);
if (r <= 0) {
httpHeaderEntryDestroy(e);
@@ -212,6 +216,7 @@
return httpHeaderReset(hdr);
if (e)
httpHeaderAddEntry(hdr, e);
+#endif
}
return 1; /* even if no fields where found, it is a valid
header */
}
@@ -273,20 +278,8 @@
return NULL;
}
- e = memPoolAlloc(pool_http_header_entry);
- debug(55, 9) ("creating entry %p: near '%.*s'\n", e,
charBufferSize(field_start, field_end), field_start);
- e->id = id;
- /* set field name */
- if (id == HDR_OTHER)
- stringLimitInit(&e->name, field_start, name_len);
- else
- e->name = Headers[id].name;
- /* set field value */
- stringLimitInit(&e->value, value_start, field_end - value_start);
- e->active = 1;
- Headers[id].stat.seenCount++;
- Headers[id].stat.aliveCount++;
- debug(55, 9) ("created entry %p: '%.*s: %.*s'\n", e, strLen2(e->name),
strBuf2(e->name), strLen2(e->value), strBuf2(e->value));
+ e = httpHeaderAddEntryStr2(hdr, id, field_start, name_len,
value_start, field_end - value_start);
+ debug(55, 9) ("httpHeaderParseEntry: created
entry %p: '%.*s: %.*s'\n", e, strLen2(e->name), strBuf2(e->name),
strLen2(e->value), strBuf2(e->value));
return e;
}
Modified: playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderPut.c
==============================================================================
--- playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderPut.c (original)
+++ playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderPut.c Mon May 25
08:13:42 2009
@@ -46,6 +46,7 @@
#include "../include/Array.h"
#include "../include/Stack.h"
+#include "../include/Vector.h"
#include "../include/util.h"
#include "../libcore/valgrind.h"
#include "../libcore/varargs.h"
Modified: playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderStats.c
==============================================================================
--- playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderStats.c (original)
+++ playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderStats.c Mon May 25
08:13:42 2009
@@ -46,6 +46,7 @@
#include "../include/Array.h"
#include "../include/Stack.h"
+#include "../include/Vector.h"
#include "../include/util.h"
#include "../libcore/valgrind.h"
#include "../libcore/varargs.h"
Modified: playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderTools.c
==============================================================================
--- playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderTools.c (original)
+++ playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderTools.c Mon May 25
08:13:42 2009
@@ -46,6 +46,7 @@
#include "../include/Array.h"
#include "../include/Stack.h"
+#include "../include/Vector.h"
#include "../include/util.h"
#include "../libcore/valgrind.h"
#include "../libcore/varargs.h"
Modified: playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderVars.c
==============================================================================
--- playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderVars.c (original)
+++ playpen/LUSCA_HEAD_http_vector/libhttp/HttpHeaderVars.c Mon May 25
08:13:42 2009
@@ -46,6 +46,7 @@
#include "../include/Array.h"
#include "../include/Stack.h"
+#include "../include/Vector.h"
#include "../include/util.h"
#include "../libcore/valgrind.h"
#include "../libcore/varargs.h"
Modified: playpen/LUSCA_HEAD_http_vector/libhttp/HttpMsg.c
==============================================================================
--- playpen/LUSCA_HEAD_http_vector/libhttp/HttpMsg.c (original)
+++ playpen/LUSCA_HEAD_http_vector/libhttp/HttpMsg.c Mon May 25 08:13:42
2009
@@ -48,6 +48,7 @@
#include "../include/Array.h"
#include "../include/Stack.h"
+#include "../include/Vector.h"
#include "../include/util.h"
#include "../libcore/valgrind.h"
#include "../libcore/varargs.h"
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"lusca-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/lusca-commit?hl=en
-~----------~----~----~----~------~----~------~--~---