Example #1
0
static struct mbuf *
rr_dequeue(struct dn_sch_inst *_si)
{
	/* Access scheduler instance private data */
	struct rr_si *si = (struct rr_si *)(_si + 1);
	struct rr_queue *rrq;
	uint64_t len;

	while ( (rrq = si->head) ) {
		struct mbuf *m = rrq->q.mq.head;
		if ( m == NULL) {
			/* empty queue, remove from list */
			rr_remove_head(si);
			continue;
		}
		len = m->m_pkthdr.len;

		if (len > rrq->credit) {
			/* Packet too big */
			rrq->credit += rrq->quantum;
			/* Try next queue */
			next_pointer(si);
		} else {
			rrq->credit -= len;
			return dn_dequeue(&rrq->q);
		}
	}

	/* no packet to dequeue*/
	return NULL;
}
Example #2
0
int next_geometry(GEOSCommand *command, GEOSGeometry** geom) {
	//long type;
	void *geom_ptr;

	if(next_pointer(command, 2, "ggeom", &geom_ptr)) {
		return -1;
	}
	
	//read the geometry type for sanity purpose
/*	
	if(ei_decode_long(command->param_bytes, &command->index, &type)) {
		return -1;
	}

	switch((int) type) {
		case GEOS_POINT:
    		case GEOS_LINESTRING:
    		case GEOS_LINEARRING:
    		case GEOS_POLYGON:
    		case GEOS_MULTIPOINT:
    		case GEOS_MULTILINESTRING:
    		case GEOS_MULTIPOLYGON:
    		case GEOS_GEOMETRYCOLLECTION: break;
		default:
			return -1;
	}*/
	*geom = (GEOSGeometry *)geom_ptr;

	return 0;
}
Example #3
0
int next_wktwriter(GEOSCommand *command, GEOSWKTWriter** writer) {
	void *writer_ptr;
	if(next_pointer(command, 2, "gwktwriter", &writer_ptr)) {
		return -1;
	}
	*writer = (GEOSWKTWriter *)writer_ptr;
	return 0;
}
Example #4
0
int next_coordsequence(GEOSCommand *command, GEOSCoordSequence** seq) {
	void *seq_ptr;
	if(next_pointer(command, 2, "gcoordseq", &seq_ptr)) {
		return -1;
	}
	*seq = (GEOSCoordSequence *)seq_ptr;
	return 0;
}
Example #5
0
int next_prepared_geometry(GEOSCommand *command, GEOSPreparedGeometry** geom) {
	void *geom_ptr;
	if(next_pointer(command, 2, "gpreparedgeom", &geom_ptr)) {
		return -1;
	}
	*geom = (GEOSPreparedGeometry *)geom_ptr;
	return 0;
}
Example #6
0
int next_wkbreader(GEOSCommand *command, GEOSWKBReader** reader) {
	void *reader_ptr;
	int p = next_pointer(command, 2, "gwkbreader", &reader_ptr);
	if(p) {
		return p;
	}
	*reader = (GEOSWKBReader *)reader_ptr;
	return 0;
}