This chapter describes describes some hints for developers.
There is not so much to say about that, just take a look at the existing
source files.
The Tab-Width is eight with an indent of two. Please make a space between
operators and operands.
NEVER call NgFuncGetStats() with the clear parameter set to true, because there are other functions (echo requests/replies, bandwidth management) wich relies on increasing link-stats. Mpd carries a copy of the netgraph link-stats at link-level, just use these instead. You can call LinkUpdateStats() for updating the internal stats-struct.
Authentication backends must run independently from the rest of Mpd, i.e.
you must not access the global bund
, link
or any other
global ressource of Mpd, because
the authentication process is started in its own thread (you have to
take care about thread-safety). An AuthData
object is passed
to your authenticating function which carries a copy of the link and other
parameters. If your backend provides other parameters, like MTU, IP, etc.
then put these at the appropriate place into AuthData
or
Auth
. To be sure to not accidentally accessing the global
lnk
, use something like this:
static int WhateverAuthenticate(AuthData auth) { Link const lnk = auth->lnk; /* hide the global "lnk" */ Auth const a = &lnk->lcp.auth; [...]
[...] pthread_mutex_lock(&gGiantMutex); [do whatever] pthread_mutex_unlock(&gGiantMutex); [...]
bund
, because it may be changed in the
meantime, use the pointer provided by the link:
Bund const bund = auth->lnk->bund; /* hide the global "bund" */
auth->lnk->bund
is NOT thread-safe.