Changeset 12ef579a4576c2d52bc65063b48858887e0669da

Show
Ignore:
Timestamp:
01/08/10 22:32:46 (4 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1262989966 +0000
git-parent:

[3c6693076116177913e70ff74448aeea19e7baf0]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1262989966 +0000
Message:

self identifying script tags, refs #229

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/stratcon_realtime_http.c

    r3c66930 r12ef579  
    7575  } state; 
    7676  int count;            /* Number of jlog messages we need to read */ 
     77  u_int32_t hack_inc_id; 
    7778  noit_http_session_ctx *ctx; 
    7879  struct realtime_tracker *rt; 
     
    107108} 
    108109int 
    109 stratcon_line_to_javascript(noit_http_session_ctx *ctx, char *buff) { 
     110stratcon_line_to_javascript(noit_http_session_ctx *ctx, char *buff, 
     111                            u_int32_t inc_id) { 
    110112  char buffer[1024]; 
    111113  char *scp, *ecp, *token; 
     
    114116  const char *v, *cb = NULL; 
    115117  noit_hash_table json = NOIT_HASH_EMPTY; 
    116  
     118  char s_inc_id[42]; 
     119 
     120  snprintf(s_inc_id, sizeof(s_inc_id), "script-%08x", inc_id); 
    117121  if(noit_hash_retrieve(&ctx->req.querystring, "cb", strlen("cb"), &vcb)) 
    118122    cb = vcb; 
     
    162166#define ra_write(a,b) if(noit_http_response_append(ctx, a, b) == noit_false) BAIL_HTTP_WRITE 
    163167 
    164     snprintf(buffer, sizeof(buffer), "<script>%s({", cb); 
     168    snprintf(buffer, sizeof(buffer), "<script id=\"%s\">%s({", s_inc_id, cb); 
    165169    ra_write(buffer, strlen(buffer)); 
    166170 
     
    170174    } 
    171175    /* Time */ 
     176    noit_hash_store(&json, "script_id", 9, strdup(s_inc_id)); 
    172177    noit_hash_store(&json, "type", 4, strdup("M")); 
    173178    PROCESS_NEXT_FIELD(token,len); 
     
    369374      case REALTIME_HTTP_WANT_BODY: 
    370375        FULLREAD(e, ctx, ctx->body_len); 
    371         if(stratcon_line_to_javascript(ctx->ctx, ctx->buffer)) goto socket_error; 
     376        if(stratcon_line_to_javascript(ctx->ctx, ctx->buffer, ctx->hack_inc_id++)) goto socket_error; 
    372377        free(ctx->buffer); ctx->buffer = NULL; 
    373378        ctx->state = REALTIME_HTTP_WANT_HEADER;