summaryrefslogtreecommitdiff
path: root/ot_sync.c
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2007-11-23 18:13:11 +0000
committerDirk Engling <erdgeist@erdgeist.org>2007-11-23 18:13:11 +0000
commit2624d425da7ea566479bd5e131ce407e95c761de (patch)
treecd2290d3cdf46c67279fc60e5aa9623b5d5b1886 /ot_sync.c
parent56815b367240600ab7095bdcbb46456850dc1d2e (diff)
downloadopentracker-2624d425da7ea566479bd5e131ce407e95c761de.tar.gz
opentracker-2624d425da7ea566479bd5e131ce407e95c761de.zip
Reflect changes in iovec code in sync code
Diffstat (limited to 'ot_sync.c')
-rw-r--r--ot_sync.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/ot_sync.c b/ot_sync.c
index 5261ee6..6964098 100644
--- a/ot_sync.c
+++ b/ot_sync.c
@@ -96,19 +96,10 @@ static void sync_make( int *iovec_entries, struct iovec **iovector ) {
/* If we reached our low watermark in buffer... */
if( re - r <= (ssize_t)(/* strlen( "20:" ) == */ 3 + sizeof( ot_hash ) + /* strlen_max( "%zd" ) == */ 12 + byte_count ) ) {
- /* crop current output buffer to the amount really used */
- iovec_fixlast( iovec_entries, iovector, OT_SYNC_CHUNK_SIZE - ( re - r ) );
-
- /* And allocate a fresh output buffer at the end of our buffers list */
- if( !( r = iovec_increase( iovec_entries, iovector, OT_SYNC_CHUNK_SIZE ) ) ) {
-
- /* If this fails: free buffers */
- iovec_free( iovec_entries, iovector );
-
- /* Release lock on current bucket and return */
- mutex_bucket_unlock( bucket );
- return;
- }
+ /* Allocate a fresh output buffer at the end of our buffers list
+ release bucket and return, if that fails */
+ if( !( r = iovec_fix_increase_or_free( iovec_entries, iovector, r, OT_SYNC_CHUNK_SIZE ) ) )
+ return mutex_bucket_unlock( bucket );
/* Adjust new end of output buffer */
re = r + OT_SYNC_CHUNK_SIZE;
@@ -128,7 +119,7 @@ static void sync_make( int *iovec_entries, struct iovec **iovector ) {
*r++='e'; *r++='e';
/* Release unused memory in current output buffer */
- iovec_fixlast( iovec_entries, iovector, OT_SYNC_CHUNK_SIZE - ( re - r ) );
+ iovec_fixlast( iovec_entries, iovector, r );
}
/* This is the entry point into this worker thread