X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=daemon%2Ffilenet.c;h=82ed1d2a571d6624f958bdffe7040473dba51051;hb=ffa81d5f0167a81cc81e9eec69062f0aeaf7754a;hp=be6c5affb86292b58eaa592381ebe4967e938ad9;hpb=a3a4a3a7ae1030512acfd849bb184b9d2264c24d;p=doldaconnect.git diff --git a/daemon/filenet.c b/daemon/filenet.c index be6c5af..82ed1d2 100644 --- a/daemon/filenet.c +++ b/daemon/filenet.c @@ -1,6 +1,6 @@ /* * Dolda Connect - Modular multiuser Direct Connect-style client - * Copyright (C) 2004 Fredrik Tolf (fredrik@dolda2000.com) + * Copyright (C) 2004 Fredrik Tolf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -64,17 +64,8 @@ static struct fnetnode *newfn(struct fnet *fnet) void killfnetnode(struct fnetnode *fn) { fnetsetstate(fn, FNN_DEAD); - if(fn->sk != NULL) - { - fn->sk->close = 1; - if(fn->sk->data == fn) - { - fn->sk->data = NULL; - putfnetnode(fn); - } - putsock(fn->sk); - fn->sk = NULL; - } + if(fn->connected) + fn->fnet->kill(fn); } void getfnetnode(struct fnetnode *fn) @@ -107,7 +98,7 @@ void putfnetnode(struct fnetnode *fn) CBCHAINFREE(fn, fnetpeer_new); CBCHAINFREE(fn, fnetpeer_del); CBCHAINFREE(fn, fnetpeer_chdi); - if(fn->fnet->destroy != NULL) + if((fn->fnet->destroy != NULL) && fn->connected) fn->fnet->destroy(fn); while(fn->args != NULL) freewcspair(fn->args, &fn->args); @@ -119,8 +110,6 @@ void putfnetnode(struct fnetnode *fn) free(fn->pubid); if(fn->name != NULL) free(fn->name); - if(fn->sk != NULL) - putsock(fn->sk); if(fn->owner != NULL) free(fn->owner); free(fn); @@ -171,11 +160,12 @@ static void conncb(struct socket *sk, int err, struct fnetnode *data) putfnetnode(data); return; } - data->sk = sk; fnetsetstate(data, FNN_HS); socksettos(sk, confgetint("fnet", "fntos")); - data->fnet->connect(data); + data->fnet->connect(data, sk); + data->connected = 1; putfnetnode(data); + putsock(sk); } static void resolvecb(struct sockaddr *addr, int addrlen, struct fnetnode *data) @@ -387,7 +377,7 @@ int fnetsetnick(struct fnetnode *fn, wchar_t *newnick) { int ret; - if(fn->fnet->setnick != NULL) + if((fn->fnet->setnick != NULL) && fn->connected) ret = fn->fnet->setnick(fn, newnick); else ret = 0; @@ -402,7 +392,7 @@ int fnetsetnick(struct fnetnode *fn, wchar_t *newnick) int fnetsendchat(struct fnetnode *fn, int public, wchar_t *to, wchar_t *string) { - if(fn->fnet->sendchat == NULL) + if((fn->fnet->sendchat == NULL) || !fn->connected) { errno = ENOTSUP; return(-1); @@ -502,9 +492,25 @@ void fnethandlechat(struct fnetnode *fn, int public, wchar_t *name, wchar_t *pee static struct configvar myvars[] = { + /** The number of seconds to wait between searches. Most hubs + * require at least ten seconds, and quite often network lag will + * often make searches arrive to the hub more often than sent. It + * may be semi-dangerous to specify too low a value, since hubs + * will often kick users that search too often (even when the + * reason is network lag -- there is no way for the hub to know + * this), but it is quite annoying to set too high a value. 15 to + * 40 seconds are the recommended range (although the default is + * 15 seconds, it is recommended to set to 30 seconds). */ {CONF_VAR_INT, "srchwait", {.num = 15}}, + /** The TOS value to use for hub connections (see the TOS VALUES + * section). */ {CONF_VAR_INT, "fntos", {.num = 0}}, + /** The TOS value to use for peer connections (see the TOS VALUES + * section). */ {CONF_VAR_INT, "fnptos", {.num = 0}}, + /** Specifies a maximum number of simultaneously connected + * hubs. Attempts to connect to new hubs beyond this limit will + * return an error. Set to zero to remove the limit. */ {CONF_VAR_INT, "maxnodes", {.num = 0}}, {CONF_VAR_END} };