[Mono-dev] [PATCH] Network Performance Counters

Gonzalo Paniagua Javier gonzalo.mono at gmail.com
Tue Sep 29 03:03:51 EDT 2009

On Mon, 2009-09-28 at 22:11 -0400, Joel Reed wrote:
> The attached patch implements 3 "Network Interface" performance category 
> counters. The counters are "Bytes Received/sec", "Bytes Sent/sec", and 
> "Bytes Total/sec". A sample program using these counters and sample 
> output is attached as well.
> This information is obtained by reading /proc/net/dev.

The value returned by mono_networkinterface_list() is not freed
properly. In get_networkinterface_instance() you do:
	g_free (buf);
but it should be something like:
	for (i = 0; i < count; i++)
		g_free (buf [i]);

I would make mono_networkinterface_list() return a null-terminated array
and then use g_strfreev () on it.

As for mono_networkinterface_list(), I think it belongs somewhere else
perhaps utils/mono-networkinterfaces.c or in io-layer. If you want to go
the io-layer route:
mono_networkinterface_list => WSAIoctl(SIO_GET_INTERFACE_LIST_EX)
mono_network_get_data => GetIfTable() from Iphlpapi.dll

This way it would work in windows and linux by now and future additions
should stick to the same interface.


More information about the Mono-devel-list mailing list