}
livesync_ticker();
-
+
/* See if we need to move our pools */
if( NOW != ot_last_clean_time ) {
ot_last_clean_time = NOW;
io_wantread( s );
-#ifdef _DEBUG
+#ifdef _DEBUG
fputs( " success.\n", stderr);
#endif
-
+
return s;
}
int bound = 0;
accesslist_filehandle = fopen( config_filename, "r" );
-
+
if( accesslist_filehandle == NULL ) {
fprintf( stderr, "Warning: Can't open config file: %s.", config_filename );
return 0;
}
-
+
while( fgets( inbuf, sizeof(inbuf), accesslist_filehandle ) ) {
char *newl;
char *p = inbuf;
/* Skip white spaces */
while(isspace(*p)) ++p;
-
+
/* Ignore comments and empty lines */
if((*p=='#')||(*p=='\n')||(*p==0)) continue;
fprintf( stderr, "Unhandled line in config file: %s\n", inbuf );
continue;
parse_error:
- fprintf( stderr, "Parse error in config file: %s\n", inbuf);
+ fprintf( stderr, "Parse error in config file: %s\n", inbuf);
}
fclose( accesslist_filehandle );
return bound;
char serverip[4] = {0,0,0,0}, tmpip[4];
int bound = 0, scanon = 1;
uint16_t tmpport;
-
+
while( scanon ) {
switch( getopt( argc, argv, ":i:p:A:P:d:r:s:f:v"
#ifdef WANT_ACCESSLIST_BLACK
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
-
+
$id$ */
/* System */
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
-
+
$id$ */
#ifndef __OT_ACCESSLIST_H__
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
-
+
$id$ */
/* System */
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
-
+
$id$ */
#ifndef __OT_CLEAN_H__
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
-
+
$id$ */
#ifdef WANT_FULLSCRAPE
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
-
+
$id$ */
#ifndef __OT_FULLSCRAPE_H__
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
-
+
$id$ */
/* System */
stats_deliver( client_socket, mode );
return -2;
}
-
+
/* Simple stats can be answerred immediately */
if( !( l = return_stats_for_tracker( static_outbuf + SUCCESS_HTTP_HEADER_LENGTH, mode, 0 ) ) ) HTTPERROR_500;
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
-
+
$id$ */
#ifndef __OT_HTTP_H__
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
-
+
$id$ */
/* System */
if( !new_ptr )
return NULL;
((*iovector)[*iovec_entries]).iov_base = new_ptr;
- ((*iovector)[*iovec_entries]).iov_len = new_alloc;
+ ((*iovector)[*iovec_entries]).iov_len = new_alloc;
++*iovec_entries;
return new_ptr;
}
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
-
+
$id$ */
#ifndef __OT_IOVEC_H__
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
-
+
$id$ */
/* System */
pthread_create( &thread_id, NULL, livesync_worker, NULL );
}
-
+
void livesync_deinit() {
pthread_cancel( thread_id );
}
stuck when there's not enough traffic to fill udp packets fast
enough */
void livesync_ticker( ) {
- if( ( g_now - livesync_lastpacket_time > LIVESYNC_MAXDELAY) &&
+ if( ( g_now - livesync_lastpacket_time > LIVESYNC_MAXDELAY) &&
( livesync_outbuffer_pos > livesync_outbuffer_start + sizeof( g_tracker_id ) ) )
livesync_issuepacket();
}
uint8_t in_ip[4]; uint16_t in_port;
ssize_t datalen;
int off;
-
+
args = args;
while( 1 ) {
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
-
+
$id$ */
#ifndef __OT_LIVESYNC_H__
0x001c 0x02 peer's port
0x0020 0x02 peer flags v1 ( SEEDING = 0x80, COMPLETE = 0x40, STOPPED = 0x20 )
]*
-
+
For N == 24: (aggregator syncs)
0x0000 0x04 id of tracker instance
[ 0x0004 0x14 info_hash
0x0021 0x02 peer flags v1 ( SEEDING = 0x80, COMPLETE = 0x40, STOPPED = 0x20 )
]+
]*
-
+
*/
#else
-/* If no syncing is required, save calling code from #ifdef
+/* If no syncing is required, save calling code from #ifdef
constructions */
#define livesync_init()
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
-
+
$id$ */
/* System */
bucket_remove( bucket );
pthread_cond_broadcast( &bucket_being_unlocked );
pthread_mutex_unlock( &bucket_mutex );
-}
+}
void mutex_bucket_unlock_by_hash( ot_hash *hash ) {
unsigned char *local_hash = hash[0];
}
/* Skip to end of list */
- tmptask = &tasklist;
+ tmptask = &tasklist;
while( *tmptask )
tmptask = &(*tmptask)->next;
*tmptask = task;
MTX_DBG( "pushresult unlocks.\n" );
pthread_mutex_unlock( &tasklist_mutex );
MTX_DBG( "pushresult unlocked.\n" );
-
+
/* Indicate whether the worker has to throw away results */
return task ? 0 : -1;
}
*iovec_entries = (*task)->iovec_entries;
*iovec = (*task)->iovec;
socket = (*task)->socket;
-
+
*task = (*task)->next;
free( ptask );
}
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
-
+
$id$ */
#ifndef __OT_MUTEX_H__
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
-
+
$id$ */
/* System */
int i, rest = 0;
if( !*node ) return 0;
- if( ++depth == STATS_NETWORK_NODE_MAXDEPTH )
+ if( ++depth == STATS_NETWORK_NODE_MAXDEPTH )
for( i=0; i<STATS_NETWORK_NODE_COUNT; ++i ) {
rest += ((*node)->counters[i]>>=shift);
return rest;
static size_t stats_httperrors_txt ( char * reply ) {
return sprintf( reply, "302 RED %llu\n400 ... %llu\n400 PAR %llu\n400 COM %llu\n403 IP %llu\n404 INV %llu\n500 SRV %llu\n",
- ot_failed_request_counts[0], ot_failed_request_counts[1], ot_failed_request_counts[2],
+ ot_failed_request_counts[0], ot_failed_request_counts[1], ot_failed_request_counts[2],
ot_failed_request_counts[3], ot_failed_request_counts[4], ot_failed_request_counts[5],
ot_failed_request_counts[6] );
}
*iovector = NULL;
if( !( r = iovec_increase( iovec_entries, iovector, OT_STATS_TMPSIZE ) ) )
return;
-
+
switch( mode & TASK_TASK_MASK ) {
case TASK_STATS_TORRENTS: r += stats_torrents_mrtg( r ); break;
- case TASK_STATS_PEERS: r += stats_peers_mrtg( r ); break;
+ case TASK_STATS_PEERS: r += stats_peers_mrtg( r ); break;
case TASK_STATS_SLASH24S: r += stats_slash24s_txt( r, 25, 16 ); break;
case TASK_STATS_TOP10: r += stats_top10_txt( r ); break;
case TASK_STATS_MEMORY: r += stats_vector_usage( r ); break;
static void * stats_worker( void * args ) {
int iovec_entries;
struct iovec *iovector;
-
+
args = args;
-
+
while( 1 ) {
ot_tasktype tasktype = TASK_STATS;
ot_taskid taskid = mutex_workqueue_poptask( &tasktype );
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
-
+
$id$ */
#ifndef __OT_STATS_H__
CODE_HTTPERROR_403_IP,
CODE_HTTPERROR_404,
CODE_HTTPERROR_500,
-
+
CODE_HTTPERROR_COUNT
};
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
-
+
$id$ */
/* System */
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
-
+
$id$ */
#ifndef __OT_SYNC_H__
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
-
+
$id$ */
/* System */
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
-
+
$id$ */
#ifndef __OT_UDP_H__
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
-
+
$id$ */
/* System */
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
-
+
$id$ */
#ifndef __OT_VECTOR_H__
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
-
+
$id$ */
#include "scan.h"
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
-
+
$id$ */
-
+
#ifndef __SCAN_URLENCODED_QUERY_H__
#define __SCAN_URLENCODED_QUERY_H__
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
-
+
$id$ */
/* System */
ot_torrent *torrent = binary_search( hash, torrents_list->data, torrents_list->size, sizeof( ot_torrent ), OT_HASH_COMPARE_SIZE, &exactmatch );
ot_peerlist *peer_list;
-#ifdef WANT_SYNC_LIVE
+#ifdef WANT_SYNC_LIVE
if( proto != FLAG_MCA )
livesync_tell( hash, peer, PEER_FLAG_STOPPED );
#endif
((uint32_t*)reply)[3] = ((uint32_t*)reply)[4] = 0;
return (size_t)20;
}
-
+
if( proto == FLAG_MCA )
return 0;
}
srandom( time(NULL) );
g_tracker_id = random();
-
+
/* Initialise background worker threads */
mutex_init( );
clean_init( );
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
-
+
$id$ */
#ifndef __OT_TRACKERLOGIC_H__