X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=daemon%2Ffnet-dc.c;h=d45b14489c9afa97d12aaacb0d31b985d2d1d680;hb=175c86de77cd5e6d447cfba50dc8f755db87eb16;hp=ee5e423977e8fd8e7316fba99569ad2b004850e2;hpb=8b93008567ad48a8c79d57da3ea27e91d7173472;p=doldaconnect.git diff --git a/daemon/fnet-dc.c b/daemon/fnet-dc.c index ee5e423..d45b144 100644 --- a/daemon/fnet-dc.c +++ b/daemon/fnet-dc.c @@ -44,7 +44,7 @@ #include "transfer.h" #include "sysevents.h" #include "net.h" -#include "tiger.h" +#include /* * The Direct Connect protocol is extremely ugly. Thus, this code must @@ -158,6 +158,7 @@ static struct dcexppeer *expected = NULL; static char *hmlistname = NULL; static char *xmllistname = NULL; static char *xmlbz2listname = NULL; +static struct timer *listwritetimer = NULL; static void peerconnect(struct socket *sk, int err, struct fnetnode *fn); static void freedcpeer(struct dcpeer *peer); @@ -168,6 +169,7 @@ static void updatehmlist(void); static void updatexmllist(void); static void updatexmlbz2list(void); static void requestfile(struct dcpeer *peer); +static void updatelists(int now); static int reservedchar(unsigned char c) { @@ -1017,7 +1019,7 @@ static void cmd_forcemove(struct socket *sk, struct fnetnode *fn, char *cmd, cha } else { freeargs = 0; } - if((newfn = fnetinitconnect(L"dc", args, NULL)) != NULL) + if((newfn = fnetinitconnect(L"dc", fn->owner, args, NULL)) != NULL) { linkfnetnode(newfn); putfnetnode(newfn); @@ -1310,7 +1312,7 @@ static void sendctm(struct socket *sk, char *nick) if(tcpsock == NULL) return; - if(sockgetremotename(sk, &addr, &addrlen) < 0) + if(sockgetremotename2(tcpsock, sk, &addr, &addrlen) < 0) return; if(addr->sa_family == AF_INET) qstrf(sk, "$ConnectToMe %s %s|", nick, formataddress(addr, addrlen)); @@ -1545,6 +1547,11 @@ static void cmd_direction(struct socket *sk, struct dcpeer *peer, char *cmd, cha peer->direction = mydir; if(peer->direction == TRNSD_UP) { + if(confgetint("transfer", "ulquota") && hasupload(&dcnet, peer->wcsname)) + { + freedcpeer(peer); + return; + } transfer = newupload(peer->fn, &dcnet, peer->wcsname, &dctransfer, peer); } else { if((transfer = finddownload(peer->wcsname)) == NULL) @@ -1591,6 +1598,11 @@ static void cmd_peerlock(struct socket *sk, struct dcpeer *peer, char *cmd, char sendsupports(peer); if((transfer = finddownload(peer->wcsname)) == NULL) { + if(confgetint("transfer", "ulquota") && hasupload(&dcnet, peer->wcsname)) + { + freedcpeer(peer); + return; + } peer->direction = TRNSD_UP; transfer = newupload(peer->fn, &dcnet, peer->wcsname, &dctransfer, peer); } else { @@ -2415,8 +2427,10 @@ static struct hash *findsehash(struct sexpr *sexpr) return(h1); break; case SOP_OR: - h1 = findsehash(sexpr->l); - h2 = findsehash(sexpr->r); + if((h1 = findsehash(sexpr->l)) == NULL) + return(NULL); + if((h2 = findsehash(sexpr->r)) == NULL) + return(NULL); if(hashcmp(h1, h2)) return(h1); break; @@ -2519,7 +2533,7 @@ static int hubsearch(struct fnetnode *fn, struct search *srch, struct srchfnnlis addtobuf(sstr, 0); if(tcpsock != NULL) { - if(sockgetremotename(fn->sk, &name, &namelen) < 0) + if(sockgetremotename2(udpsock, fn->sk, &name, &namelen) < 0) { flog(LOG_WARNING, "cannot get address of UDP socket"); } else { @@ -3502,11 +3516,33 @@ static void updatexmlbz2list(void) fclose(real); } -static int shareupdate(unsigned long long uusharesize, void *data) +static void listtimercb(int cancelled, void *uudata) { + listwritetimer = NULL; + if(!cancelled) + updatelists(1); +} + +static void updatelists(int now) +{ + if((hmlistname == NULL) || (xmllistname == NULL) || (xmlbz2listname == NULL)) + now = 1; + if(!now) + { + if(listwritetimer == NULL) + listwritetimer = timercallback(ntime() + 300, listtimercb, NULL); + return; + } + if(listwritetimer != NULL) + canceltimer(listwritetimer); updatehmlist(); updatexmllist(); updatexmlbz2list(); +} + +static int shareupdate(unsigned long long uusharesize, void *data) +{ + updatelists(0); return(0); }