1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-06 03:28:33 +00:00

(trunk libT) add a bunch of comments denoting where the libevent 2.0 changes will go

This commit is contained in:
Charles Kerr 2009-06-02 18:21:23 +00:00
parent aaf8a06777
commit 9513fcbe66
8 changed files with 27 additions and 8 deletions

View file

@ -17,7 +17,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h> /* close() */
#include <locale.h>
#include <unistd.h> /* close() */

View file

@ -34,6 +34,7 @@ struct evbuffer;
*/
/* these are PRIVATE IMPLEMENTATION details that should not be touched.
* I'll probably change them just to break your code! HA HA HA!
* it's included in the header for inlining and composition */
enum
{
@ -45,7 +46,8 @@ enum
TR_TYPE_REAL = 32
};
/* these are PRIVATE IMPLEMENTATION details that should not be touched.
/* These are PRIVATE IMPLEMENTATION details that should not be touched.
* I'll probably change them just to break your code! HA HA HA!
* it's included in the header for inlining and composition */
typedef struct tr_benc
{
@ -61,8 +63,8 @@ typedef struct tr_benc
{
size_t len; /* the string length */
union {
char buf[16]; /* a local buffer */
char * ptr; /* alloc'ed string */
char buf[16]; /* local buffer for short strings */
char * ptr; /* alloc'ed pointer for long strings */
} str;
} s;
@ -108,7 +110,7 @@ void tr_bencInitBool( tr_benc *, int value );
void tr_bencInitReal( tr_benc *, double value );
/***
****
**** Serialization / Deserialization
***/
typedef enum
@ -229,6 +231,7 @@ int tr_bencParseStr( const uint8_t * buf,
***
**/
/* this is only quasi-supported. don't rely on it too heavily outside of libT */
void tr_bencMergeDicts( tr_benc * target, const tr_benc * source );
/* @} */

View file

@ -683,6 +683,7 @@ tr_peerIoWrite( tr_peerIo * io,
size_t byteCount,
tr_bool isPieceData )
{
/* FIXME(libevent2): this implementation snould be moved to tr_peerIoWriteBuf. This function should be implemented as evbuffer_new() + evbuffer_add_reference() + a call to tr_peerIoWriteBuf() + evbuffer_free() */
struct tr_datatype * datatype;
assert( tr_amInEventThread( io->session ) );
@ -699,6 +700,7 @@ tr_peerIoWrite( tr_peerIo * io,
{
case PEER_ENCRYPTION_RC4:
{
/* FIXME(libevent2): use evbuffer_reserve_space() and evbuffer_commit_space() instead of tmp */
uint8_t tmp[MAX_STACK_ARRAY_SIZE];
const uint8_t * walk = bytes;
evbuffer_expand( io->outbuf, byteCount );
@ -728,6 +730,7 @@ tr_peerIoWriteBuf( tr_peerIo * io,
struct evbuffer * buf,
tr_bool isPieceData )
{
/* FIXME(libevent2): loop through calls to evbuffer_get_contiguous_space() + evbuffer_drain() */
const size_t n = EVBUFFER_LENGTH( buf );
tr_peerIoWrite( io, EVBUFFER_DATA( buf ), n, isPieceData );
evbuffer_drain( buf, n );
@ -744,6 +747,7 @@ tr_peerIoReadBytes( tr_peerIo * io,
size_t byteCount )
{
assert( tr_isPeerIo( io ) );
/* FIXME(libevent2): use evbuffer_get_length() */
assert( EVBUFFER_LENGTH( inbuf ) >= byteCount );
switch( io->encryptionMode )
@ -753,6 +757,7 @@ tr_peerIoReadBytes( tr_peerIo * io,
break;
case PEER_ENCRYPTION_RC4:
/* FIXME(libevent2): loop through calls to evbuffer_get_contiguous_space() + evbuffer_drain() */
tr_cryptoDecrypt( io->crypto, byteCount, EVBUFFER_DATA(inbuf), bytes );
evbuffer_drain(inbuf, byteCount );
break;

View file

@ -219,6 +219,7 @@ myDebug( const char * file, int line,
evbuffer_add_vprintf( buf, fmt, args );
va_end( args );
evbuffer_add_printf( buf, " (%s:%d)\n", base, line );
/* FIXME(libevent2) tr_getLog() should return an fd, then use evbuffer_write() here */
fwrite( EVBUFFER_DATA( buf ), 1, EVBUFFER_LENGTH( buf ), fp );
tr_free( base );
@ -1718,6 +1719,7 @@ fillOutputBuffer( tr_peermsgs * msgs, time_t now )
if( requestIsValid( msgs, &req )
&& tr_cpPieceIsComplete( &msgs->torrent->completion, req.index ) )
{
/* FIXME(libevent2): we can eliminate "buf" and an extra memcpy if we create an evbuffer here, add the message header, then use evbuffer_reserve_space() + tr_ioRead() + evbuffer_commit_space() */
int err;
static uint8_t buf[MAX_BLOCK_SIZE];
@ -1734,7 +1736,6 @@ fillOutputBuffer( tr_peermsgs * msgs, time_t now )
tr_peerIoWriteUint8 ( io, out, BT_PIECE );
tr_peerIoWriteUint32( io, out, req.index );
tr_peerIoWriteUint32( io, out, req.offset );
/* FIXME(libevent2): use evbuffer_add_reference() */
tr_peerIoWriteBytes ( io, out, buf, req.length );
tr_peerIoWriteBuf( io, out, TRUE );
bytesWritten += EVBUFFER_LENGTH( out );

View file

@ -324,6 +324,9 @@ add_response( struct evhttp_request * req,
{
int state;
/* FIXME(libevent2): this won't compile under libevent2.
but we can use evbuffer_reserve_space() + evbuffer_commit_space() instead */
server->stream.next_in = (Bytef*) content;
server->stream.avail_in = content_len;
@ -478,6 +481,7 @@ struct rpc_response_data
struct tr_rpc_server * server;
};
/* FIXME(libevent2): make "response" an evbuffer and remove response_len */
static void
rpc_response_func( tr_session * session UNUSED,
const char * response,

View file

@ -23,6 +23,7 @@ extern "C" {
struct tr_benc;
/* FIXME(libevent2): make "response" an evbuffer and remove response_len */
typedef void( *tr_rpc_response_func )( tr_session * session,
const char * response,
size_t response_len,

View file

@ -1339,6 +1339,11 @@ tr_torrentCloseLocalFiles( const tr_torrent * tor )
assert( tr_isTorrent( tor ) );
/* FIXME(libevent2) we're just using the evbuffer to build a key here anyway.
so we do (tor->info.fileCount * fd.openFileLimit) strcmps for these keys. :/
it would be more efficient to remove this code altogether and
add "int torrentId;" to "struct tr_openfile", and a new function
tr_fdCloseTorrentFiles( tr_session*, int torrentId ) */
for( i=0; i<tor->info.fileCount; ++i )
{
const tr_file * file = &tor->info.files[i];

View file

@ -270,8 +270,9 @@ tr_deepLog( const char * file,
evbuffer_add_vprintf( buf, fmt, args );
va_end( args );
evbuffer_add_printf( buf, " (%s:%d)\n", base, line );
/* FIXME(libevent2) ifdef this out for nonwindows platforms */
OutputDebugString( EVBUFFER_DATA( buf ) );
if(fp)
if(fp) /* FIXME(libevent2) tr_getLog() should return an fd, then use evbuffer_write() here ) */
(void) fwrite( EVBUFFER_DATA( buf ), 1, EVBUFFER_LENGTH( buf ), fp );
tr_free( base );