Changeset 7212f9de44a1f04707e822e3337100a80f707cb3

Show
Ignore:
Timestamp:
01/15/08 16:41:44 (6 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1200415304 +0000
git-parent:

[f41090dab0be1c792f9587e2d2930761969ace33]

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

oh my, it compiles and runs

Files:

Legend:

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

    rf41090d r7212f9d  
    1616                     struct timeval *now) { 
    1717  int newmask = EVENTER_READ; 
    18   noit_log(noit_stderr, NULL, "HERE!\n"); 
    1918  if(mask & EVENTER_EXCEPTION) { 
    2019    eventer_remove_fd(e->fd); 
  • src/noit_listener.c

    rf41090d r7212f9d  
    77 
    88#include <unistd.h> 
     9#include <errno.h> 
    910#include <sys/time.h> 
    1011#include <sys/socket.h> 
     
    2829  } s; 
    2930 
    30   noit_log(noit_stderr, NULL, "Accepting\n"); 
    3131  if(mask & EVENTER_EXCEPTION) { 
    3232    eventer_remove_fd(e->fd); 
     
    6060  int8_t family; 
    6161  socklen_t on; 
     62  long reuse; 
    6263  listener_closure_t listener_closure; 
    6364  eventer_t event; 
     
    9192  } 
    9293 
     94  reuse = 1; 
     95  if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, 
     96                 (void*)&reuse, sizeof(reuse)) != 0) { 
     97 
     98    close(fd); 
     99    return -1; 
     100  } 
     101 
    93102  memset(&s, 0, sizeof(s)); 
    94103  s.addr6.sin6_family = family; 
     
    97106  if(bind(fd, (struct sockaddr *)&s, 
    98107          (family == AF_INET) ?  sizeof(s.addr4) : sizeof(s.addr6)) < 0) { 
     108    noit_log(noit_stderr, NULL, "bind failed: %s\b", strerror(errno)); 
    99109    close(fd); 
    100110    return -1; 
     
    111121  listener_closure->family = family; 
    112122  listener_closure->port = htons(port); 
     123  listener_closure->dispatch_callback = handler; 
    113124  listener_closure->dispatch_closure = closure; 
    114125 
  • src/noitd.c

    rf41090d r7212f9d  
    33#include <stdio.h> 
    44#include <stdlib.h> 
     5#include <errno.h> 
     6#include <sys/ioctl.h> 
     7#include <fcntl.h> 
    58 
    69#include "eventer/eventer.h" 
     
    1114int stdin_handler(eventer_t e, int mask, void *closure, struct timeval *now) { 
    1215  fprintf(stderr, "in stdin_handler:\n"); 
    13   return EVENTER_READ; 
     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; 
    1429} 
    1530void stdin_sample() { 
     31  socklen_t salen; 
    1632  eventer_t e; 
     33 
     34  salen = 1; 
     35  if(ioctl(0, FIONBIO, &salen)) { 
     36    fprintf(stderr, "Cannot unlock stdin\n"); 
     37  } 
    1738  e = eventer_alloc(); 
    1839  e->fd = 0;