Changeset 1648

Show
Ignore:
Timestamp:
07/08/08 23:09:23 (2 months ago)
Author:
till
Message:

nebula
- more *BSD compatibility changes
- default host and port in nebulaclient fixed

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • nebula/trunk/ChangeLog

    r1642 r1648  
    110.2.3 
    22- enable realtime signal thread control only if available 
     3- *BSD compatibility changes 
     4- default host and port in nebulaclient fixed 
    350.2.2 
    46- new threading concept: one clustering thread and one or more signature generation threads poll job queues 
  • nebula/trunk/client/nebulaclient.c

    r1623 r1648  
    134134        cbuf_len                = 0; 
    135135        cbuf                    = NULL; 
    136         nebula_port             = 12345
     136        nebula_port             = 4712
    137137        nebula_host             = NULL; 
    138138        dirname                 = NULL; 
     
    219219 
    220220        // prepare socket 
     221        if (!nebula_host && ((nebula_host = strdup("localhost")) == NULL)) { 
     222                fprintf(stderr, "Error - Unable to allocate memory: %s.\n", strerror(errno)); 
     223                exit(EXIT_FAILURE); 
     224        } 
    221225        if ((host = gethostbyname(nebula_host)) == NULL) { 
    222226                fprintf(stderr, "Error - Unable to resolve %s: %s.\n", nebula_host, strerror(errno)); 
  • nebula/trunk/src/Makefile.am

    r1623 r1648  
    55bin_PROGRAMS = nebula 
    66nebula_SOURCES =        signals.c signals.h \ 
     7                        sem.c sem.h \ 
    78                        md5.c md5.h \ 
    89                        sha512.c sha512.h \ 
  • nebula/trunk/src/classify.c

    r1642 r1648  
    4444 
    4545        for (;;) { 
    46                 if (sem_wait(&sessions_semaphore) == -1) { 
     46                if (repsem_wait(&sessions_semaphore) == -1) { 
    4747                        fprintf(stderr, "Error - Unable to decrement semaphore: %s.\n", strerror(errno)); 
    4848                        exit(EXIT_FAILURE); 
     
    275275 
    276276                        // wake up a signature generation thread 
    277                         if (sem_post(&siggen_semaphore) == -1) { 
     277                        if (repsem_post(&siggen_semaphore) == -1) { 
    278278                                fprintf(stderr, "Error - Unable to increment semaphore: %s.\n", strerror(errno)); 
    279279                                exit(EXIT_FAILURE); 
  • nebula/trunk/src/nebula.c

    r1626 r1648  
    141141 
    142142        // initialize semaphore 
    143         if ((sem_init(&sessions_semaphore, 0, 0) == -1) || 
    144             (sem_init(&sessions_semaphore, 0, 0) == -1)) { 
     143        if ((repsem_init(&sessions_semaphore, 0, 0) == -1) || 
     144            (repsem_init(&sessions_semaphore, 0, 0) == -1)) { 
    145145                fprintf(stderr, "Error - Unable to initialize semaphore: %s.\n", strerror(errno)); 
    146146                exit(EXIT_FAILURE); 
     
    275275                        exit(EXIT_FAILURE); 
    276276                } 
    277                 if (pthread_create(&ntid, &ptattr, pt_pollgq, (void *) &gthread_no)) { 
     277                if (pthread_create(&ntid, &ptattr, pt_pollgq, NULL)) { 
    278278                        fprintf(stderr, "Error - Cannot create signature generation thread: %s.\n", strerror(errno)); 
    279279                        exit(EXIT_FAILURE); 
     
    417417 
    418418                                                // wake up a classification thread 
    419                                                 if (sem_post(&sessions_semaphore) == -1) { 
     419                                                if (repsem_post(&sessions_semaphore) == -1) { 
    420420                                                        fprintf(stderr, "Error - Unable to increment semaphore: %s.\n", strerror(errno)); 
    421421                                                        exit(EXIT_FAILURE); 
  • nebula/trunk/src/nebula.h

    r1623 r1648  
    2828 
    2929#include <pthread.h> 
    30 #include <semaphore.h> 
     30//#include <semaphore.h> 
    3131 
    3232#include "avl.h" 
    3333#include "cluster.h" 
    3434#include "hash.h" 
     35#include "sem.h" 
    3536#include "session.h" 
    3637#include "stree.h" 
     
    7273pthread_rwlock_t        sighash_trie_lock; 
    7374 
    74 sem_t                 sessions_semaphore; 
    75 sem_t                 siggen_semaphore; 
     75repsem_t                      sessions_semaphore; 
     76repsem_t                      siggen_semaphore; 
    7677 
    7778#endif 
  • nebula/trunk/src/sig.c

    r1623 r1648  
    360360 
    361361        for (;;) { 
    362                 if (sem_wait(&siggen_semaphore) == -1) { 
     362                if (repsem_wait(&siggen_semaphore) == -1) { 
    363363                        fprintf(stderr, "Error - Unable to decrement semaphore: %s.\n", strerror(errno)); 
    364364                        exit(EXIT_FAILURE); 
  • nebula/trunk/src/signals.c

    r1642 r1648  
    9696                exit(EXIT_SUCCESS); 
    9797        } 
     98if (sig == SIGSEGV) printf("----> segfault.\n"); 
    9899 
    99100        // signal indicates an error 
  • nebula/trunk/src/util.c

    r1623 r1648  
    129129 
    130130        // destroy semaphores 
    131         if (sem_getvalue(&sessions_semaphore, &i) == -1) { 
     131        if (repsem_getvalue(&sessions_semaphore, &i) == -1) { 
    132132                fprintf(stderr, "Error - Unable to get semaphore value: %s.\n", strerror(errno)); 
    133133                exit(EXIT_FAILURE); 
    134134        } 
    135         for (; i; i--) sem_wait(&sessions_semaphore); 
    136         if (sem_destroy(&sessions_semaphore) == -1) { 
     135        for (; i; i--) repsem_wait(&sessions_semaphore); 
     136        if (repsem_destroy(&sessions_semaphore) == -1) { 
    137137                fprintf(stderr, "Error - Unable to destroy semaphore: %s.\n", strerror(errno)); 
    138138                exit(EXIT_FAILURE); 
    139139        } 
    140140         
    141         if (sem_getvalue(&siggen_semaphore, &i) == -1) { 
     141        if (repsem_getvalue(&siggen_semaphore, &i) == -1) { 
    142142                fprintf(stderr, "Error - Unable to get semaphore value: %s.\n", strerror(errno)); 
    143143                exit(EXIT_FAILURE); 
    144144        } 
    145         for (; i; i--) sem_wait(&siggen_semaphore); 
    146         if (sem_destroy(&siggen_semaphore) == -1) { 
     145        for (; i; i--) repsem_wait(&siggen_semaphore); 
     146        if (repsem_destroy(&siggen_semaphore) == -1) { 
    147147                fprintf(stderr, "Error - Unable to destroy semaphore: %s.\n", strerror(errno)); 
    148148                exit(EXIT_FAILURE);