Changeset 9d912628f9c34c2d71a0893d6fb80b5c3730e7f1

Show
Ignore:
Timestamp:
06/16/09 16:04:36 (5 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1245168276 +0000
git-parent:

[1efd69391b750fb1932062208c86e6cf851dc6b7]

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

pull the realtime HTML document.domain from the config file... refs #145

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/stratcon.conf.in

    rf6540ba r9d91262  
    100100  <realtime type="stratcon_realtime_http"> 
    101101    <listener address="*" port="80"> 
     102      <config> 
     103        <hostname>stratcon.noit.example.com</hostname> 
     104        <document_domain>noit.example.com</document_domain> 
     105      </config> 
    102106    </listener> 
    103107  </realtime> 
  • src/stratcon_realtime_http.c

    r88a7178 r9d91262  
    8080  enum { RC_INITIAL = 0, RC_REQ_RECV, RC_INTERESTS_RESOLVED, RC_FEEDING } setup; 
    8181  struct realtime_tracker *checklist; 
     82  char *document_domain; 
    8283} realtime_context; 
    8384 
    84 static realtime_context *alloc_realtime_context() { 
     85static realtime_context *alloc_realtime_context(const char *domain) { 
    8586  realtime_context *ctx; 
    86   return calloc(sizeof(*ctx), 1); 
     87  ctx = calloc(sizeof(*ctx), 1); 
     88  ctx->document_domain = strdup(domain); 
     89  return ctx; 
    8790} 
    8891static void free_realtime_tracker(struct realtime_tracker *rt) { 
     
    9194} 
    9295static void clear_realtime_context(realtime_context *rc) { 
     96 rc->setup = RC_INITIAL; 
    9397  while(rc->checklist) { 
    9498    struct realtime_tracker *tofree; 
     
    97101    free_realtime_tracker(tofree); 
    98102  } 
     103  if(rc->document_domain) free(rc->document_domain); 
     104  rc->document_domain = NULL; 
    99105} 
    100106int 
     
    171177  if(0) { 
    172178    noit_http_response_end(ctx); 
    173     memset(ctx->dispatcher_closure, 0, sizeof(realtime_context)); 
     179    clear_realtime_context(ctx->dispatcher_closure); 
    174180    if(ctx->conn.e) eventer_trigger(ctx->conn.e, EVENTER_WRITE); 
    175181    return 0; 
     
    369375    noit_http_response_end(ctx); 
    370376    clear_realtime_context(rc); 
    371     memset(ctx->dispatcher_closure, 0, sizeof(realtime_context)); 
    372377    if(ctx->conn.e) eventer_trigger(ctx->conn.e, EVENTER_WRITE); 
    373378  } 
     
    407412    noit_http_response_header_set(ctx, "Content-Type", "text/html"); 
    408413 
    409     snprintf(c, sizeof(c), "<html><head><script>document.domain='omniti.com';</script></head><body>\n"); 
     414    snprintf(c, sizeof(c), 
     415             "<html><head><script>document.domain='%s';</script></head><body>\n", 
     416             rc->document_domain); 
    410417    noit_http_response_append(ctx, c, strlen(c)); 
    411418 
     
    438445  noit_http_session_ctx *http_ctx = ac->service_ctx; 
    439446  if(!http_ctx) { 
     447    const char *document_domain = NULL; 
     448 
     449    if(!noit_hash_retr_str(ac->config, 
     450                           "document_domain", strlen("document_domain"), 
     451                           &document_domain)) { 
     452      noitL(noit_error, "Document domain not set!  Realtime streaming will be broken\n"); 
     453      document_domain = ""; 
     454    } 
     455 
    440456    http_ctx = ac->service_ctx = 
    441457      noit_http_session_ctx_new(stratcon_request_dispatcher, 
    442                                 alloc_realtime_context(), 
     458                                alloc_realtime_context(document_domain), 
    443459                                e); 
    444460  }