Changeset 1611
- Timestamp:
- 03/27/08 22:29:13 (6 months ago)
- Files:
-
- nebula/trunk/ChangeLog (modified) (1 diff)
- nebula/trunk/src/nebula.c (modified) (3 diffs)
- nebula/trunk/src/nebula.h (modified) (1 diff)
- nebula/trunk/src/session.c (modified) (1 diff)
- nebula/trunk/src/sig.c (modified) (3 diffs)
- nebula/trunk/src/sig.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
nebula/trunk/ChangeLog
r1593 r1611 8 8 - off-by-one error in signature generator input offset fixed 9 9 - signature generation triggers when cluster threshold is met instead of exceeded 10 - real time signals for adjusting certain parameters 11 - write instead of printf in signal handlers 10 12 - flush stdout after each session 11 13 - clean up on SIGINT and SIGTERM nebula/trunk/src/nebula.c
r1593 r1611 87 87 memset(pfdflag, 0, sizeof(u_char) * (POLLFD_SET_SIZE)); 88 88 memset(s, 0, sizeof(submission) * POLLFD_SET_SIZE); 89 pollfd_set_size = 0; 89 90 90 91 global_sid = 2000000; … … 272 273 273 274 for(;;) { 274 switch (rv = poll(pfdset, POLLFD_SET_SIZE+1, -1)) {275 switch (rv = poll(pfdset, pollfd_set_size+1, -1)) { 275 276 case -1: 276 277 if (errno == EINTR) break; … … 294 295 } 295 296 296 if (LISTEN_SOCK.revents & POLLIN) { 297 // incoming connection, find next free place in poll fd set 298 299 for (i=0; i<POLLFD_SET_SIZE; i++) { 300 if (pfdset[i].fd <= 0) { 301 pthread_mutex_lock(&sessions_mutex); 302 303 pfdset[i].fd = net_accept(LISTEN_SOCK.fd); 304 pfdset[i].events = POLLOUT; 305 pfdflag[i] = 1; 306 307 memset(&s[i], 0, sizeof(submission)); 308 309 pthread_mutex_unlock(&sessions_mutex); 310 311 if (verbose > 1) printf("[>] Connection accepted.\n"); 312 break; 313 } 314 } 297 if ((LISTEN_SOCK.revents & POLLIN) && pollfd_set_size < POLLFD_SET_SIZE) { 298 // incoming connection, accept it and place fd in pollfd set 299 pthread_mutex_lock(&sessions_mutex); 300 301 pollfd_set_size++; 302 303 pfdset[pollfd_set_size].fd = net_accept(LISTEN_SOCK.fd); 304 pfdset[pollfd_set_size].events = POLLOUT; 305 pfdflag[pollfd_set_size] = 1; 306 307 memset(&s[pollfd_set_size], 0, sizeof(submission)); 308 309 pthread_mutex_unlock(&sessions_mutex); 310 311 if (verbose > 1) printf("[>] Connection accepted.\n"); 315 312 } 316 313 } 317 for (i= 0; i<POLLFD_SET_SIZE; i++) {314 for (i=1; i<=pollfd_set_size; i++) { 318 315 if (pfdflag[i] && pfdset[i].revents & POLLOUT) { 319 316 switch (session_handle_data(&pfdset[i], &s[i])) { nebula/trunk/src/nebula.h
r1593 r1611 37 37 38 38 #define POLLFD_SET_SIZE 255 39 #define LISTEN_SOCK pfdset[ POLLFD_SET_SIZE]39 #define LISTEN_SOCK pfdset[0] 40 40 41 41 struct pollfd pfdset[POLLFD_SET_SIZE+1]; 42 42 u_char pfdflag[POLLFD_SET_SIZE]; 43 int pollfd_set_size; // size of dynamically adjusted set 43 44 44 45 int lock_mutex; nebula/trunk/src/session.c
r1593 r1611 50 50 if (verbose > 1) printf("[<] Connection terminated.\n"); 51 51 52 memset(&pfdset[session_number], 0, sizeof(struct pollfd)); 52 // shrink pollfd set 53 memmove(&pfdset[session_number], &pfdset[session_number+1], sizeof(struct pollfd) * (POLLFD_SET_SIZE-session_number)); 54 memset(&pfdset[pollfd_set_size], 0, sizeof(struct pollfd)); 55 pollfd_set_size--; 56 53 57 pfdset[session_number].events = 0; 54 58 pfdflag[session_number] = 0; // mark fd as unused nebula/trunk/src/sig.c
r1589 r1611 110 110 111 111 // find minimal and maximal offset for leaves in this substring's subtree 112 for (leaf = l; leaf < num_leaves && leaf <= r; leaf ++) {112 for (leaf = l; leaf < num_leaves && leaf <= r; leaf++) { 113 113 id = leaves[leaf]->string_id-1; 114 114 start = leaves[leaf]->path_position; … … 126 126 127 127 128 // store signature info into for hashing a contiguous memory area128 // store signature info into a contiguous memory area and calculate hash 129 129 for (i=num_frags; i; i--) { 130 130 // append next signature segment … … 290 290 if (!printable) putchar('|'); 291 291 INC_CHARCOUNT(1); 292 printf("\"; depth: %lu; offset: %lu;", 293 (long unsigned int) seglist[num_frags-1].max_off+seglist[num_frags-1].len, 292 printf("\"; offset: %lu; depth: %lu;", 294 293 (long unsigned int) (seglist[num_frags-1].min_off > seglist[num_frags-1].len ? 295 seglist[num_frags-1].min_off - seglist[num_frags-1].len : 0)); 294 seglist[num_frags-1].min_off - seglist[num_frags-1].len : 0), 295 (long unsigned int) seglist[num_frags-1].max_off+seglist[num_frags-1].len); 296 296 297 297 // process other segments nebula/trunk/src/sig.h
r1589 r1611 84 84 85 85 typedef struct { 86 ssize_t org_off; 87 ssize_t min_off; 88 ssize_t max_off; 89 ssize_t len; 86 ssize_t org_off; // actual offset in the GST input string 87 ssize_t min_off; // minimum offset in byte streams 88 ssize_t max_off; // maximum offset in byte streams 89 ssize_t len; // segment length 90 90 } sseg; 91 91
