httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Oppegaard <...@joppegaard.com>
Subject Re: mod_usertrack.c modifications and child seg faults
Date Wed, 20 Nov 2002 19:45:06 GMT
On 20 Nov 2002, Jeff Trawick wrote:
> 
> Joe Oppegaard <joe@joppegaard.com> writes:
> 
> > Once I switch over to the if statement that first checks for r->content_type
> > then calls strcmp, everything works just as expected.
> > 
> > Any ideas on why this is?
> 
> the simple answer is "because r->content_type has not yet been set at
> this point"
> 
> and if you look at other code in Apache you'll see checks to verify
> that r->content_type is actually set
> 
> as for why r->content_type isn't set as of the fixup hook on this
> particular request, I do not know...  it depends on the config
> affecting this request and what other modules are doing

Ah yes, that's true I noticed that in a few other modules. In trying to 
figure this out, I had thrown in a ap_rprintf statement, and seen 
that r->content_type is actually holding a value at this point.

In the code below this will actually spit back out to the browser what 
the content type is. If I uncomment the if with just the strcmp by 
itself it will segfault. Though when that strcmp statement wasn't there, 
printf showed that value existed at that point, correct? 

Of course, using the if statement that first checks r->content_type 
still works perfect. 

I can handle the answer of that's just how you do it, but I'm confused 
on why.

--- mod_usertrack.c.orig        2002-11-19 23:36:26.000000000 -0800
+++ mod_usertrack.c     2002-11-20 11:29:33.000000000 -0800
@@ -222,8 +222,18 @@

             return DECLINED;    /* There's already a cookie, no new one */
         }
-    make_cookie(r);
-    return OK;                  /* We set our cookie */
+
+
+    ap_rprintf(r,"r->content_type holds %s", r->content_type);
+    /*if (r->content_type && strcmp(r->content_type,"text/html") == 0) {*/
+    /*if (strcmp(r->content_type,"text/html") == 0) {*/
+    if (1) {
+       make_cookie(r);
+        return OK;
+    }
+    else {
+        return DECLINED;
+    }
 }

 static void *make_cookie_log_state(apr_pool_t *p, server_rec *s)



<old patch snipped>
>
> is this really the right patch?  how do you even get to the code below
> given the unconditional "return OK" right above?
> 

Oops! There should have been a few minus signs there.

The patch above is correct now though. :)

___
Joe Oppegaard
http://joppegaard.com

GnuPG/PGP Information:
Key: 1024D/272159F6
Keyserver: pgp.mit.edu
By web: http://joppegaard.com/files/0x272159F6.asc



Mime
View raw message