Vanilla Netrek Server Development Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[VANILLA-L:1051] Re: Client to Metaserver Recoding Patch V1.0
> I expect one metaserver to take it on, and to advise the others once it
> is proven.
Its up and running on metaserver2.us.netrek.org. Try to break it.
> I'm not exactly ecstatic about the code I wrote in disp_udp.c, but I've
> sat on it for long enough that it needs airing and production testing.
> It has hasty memory estimation logic which might bite me later.
Which part? this one:
buffer = malloc((MAX_HOSTNAME+1 +6+1 +3+1 +6+1 +3+1 +3+1 +1+1 +1)*count+6);
/* host port stat age play que type \n */
Lessee. You're allocating a buffer just big enough to hold all the data to
send to the client.
MAX_HOSTNAME, plus a comma, 6 digit port, plus a comma, 6 digit age,
plus a comma, 3 digit players, plus a comma, 3 digit queue, plus a comma,
and finally a 1 character type finished off with a newline. Multiply
by the number of servers to send and add 6.
You've got 1 extra byte for MAX_HOSTNAME. An array MAX_HOSTNAME big
holds a string MAX_HOSTNAME-1 characters + a null (if you expect it to
work with sprintf).
Maybe 1 extra digit for the port if ports are only 16 bit integers. I
forget.
6 digits for age. Well I guess we metaserver admins have to poll more
than once every 11 days *grin*. Is there a timeout defined for
undisplaying servers who haven't done metaserver solicit for a while?
At any rate, might do a bounds check on that one. That one just might
kill you, but you've got a lot of slop to cover.
3 digits for players. Lets hope paradise doesn't get to out of hand!
*grin* Seems fine.
3 digits for the queue. Same as above.
1 for the type. Hmmm. might limit future expandability. Might want
to make the type field size in the SERVER struct a #define and use the
same #define in your malloc.
the +6. 5 digit server count + newline. Ok. I guess.
--Carlos V.
+
++ Vanilla-l Mailing List ++
To unsubscribe: send "unsubscribe vanilla-l" to majordomo@real-time.com
For more information: http://archives.real-time.com
References: