89 unsigned int percentage;
93 percentage = ( ( 100 * stats->
local ) / stats->
total );
95 "%3d%% from %d peers", percentage, stats->
peers );
150 DBGC ( peermux,
"PEERMUX %p could not parse content info: %s\n",
158 DBGC ( peermux,
"PEERMUX %p could not presize buffer: %s\n",
183 unsigned int next_segment;
184 unsigned int next_block;
196 next_block = (
block->index + 1 );
199 if ( next_block >=
segment->blocks ) {
210 if ( next_segment >=
info->segments ) {
219 next_segment ) ) != 0 ) {
220 DBGC (
peermux,
"PEERMUX %p could not get segment %d " 221 "information: %s\n",
peermux, next_segment,
229 DBGC (
peermux,
"PEERMUX %p could not get segment %d block " 237 DBGC (
peermux,
"PEERMUX %p skipping segment %d block %d\n",
245 DBGC (
peermux,
"PEERMUX %p could not start download for " 314 unsigned int count = 0;
326 DBGC2 ( peermux,
"PEERMUX %p downloaded %d/%d from %d peers\n",
static struct interface_operation peermux_xfer_operations[]
Data transfer interface operations.
An object interface operation.
uint16_t segment
Code segment.
static int peermux_block_deliver(struct peerdist_multiplexed_block *peermblk, struct io_buffer *iobuf, struct xfer_metadata *meta)
Receive data from multiplexed block download.
struct arbelprm_rc_send_wqe rc
void intf_close(struct interface *intf, int rc)
Close an object interface.
static void peermux_block_stat(struct peerdist_multiplexed_block *peermblk, struct peerdisc_peer *peer, struct list_head *peers)
Record peer discovery statistics.
void intf_restart(struct interface *intf, int rc)
Shut down and restart an object interface.
int xferbuf_deliver(struct xfer_buffer *xferbuf, struct io_buffer *iobuf, struct xfer_metadata *meta)
Add received data to data transfer buffer.
void intf_shutdown(struct interface *intf, int rc)
Shut down an object interface.
A content information segment.
static void uri_put(struct uri *uri)
Decrement URI reference count.
userptr_t data
Data buffer.
static struct uri * uri_get(struct uri *uri)
Increment URI reference count.
#define XFER_FL_ABS_OFFSET
Offset is absolute.
#define ref_init(refcnt, free)
Initialise a reference counter.
int peermux_filter(struct interface *xfer, struct interface *info, struct uri *uri)
Add PeerDist content-encoding filter.
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
int peerblk_open(struct interface *xfer, struct uri *uri, struct peerdist_info_block *block)
Open PeerDist block download.
void xferbuf_free(struct xfer_buffer *xferbuf)
Free data transfer buffer.
Uniform Resource Identifiers.
A PeerDist multiplexed block download.
unsigned int peers
Maximum observed number of peers.
void process_del(struct process *process)
Remove process from process list.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static struct interface_operation peermux_block_operations[]
Block download data transfer interface operations.
struct peerdist_info_cache cache
Content information cache.
A doubly-linked list entry (or list head)
static int peermux_info_deliver(struct peerdist_multiplexer *peermux, struct io_buffer *iobuf, struct xfer_metadata *meta)
Receive content information.
struct peerdist_multiplexer * peermux
PeerDist download multiplexer.
void peerdisc_stat(struct interface *intf, struct peerdisc_peer *peer, struct list_head *peers)
Report peer discovery statistics.
#define list_empty(list)
Test whether a list is empty.
#define list_first_entry(list, type, member)
Get the container of the first entry in a list.
static struct interface_descriptor peermux_info_desc
Content information interface descriptor.
A content information block.
A PeerDist download multiplexer.
#define list_del(list)
Delete an entry from a list.
unsigned int total
Number of blocks downloaded in total.
#define ENOMEM
Not enough space.
#define iob_disown(iobuf)
Disown an I/O buffer.
static void peermux_close(struct peerdist_multiplexer *peermux, int rc)
Close PeerDist download multiplexer.
Peer Content Caching and Retrieval (PeerDist) protocol multiplexer.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define container_of(ptr, type, field)
Get containing structure.
static void peermux_free(struct refcnt *refcnt)
Free PeerDist download multiplexer.
struct process process
Block download initiation process.
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
static void peermux_block_close(struct peerdist_multiplexed_block *peermblk, int rc)
Close multiplexed block download.
Peer Content Caching and Retrieval (PeerDist) protocol block downloads.
static int peermux_progress(struct peerdist_multiplexer *peermux, struct job_progress *progress)
Report progress of PeerDist download.
int xfer_seek(struct interface *intf, off_t offset)
Seek to position.
void process_add(struct process *process)
Add process to process list.
static struct interface_descriptor peermux_block_desc
Block download data transfer interface descriptor.
An object interface descriptor.
char * strerror(int errno)
Retrieve string representation of error number.
static void(* free)(struct refcnt *refcnt))
void * zalloc(size_t size)
Allocate cleared memory.
struct list_head list
List of multiplexed blocks.
struct peerdist_multiplexed_block block[PEERMUX_MAX_BLOCKS]
Block downloads.
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
int xfer_deliver(struct interface *intf, struct io_buffer *iobuf, struct xfer_metadata *meta)
Deliver datagram.
struct peerdist_info_block block
Content information block.
struct xfer_buffer * xfer_buffer(struct interface *intf)
Get underlying data transfer buffer.
static void process_init_stopped(struct process *process, struct process_descriptor *desc, struct refcnt *refcnt)
Initialise process without adding to process list.
struct refcnt refcnt
Reference count.
struct interface xfer
Data transfer interface.
struct list_head idle
List of idle block downloads.
static void xferbuf_umalloc_init(struct xfer_buffer *xferbuf, userptr_t *data)
Initialise umalloc()-based data transfer buffer.
char message[32]
Message (optional)
static struct process_descriptor peermux_process_desc
Block download initiation process descriptor.
#define INIT_LIST_HEAD(list)
Initialise a list head.
#define INTF_DESC(object_type, intf, operations)
Define an object interface descriptor.
struct peerdist_statistics stats
Statistics.
void intf_nullify(struct interface *intf)
Ignore all further operations on an object interface.
struct interface xfer
Data transfer interface.
#define PROC_DESC(object_type, process, _step)
Define a process descriptor.
static struct xfer_buffer * peermux_block_buffer(struct peerdist_multiplexed_block *peermblk)
Get multiplexed block download underlying data transfer buffer.
static void peermux_step(struct peerdist_multiplexer *peermux)
Initiate multiplexed block download.
uint16_t count
Number of entries.
static struct interface_descriptor peermux_xfer_desc
Data transfer interface descriptor.
struct peerdist_info_segment segment
Content information segment.
unsigned int local
Number of blocks downloaded from peers.
struct list_head busy
List of busy block downloads.
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
A Uniform Resource Identifier.
#define INTF_DESC_PASSTHRU(object_type, intf, operations, passthru)
Define an object interface descriptor with pass-through interface.
struct xfer_buffer buffer
Content information data transfer buffer.
#define PEERMUX_MAX_BLOCKS
Maximum number of concurrent block downloads.
static void peermux_info_close(struct peerdist_multiplexer *peermux, int rc)
Close content information interface.
struct peerdist_raw raw
Raw content information.
struct list_head list
List of peers.
struct interface info
Content information interface.
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
static struct interface_operation peermux_info_operations[]
Content information interface operations.
struct uri * uri
Original URI.
struct peerdist_info info
Content information.
#define ref_put(refcnt)
Drop reference to object.
A PeerDist discovery peer.