Move requested payload queue into frame structure

This commit is contained in:
Jeremy Lakeman 2012-10-09 15:44:37 +10:30
parent 9842e22353
commit e28deeb6d5
7 changed files with 27 additions and 23 deletions

View File

@ -549,7 +549,8 @@ int send_please_explain(struct decode_context *context, struct subscriber *sourc
}
DEBUGF("Queued please explain");
if (!overlay_payload_enqueue(OQ_MESH_MANAGEMENT, context->please_explain))
context->please_explain->queue=OQ_MESH_MANAGEMENT;
if (!overlay_payload_enqueue(context->please_explain))
return 0;
op_free(context->please_explain);
return 0;

View File

@ -911,16 +911,16 @@ int overlay_mdp_dispatch(overlay_mdp_frame *mdp,int userGeneratedFrameP,
}
// TODO include priority in packet header
int qn=OQ_ORDINARY;
frame->queue=OQ_ORDINARY;
/* Make sure voice traffic gets priority */
if ((frame->type&OF_TYPE_BITS)==OF_TYPE_DATA_VOICE) {
qn=OQ_ISOCHRONOUS_VOICE;
frame->queue=OQ_ISOCHRONOUS_VOICE;
rhizome_saw_voice_traffic();
}
frame->send_copies = mdp->out.send_copies;
if (overlay_payload_enqueue(qn, frame))
if (overlay_payload_enqueue(frame))
op_free(frame);
RETURN(0);
}

View File

@ -31,6 +31,7 @@ struct overlay_frame {
unsigned int modifiers;
unsigned char ttl;
unsigned char queue;
// temporary hack to improve reliability before implementing per-packet nack's
int send_copies;

View File

@ -93,14 +93,14 @@ int overlay_forward_payload(struct overlay_frame *f){
return WHY("Could not clone frame for queuing");
// TODO include priority in packet header
int qn=OQ_ORDINARY;
qf->queue=OQ_ORDINARY;
/* Make sure voice traffic gets priority */
if ((qf->type&OF_TYPE_BITS)==OF_TYPE_DATA_VOICE) {
qn=OQ_ISOCHRONOUS_VOICE;
qf->queue=OQ_ISOCHRONOUS_VOICE;
rhizome_saw_voice_traffic();
}
if (overlay_payload_enqueue(qn,qf)) {
if (overlay_payload_enqueue(qf)) {
op_free(qf);
return WHY("failed to enqueue forwarded payload");
}

View File

@ -177,7 +177,7 @@ int dump_payload(struct overlay_frame *p, char *message)
return 0;
}
int overlay_payload_enqueue(int q, struct overlay_frame *p)
int overlay_payload_enqueue(struct overlay_frame *p)
{
/* Add payload p to queue q.
@ -195,14 +195,15 @@ int overlay_payload_enqueue(int q, struct overlay_frame *p)
return WHYF("Destination %s is unreachable (%d)", alloca_tohex_sid(p->destination->sid), r);
}
if (p->queue<0||p->queue>=OQ_MAX)
return WHY("Invalid queue specified");
overlay_txqueue *queue = &overlay_tx[p->queue];
if (debug&DEBUG_PACKETTX)
DEBUGF("Enqueuing packet for %s* (q[%d]length = %d)",
p->destination?alloca_tohex(p->destination->sid, 7): alloca_tohex(p->broadcast_id.id,BROADCAST_LEN),
q,overlay_tx[q].length);
if (q<0||q>=OQ_MAX)
return WHY("Invalid queue specified");
p->queue, queue->length);
if (p->payload && p->payload->position > p->payload->sizeLimit){
// HACK, maybe should be done in each caller
@ -210,8 +211,8 @@ int overlay_payload_enqueue(int q, struct overlay_frame *p)
p->payload->sizeLimit=p->payload->position;
}
if (overlay_tx[q].length>=overlay_tx[q].maxLength)
return WHYF("Queue #%d congested (size = %d)",q,overlay_tx[q].maxLength);
if (queue->length>=queue->maxLength)
return WHYF("Queue #%d congested (size = %d)",p->queue,queue->maxLength);
if (p->send_copies<=0)
p->send_copies=1;
@ -242,19 +243,19 @@ int overlay_payload_enqueue(int q, struct overlay_frame *p)
p->sendBroadcast=1;
}
struct overlay_frame *l=overlay_tx[q].last;
struct overlay_frame *l=queue->last;
if (l) l->next=p;
p->prev=l;
p->next=NULL;
p->enqueued_at=gettime_ms();
overlay_tx[q].last=p;
if (!overlay_tx[q].first) overlay_tx[q].first=p;
overlay_tx[q].length++;
queue->last=p;
if (!queue->first) queue->first=p;
queue->length++;
overlay_update_queue_schedule(&overlay_tx[q], p);
overlay_update_queue_schedule(queue, p);
if (0) dump_queue("after",q);
if (0) dump_queue("after",p->queue);
return 0;
}

View File

@ -303,7 +303,8 @@ int overlay_route_ack_selfannounce(struct overlay_frame *f,
/* Add to queue. Keep broadcast status that we have assigned here if required to
get ack back to sender before we have a route. */
if (overlay_payload_enqueue(OQ_MESH_MANAGEMENT,out))
out->queue=OQ_MESH_MANAGEMENT;
if (overlay_payload_enqueue(out))
{
op_free(out);
return WHY("overlay_payload_enqueue(self-announce ack) failed");

View File

@ -640,7 +640,7 @@ unsigned int overlay_route_hash_sid(const unsigned char *sid);
int packetEncipher(unsigned char *packet,int maxlen,int *len,int cryptoflags);
int overlayServerMode();
int overlay_payload_enqueue(int q, struct overlay_frame *p);
int overlay_payload_enqueue(struct overlay_frame *p);
int overlay_route_record_link( time_ms_t now,unsigned char *to,
unsigned char *via,int sender_interface,
unsigned int s1,unsigned int s2,int score,int gateways_en_route);