"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libisofs/buffer.c" between
xorriso-1.5.2.tar.gz and xorriso-1.5.4.tar.gz

About: GNU xorriso creates, loads, manipulates and writes ISO 9660 filesystem images with Rock Ridge extensions. It is suitable for incremental data backup and for production of bootable ISO 9660 images. GNU xorriso is a statical compilation of the libraries libburn, libisofs, libisoburn, and libjte.

buffer.c  (xorriso-1.5.2):buffer.c  (xorriso-1.5.4)
skipping to change at line 15 skipping to change at line 15
* modify it under the terms of the GNU General Public License version 2 * modify it under the terms of the GNU General Public License version 2
* or later as published by the Free Software Foundation. * or later as published by the Free Software Foundation.
* See COPYING file for details. * See COPYING file for details.
*/ */
/* /*
* Synchronized ring buffer, works with a writer thread and a read thread. * Synchronized ring buffer, works with a writer thread and a read thread.
* *
* TODO #00010 : optimize ring buffer * TODO #00010 : optimize ring buffer
* - write/read at the end of buffer requires a second mutex_lock, even if * - write/read at the end of buffer requires a second mutex_lock, even if
* there's enought space/data at the beginning * there's enough space/data at the beginning
* - pre-buffer for writes < BLOCK_SIZE * - pre-buffer for writes < BLOCK_SIZE
* *
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "../config.h" #include "../config.h"
#endif #endif
/* /*
Use the copy of the struct burn_source definition in libisofs.h Use the copy of the struct burn_source definition in libisofs.h
skipping to change at line 148 skipping to change at line 148
* reader close the buffer. * reader close the buffer.
* *
* @param buf * @param buf
* the buffer * the buffer
* @param data * @param data
* pointer to a memory region of at least coun bytes, from which data * pointer to a memory region of at least coun bytes, from which data
* will be read. * will be read.
* @param * @param
* Number of bytes to write * Number of bytes to write
* @return * @return
* 1 succes, 0 read finished, < 0 error * 1 success, 0 read finished, < 0 error
*/ */
int iso_ring_buffer_write(IsoRingBuffer *buf, uint8_t *data, size_t count) int iso_ring_buffer_write(IsoRingBuffer *buf, uint8_t *data, size_t count)
{ {
size_t len; size_t len;
size_t bytes_write = 0; size_t bytes_write = 0;
if (buf == NULL || data == NULL) { if (buf == NULL || data == NULL) {
return ISO_NULL_POINTER; return ISO_NULL_POINTER;
} }
while (bytes_write < count) { while (bytes_write < count) {
pthread_mutex_lock(&buf->mutex); pthread_mutex_lock(&buf->mutex);
while (buf->size == buf->cap) { while (buf->size == buf->cap) {
/* /*
* Note. There's only a writer, so we have no race conditions. * Note. There's only a writer, so we have no race conditions.
* Thus, the while(buf->size == buf->cap) is used here * Thus, the while(buf->size == buf->cap) is used here
* only to propertly detect the reader has been cancelled * only to properly detect the reader has been cancelled
*/ */
if (buf->rend) { if (buf->rend) {
/* the read procces has been finished */ /* the read procces has been finished */
pthread_mutex_unlock(&buf->mutex); pthread_mutex_unlock(&buf->mutex);
return 0; return 0;
} }
buf->times_full++; buf->times_full++;
/* wait until space available */ /* wait until space available */
pthread_cond_wait(&buf->full, &buf->mutex); pthread_cond_wait(&buf->full, &buf->mutex);
skipping to change at line 199 skipping to change at line 199
/* wake up reader */ /* wake up reader */
pthread_cond_signal(&buf->empty); pthread_cond_signal(&buf->empty);
pthread_mutex_unlock(&buf->mutex); pthread_mutex_unlock(&buf->mutex);
} }
return ISO_SUCCESS; return ISO_SUCCESS;
} }
/** /**
* Read count bytes from the buffer into dest. It blocks until the desired * Read count bytes from the buffer into dest. It blocks until the desired
* bytes has been read. If the writer finishes before outputting enought * bytes has been read. If the writer finishes before outputting enough
* bytes, 0 (EOF) is returned, the number of bytes already read remains * bytes, 0 (EOF) is returned, the number of bytes already read remains
* unknown. * unknown.
* *
* @return * @return
* 1 success, 0 EOF, < 0 error * 1 success, 0 EOF, < 0 error
*/ */
int iso_ring_buffer_read(IsoRingBuffer *buf, uint8_t *dest, size_t count) int iso_ring_buffer_read(IsoRingBuffer *buf, uint8_t *dest, size_t count)
{ {
size_t len; size_t len;
size_t bytes_read = 0; size_t bytes_read = 0;
skipping to change at line 222 skipping to change at line 222
return ISO_NULL_POINTER; return ISO_NULL_POINTER;
} }
while (bytes_read < count) { while (bytes_read < count) {
pthread_mutex_lock(&buf->mutex); pthread_mutex_lock(&buf->mutex);
while (buf->size == 0) { while (buf->size == 0) {
/* /*
* Note. There's only a reader, so we have no race conditions. * Note. There's only a reader, so we have no race conditions.
* Thus, the while(buf->size == 0) is used here just to ensure * Thus, the while(buf->size == 0) is used here just to ensure
* a reader detects the EOF propertly if the writer has been * a reader detects the EOF properly if the writer has been
* canceled while the reader was waiting * canceled while the reader was waiting
*/ */
if (buf->wend) { if (buf->wend) {
/* the writer procces has been finished */ /* the writer procces has been finished */
pthread_mutex_unlock(&buf->mutex); pthread_mutex_unlock(&buf->mutex);
return 0; /* EOF */ return 0; /* EOF */
} }
buf->times_empty++; buf->times_empty++;
/* wait until data available */ /* wait until data available */
 End of changes. 5 change blocks. 
5 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)