summaryrefslogtreecommitdiff
path: root/ot_sync.c
diff options
context:
space:
mode:
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 ) {
96 /* If we reached our low watermark in buffer... */ 96 /* If we reached our low watermark in buffer... */
97 if( re - r <= (ssize_t)(/* strlen( "20:" ) == */ 3 + sizeof( ot_hash ) + /* strlen_max( "%zd" ) == */ 12 + byte_count ) ) { 97 if( re - r <= (ssize_t)(/* strlen( "20:" ) == */ 3 + sizeof( ot_hash ) + /* strlen_max( "%zd" ) == */ 12 + byte_count ) ) {
98 98
99 /* crop current output buffer to the amount really used */ 99 /* Allocate a fresh output buffer at the end of our buffers list
100 iovec_fixlast( iovec_entries, iovector, OT_SYNC_CHUNK_SIZE - ( re - r ) ); 100 release bucket and return, if that fails */
101 101 if( !( r = iovec_fix_increase_or_free( iovec_entries, iovector, r, OT_SYNC_CHUNK_SIZE ) ) )
102 /* And allocate a fresh output buffer at the end of our buffers list */ 102 return mutex_bucket_unlock( bucket );
103 if( !( r = iovec_increase( iovec_entries, iovector, OT_SYNC_CHUNK_SIZE ) ) ) {
104
105 /* If this fails: free buffers */
106 iovec_free( iovec_entries, iovector );
107
108 /* Release lock on current bucket and return */
109 mutex_bucket_unlock( bucket );
110 return;
111 }
112 103
113 /* Adjust new end of output buffer */ 104 /* Adjust new end of output buffer */
114 re = r + OT_SYNC_CHUNK_SIZE; 105 re = r + OT_SYNC_CHUNK_SIZE;
@@ -128,7 +119,7 @@ static void sync_make( int *iovec_entries, struct iovec **iovector ) {
128 *r++='e'; *r++='e'; 119 *r++='e'; *r++='e';
129 120
130 /* Release unused memory in current output buffer */ 121 /* Release unused memory in current output buffer */
131 iovec_fixlast( iovec_entries, iovector, OT_SYNC_CHUNK_SIZE - ( re - r ) ); 122 iovec_fixlast( iovec_entries, iovector, r );
132} 123}
133 124
134/* This is the entry point into this worker thread 125/* This is the entry point into this worker thread