Commit 768d1eed authored by Anders Berg's avatar Anders Berg

I have realized that I have major structure problems. I will have to study...

I have realized that I have major structure problems. I will have to study varnishlog output a bit more to understand it better.

May wanna start clean again, and use hardearned knowledge to make better and more robust structure.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@688 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent a8136a1f
...@@ -38,6 +38,8 @@ struct logline { ...@@ -38,6 +38,8 @@ struct logline {
// XXX Set to 1 if we have a IP adress. Not sure when to unset. // XXX Set to 1 if we have a IP adress. Not sure when to unset.
// Know for sure when we have a real SessionClose. Probably // Know for sure when we have a real SessionClose. Probably
// When we clean also. When we have timeout. Are there any more? // When we clean also. When we have timeout. Are there any more?
int v;
// Set to 1 if we wanna print the loglinestring because we are done
int w; int w;
// unsigned char *df_l; // Datafield for %l // unsigned char *df_l; // Datafield for %l
// unsigned char *df_u; // Datafield for %u // unsigned char *df_u; // Datafield for %u
...@@ -119,6 +121,7 @@ extended_log_format(unsigned char *p, char *w_opt) ...@@ -119,6 +121,7 @@ extended_log_format(unsigned char *p, char *w_opt)
i = 0; i = 0;
v = 0; v = 0;
w = 0; w = 0;
ll[u].w = 0;
switch (p[0]) { switch (p[0]) {
...@@ -133,7 +136,12 @@ extended_log_format(unsigned char *p, char *w_opt) ...@@ -133,7 +136,12 @@ extended_log_format(unsigned char *p, char *w_opt)
strncpy(ll[u].df_h, p + 4, j); strncpy(ll[u].df_h, p + 4, j);
ll[u].df_h[j] = '\0'; // put on a NULL at end of buffer. ll[u].df_h[j] = '\0'; // put on a NULL at end of buffer.
//printf("New session [%d]: %s \n",u, ll[u].df_h); //printf("New session [%d]: %s \n",u, ll[u].df_h);
ll[u].w = 1; // We have IP ll[u].v = 1; // We have IP
// We have a new session. This is a good place to initialize and
// clean data from previous sessions with same filedescriptor.
//free(ll[u].df_U);
break; break;
...@@ -258,14 +266,16 @@ extended_log_format(unsigned char *p, char *w_opt) ...@@ -258,14 +266,16 @@ extended_log_format(unsigned char *p, char *w_opt)
// XXX what to do with the timeout? // XXX what to do with the timeout?
// Right now I am gonna just let it pass, and not even clean memory. // Right now I am gonna just let it pass, and not even clean memory.
//printf("Timeout...\n"); //printf("Timeout...\n");
ll[u].w = 0; //ll[u].w = 1;
} }
else{ else{
v = 1; // We are done, clean memory ll[u].w = 1; // We are done, clean memory
ll[u].w = 0;
} }
free(ll[u].df_U);
break; break;
case SLT_SessionReuse: case SLT_SessionReuse:
...@@ -281,12 +291,12 @@ extended_log_format(unsigned char *p, char *w_opt) ...@@ -281,12 +291,12 @@ extended_log_format(unsigned char *p, char *w_opt)
j = strlen(p + 4) - strlen(tmpPtr); // length of IP j = strlen(p + 4) - strlen(tmpPtr); // length of IP
strncpy(ll[u].df_h, p + 4, j); strncpy(ll[u].df_h, p + 4, j);
ll[u].df_h[j] = '\0'; // put on a NULL at end of buffer. ll[u].df_h[j] = '\0'; // put on a NULL at end of buffer.
ll[u].w = 1; // We have a IP ll[u].v = 1; // We have a IP
} }
v = 1; // We are done, clean memory ll[u].w = 1; // We are done, clean memory
break; break;
...@@ -295,13 +305,13 @@ extended_log_format(unsigned char *p, char *w_opt) ...@@ -295,13 +305,13 @@ extended_log_format(unsigned char *p, char *w_opt)
break; break;
} }
// Memorycleaner and stringwriter. v is 1 after SLT_SessionClose OR SLT_SessionReuse that // Memorycleaner and stringwriter. w is 1 after SLT_SessionClose OR SLT_SessionReuse that
// do something useful. w is set when we have a real IP adress, somewhere we are getting // do something useful. v is set when we have a real IP adress, somewhere we are getting
// requests without. // requests without.
// //
// XXX Find out why we don't have IP and get rid of w. // XXX Find out why we don't have IP and get rid of v.
// //
if (v && ll[u].w) { if (ll[u].w && ll[u].v) {
...@@ -310,19 +320,30 @@ extended_log_format(unsigned char *p, char *w_opt) ...@@ -310,19 +320,30 @@ extended_log_format(unsigned char *p, char *w_opt)
printf("\"%s\"", sbuf_data(ob[u])); printf("\"%s\"", sbuf_data(ob[u]));
printf(" %s %s \"%s\" \"%s\"\n", ll[u].df_s, ll[u].df_b, ll[u].df_R, ll[u].df_U); printf(" %s %s \"%s\" \"%s\"\n", ll[u].df_s, ll[u].df_b, ll[u].df_R, ll[u].df_U);
sbuf_clear(ob[u]); sbuf_clear(ob[u]);
ll[u].df_U == NULL;
if (cm_R){ if (cm_R){
// Clean the memory for Referer // Clean the memory for Referer
free(ll[u].df_R); free(ll[u].df_R);
} }
if (cm_U){ if (cm_U){
// Clean User-Agent.
// Clean memory for User-Agent // Clean memory for User-Agent
free(ll[u].df_U); free(ll[u].df_U);
// Initialize User-Agent.
ll[u].df_U == NULL;
} }
if (cm_r){ if (cm_r){
// Clean memory for Date variables // Clean memory for Date variables
free(tmpPtrb); free(tmpPtrb);
} }
// XXX We reinitialize the struct logline
// free(ll[u]);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment