Ignore:
Timestamp:
Feb 23, 2010, 7:20:57 AM (12 years ago)
Author:
charles
Message:

(trunk libT) use jch's suggestion of having a per-session page-aligned memory buffer for general reuse. (http://trac.transmissionbt.com/ticket/2551#comment:5)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-io.c

    r9973 r10276  
    3333#include "net.h"
    3434#include "peer-io.h"
    35 #include "platform.h" /* MAX_STACK_ARRAY_SIZE */
    3635#include "trevent.h" /* tr_runInEventThread() */
    3736#include "utils.h"
     
    811810        {
    812811            /* FIXME(libevent2): use evbuffer_reserve_space() and evbuffer_commit_space() instead of tmp */
    813             uint8_t tmp[MAX_STACK_ARRAY_SIZE];
     812            void * tmp = tr_sessionGetBuffer( io->session );
     813            const size_t tmplen = SESSION_BUFFER_SIZE;
    814814            const uint8_t * walk = bytes;
    815815            evbuffer_expand( io->outbuf, byteCount );
    816816            while( byteCount > 0 )
    817817            {
    818                 const size_t thisPass = MIN( byteCount, sizeof( tmp ) );
     818                const size_t thisPass = MIN( byteCount, tmplen );
    819819                tr_cryptoEncrypt( io->crypto, thisPass, walk, tmp );
    820820                evbuffer_add( io->outbuf, tmp, thisPass );
     
    822822                byteCount -= thisPass;
    823823            }
     824            tr_sessionReleaseBuffer( io->session );
    824825            break;
    825826        }
     
    882883                size_t            byteCount )
    883884{
    884     uint8_t tmp[MAX_STACK_ARRAY_SIZE];
     885    void * buf = tr_sessionGetBuffer( io->session );
     886    const size_t buflen = SESSION_BUFFER_SIZE;
    885887
    886888    while( byteCount > 0 )
    887889    {
    888         const size_t thisPass = MIN( byteCount, sizeof( tmp ) );
    889         tr_peerIoReadBytes( io, inbuf, tmp, thisPass );
     890        const size_t thisPass = MIN( byteCount, buflen );
     891        tr_peerIoReadBytes( io, inbuf, buf, thisPass );
    890892        byteCount -= thisPass;
    891893    }
     894
     895    tr_sessionReleaseBuffer( io->session );
    892896}
    893897
Note: See TracChangeset for help on using the changeset viewer.