Changeset d3656fed58131220b357fb3d3df18b6ca52a4663

Show
Ignore:
Timestamp:
11/15/09 02:10:56 (8 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1258251056 +0000
git-parent:

[70b13a8622884b1df6251f14382a8d8736219ec2]

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

closes #170

Files:

Legend:

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

    r1da42f7 rd3656fe  
    9090                             (ctx->timeout_event ? "disconnected" : 
    9191                                                   "connecting"), lasttime); 
     92  if(ctx->e) { 
     93    char buff[128]; 
     94    const char *addrstr = NULL; 
     95    struct sockaddr_in6 addr6; 
     96    socklen_t len = sizeof(addr6); 
     97    if(getsockname(ctx->e->fd, (struct sockaddr *)&addr6, &len) == 0) { 
     98      unsigned short port = 0; 
     99      if(addr6.sin6_family == AF_INET) { 
     100        addrstr = inet_ntop(addr6.sin6_family, 
     101                            &((struct sockaddr_in *)&addr6)->sin_addr, 
     102                            buff, sizeof(buff)); 
     103        port = ntohs(((struct sockaddr_in *)&addr6)->sin_port); 
     104      } 
     105      else if(addr6.sin6_family == AF_INET6) { 
     106        addrstr = inet_ntop(addr6.sin6_family, &addr6.sin6_addr, 
     107                            buff, sizeof(buff)); 
     108        port = ntohs(addr6.sin6_port); 
     109      } 
     110      if(addrstr != NULL) 
     111        nc_printf(ncct, "\tLocal address is %s:%u\n", buff, port); 
     112      else 
     113        nc_printf(ncct, "\tLocal address not interpretable\n"); 
     114    } 
     115    else { 
     116      nc_printf(ncct, "\tLocal address error[%d]: %s\n", 
     117                ctx->e->fd, strerror(errno)); 
     118    } 
     119  } 
    92120  switch(ntohl(jctx->jlog_feed_cmd)) { 
    93121    case NOIT_JLOG_DATA_FEED: feedtype = "durable/storage"; break; 
     
    323351    noit_connection_schedule_reattempt(nctx, now); 
    324352    eventer_remove_fd(e->fd); 
     353    nctx->e = NULL; 
    325354    e->opset->close(e->fd, &mask, e); 
    326355    return 0; 
     
    396425          completion_e = eventer_alloc(); 
    397426          memcpy(completion_e, e, sizeof(*e)); 
     427          nctx->e = completion_e; 
    398428          completion_e->mask = EVENTER_READ | EVENTER_WRITE | EVENTER_EXCEPTION; 
    399429          ctx->state = JLOG_STREAMER_IS_ASYNC; 
     
    463493  noitL(noit_error, "jlog streamer SSL upgrade failed.\n"); 
    464494  eventer_remove_fd(e->fd); 
     495  nctx->e = NULL; 
    465496  e->opset->close(e->fd, &mask, e); 
    466497  noit_connection_schedule_reattempt(nctx, now); 
     
    510541          remote_str, strerror(aerrno)); 
    511542    eventer_remove_fd(e->fd); 
     543    nctx->e = NULL; 
    512544    e->opset->close(e->fd, &mask, e); 
    513545    noit_connection_schedule_reattempt(nctx, now); 
     
    542574#endif 
    543575 
     576  nctx->e = NULL; 
    544577  if(nctx->wants_permanent_shutdown) { 
    545578    noit_connection_ctx_dealloc(nctx); 
     
    587620  e->callback = noit_connection_complete_connect; 
    588621  e->closure = nctx; 
     622  nctx->e = e; 
    589623  eventer_add(e); 
    590624  return; 
     
    804838               (ctx->timeout_event ? (xmlChar *)"disconnected" : 
    805839                                    (xmlChar *)"connecting")); 
     840    if(ctx->e) { 
     841      char buff[128]; 
     842      const char *addrstr = NULL; 
     843      struct sockaddr_in6 addr6; 
     844      socklen_t len = sizeof(addr6); 
     845      if(getsockname(ctx->e->fd, (struct sockaddr *)&addr6, &len) == 0) { 
     846        unsigned short port = 0; 
     847        if(addr6.sin6_family == AF_INET) { 
     848          addrstr = inet_ntop(addr6.sin6_family, 
     849                              &((struct sockaddr_in *)&addr6)->sin_addr, 
     850                              buff, sizeof(buff)); 
     851          port = ntohs(((struct sockaddr_in *)&addr6)->sin_port); 
     852        } 
     853        else if(addr6.sin6_family == AF_INET6) { 
     854          addrstr = inet_ntop(addr6.sin6_family, &addr6.sin6_addr, 
     855                              buff, sizeof(buff)); 
     856          port = ntohs(addr6.sin6_port); 
     857        } 
     858        if(addrstr != NULL) { 
     859          snprintf(buff + strlen(buff), sizeof(buff) - strlen(buff), 
     860                   ":%u", port); 
     861          xmlSetProp(node, (xmlChar *)"local", (xmlChar *)buff); 
     862        } 
     863      } 
     864    } 
    806865    xmlSetProp(node, (xmlChar *)"remote", (xmlChar *)ctx->remote_str); 
    807866    switch(ntohl(jctx->jlog_feed_cmd)) { 
  • src/stratcon_jlog_streamer.h

    r1da42f7 rd3656fe  
    6060  struct timeval last_connect; 
    6161  eventer_t timeout_event; 
     62  eventer_t e; 
    6263 
    6364  eventer_func_t consumer_callback;