Changeset f235ad41b286a70c1f8e40c8e56eebc9b051508a

Show
Ignore:
Timestamp:
01/16/08 04:57:05 (6 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1200459425 +0000
git-parent:

[7212f9de44a1f04707e822e3337100a80f707cb3]

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

make this work on Mac OS X

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/eventer/eventer_kqueue_impl.c

    rb62cf2b rf235ad4  
    88#include "utils/noit_atomic.h" 
    99#include "utils/noit_skiplist.h" 
     10#include "utils/noit_log.h" 
    1011 
    1112#include <errno.h> 
     
    265266                      NULL, 0, 
    266267                      &__zerotime); 
     268      noit_log(noit_debug, &__now, "debug: kevent(%d, [], %d) => %d\n", kqueue_fd, master_kqs->__ke_vec_used, fd_cnt); 
    267269      if(fd_cnt < 0) { 
    268         fprintf(stderr, "kevent: %s\n", strerror(errno)); 
     270        noit_log(noit_error, &__now, "kevent: %s\n", strerror(errno)); 
    269271      } 
    270272      master_kqs->__ke_vec_used = 0; 
     
    278280                    ke_vec, ke_vec_a, 
    279281                    &__kqueue_sleeptime); 
     282    noit_log(noit_debug, &__now, "debug: kevent(%d, [], %d) => %d\n", kqueue_fd, ke_vec_used, fd_cnt); 
    280283    ke_vec_used = 0; 
    281284    if(fd_cnt < 0) { 
    282       fprintf(stderr, "kevent: %s\n", strerror(errno)); 
     285      noit_log(noit_error, &__now, "kevent: %s\n", strerror(errno)); 
    283286    } 
    284287    else { 
     
    291294 
    292295        ke = &ke_vec[idx]; 
     296        if(ke->flags & EV_ERROR) { 
     297          if(ke->data != EBADF) 
     298            noit_log(noit_error, &__now, "error: %s\n", strerror(ke->data)); 
     299          continue; 
     300        } 
    293301        e = (eventer_t)ke->udata; 
    294302        fd = ke->ident; 
  • src/noit_console.c

    r7212f9d rf235ad4  
    2525    char buffer[4096]; 
    2626    len = e->opset->read(e->fd, buffer, sizeof(buffer)-1, &newmask, e); 
    27     if(len < 0) { 
     27    if(len <= 0) { 
    2828      eventer_remove_fd(e->fd); 
    2929      close(e->fd); 
  • src/noitd.c

    r7212f9d rf235ad4  
    1212#include "noit_console.h" 
    1313 
    14 int stdin_handler(eventer_t e, int mask, void *closure, struct timeval *now) { 
    15   fprintf(stderr, "in stdin_handler:\n"); 
    16   while(1) { 
    17     int len; 
    18     char buffer[1024]; 
    19     len = e->opset->read(e->fd, buffer, sizeof(buffer)-1, &mask, NULL); 
    20     printf("read() => %d\n", len); 
    21     if(len < 0 && errno == EINTR) continue; 
    22     if(len < 0 && errno == EAGAIN) break; 
    23     if(len > 0) { 
    24       buffer[len] = '\0'; 
    25       printf("read: '%s'\n", buffer); 
    26     } 
    27   } 
    28   return mask; 
    29 
    30 void stdin_sample() { 
    31   socklen_t salen; 
    32   eventer_t e; 
     14int main(int argc, char **argv) { 
    3315 
    34   salen = 1; 
    35   if(ioctl(0, FIONBIO, &salen)) { 
    36     fprintf(stderr, "Cannot unlock stdin\n"); 
    37   } 
    38   e = eventer_alloc(); 
    39   e->fd = 0; 
    40   e->mask = EVENTER_READ; 
    41   e->callback = stdin_handler; 
    42   eventer_add(e); 
    43 } 
    44 int main(int argc, char **argv) { 
    4516  noit_log_init(); 
     17  noit_log_stream_add_stream(noit_debug, noit_stderr); 
     18  noit_log_stream_add_stream(noit_error, noit_stderr); 
     19 
    4620  if(eventer_choose("kqueue") == -1) { 
    4721    fprintf(stderr, "Cannot choose kqueue\n"); 
     
    5327  } 
    5428 
    55   stdin_sample(); 
    5629  noit_listener("127.0.0.1", 23123, SOCK_STREAM, 5, noit_console_handler, NULL); 
    5730  eventer_loop(); 
  • src/utils/noit_log.c

    rf41090d rf235ad4  
    1414static noit_hash_table noit_loggers = NOIT_HASH_EMPTY; 
    1515noit_log_stream_t noit_stderr = NULL; 
     16noit_log_stream_t noit_error = NULL; 
     17noit_log_stream_t noit_debug = NULL; 
    1618 
    1719void 
     
    1921  noit_hash_init(&noit_loggers); 
    2022  noit_stderr = noit_log_stream_new_on_fd("stderr", 2); 
     23  noit_error = noit_log_stream_new("error"); 
     24  noit_debug = noit_log_stream_new("debug"); 
    2125} 
    2226 
  • src/utils/noit_log.h

    rf41090d rf235ad4  
    2424 
    2525extern noit_log_stream_t noit_stderr; 
     26extern noit_log_stream_t noit_debug; 
     27extern noit_log_stream_t noit_error; 
    2628 
    2729API_EXPORT(void) noit_log_init();