#include "transfer.h"
#include "sysevents.h"
#include "net.h"
-#include "tiger.h"
+#include <tiger.h>
/*
* The Direct Connect protocol is extremely ugly. Thus, this code must
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);
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)
{
} 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);
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)
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 {
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;
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);
}