Dolda2000 GitWeb
/
doldaconnect.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0e238ce
)
Made the UI reader a bit more resilient to faulty clients.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Sun, 24 Feb 2008 05:05:23 +0000
(06:05 +0100)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Sun, 24 Feb 2008 05:05:23 +0000
(06:05 +0100)
daemon/ui.c
patch
|
blob
|
blame
|
history
diff --git
a/daemon/ui.c
b/daemon/ui.c
index
9c63071
..
01e1a52
100644
(file)
--- a/
daemon/ui.c
+++ b/
daemon/ui.c
@@
-118,6
+118,7
@@
struct uidata
struct uidata *next, *prev;
struct socket *sk;
struct qcommand *queue, *queuelast;
struct uidata *next, *prev;
struct socket *sk;
struct qcommand *queue, *queuelast;
+ size_t queuesize;
struct authhandle *auth;
int close;
union
struct authhandle *auth;
int close;
union
@@
-704,7
+705,7
@@
static void cmd_lspeers(struct socket *sk, struct uidata *data, int argc, wchar_
}
if(fn->peers == NULL)
{
}
if(fn->peers == NULL)
{
- sq(sk, 0, L"201", L"No peers avaiable", NULL);
+ sq(sk, 0, L"201", L"No peers avai
l
able", NULL);
} else {
for(peer = btreeiter(fn->peers); peer != NULL; peer = npeer)
{
} else {
for(peer = btreeiter(fn->peers); peer != NULL; peer = npeer)
{
@@
-1421,6
+1422,7
@@
static struct qcommand *unlinkqcmd(struct uidata *data)
qcmd = data->queue;
if(qcmd != NULL)
{
qcmd = data->queue;
if(qcmd != NULL)
{
+ data->queuesize--;
data->queue = qcmd->next;
if(qcmd == data->queuelast)
data->queuelast = qcmd->next;
data->queue = qcmd->next;
if(qcmd == data->queuelast)
data->queuelast = qcmd->next;
@@
-1611,6
+1613,7
@@
static void queuecmd(struct uidata *data, struct command *cmd, int argc, wchar_t
data->queuelast = new;
if(data->queue == NULL)
data->queue = new;
data->queuelast = new;
if(data->queue == NULL)
data->queue = new;
+ data->queuesize++;
}
static struct uidata *newuidata(struct socket *sk)
}
static struct uidata *newuidata(struct socket *sk)
@@
-1803,6
+1806,11
@@
static void uiread(struct socket *sk, struct uidata *data)
break;
}
}
break;
}
}
+ if(data->cbdata > 16384)
+ {
+ /* Kill clients that send us unreasonably long lines */
+ data->close = 1;
+ }
}
static void uierror(struct socket *sk, int err, struct uidata *data)
}
static void uierror(struct socket *sk, int err, struct uidata *data)
@@
-2400,6
+2408,15
@@
static int run(void)
freequeuecmd(qcmd);
return(1);
}
freequeuecmd(qcmd);
return(1);
}
+ if(data->queuesize > 10)
+ {
+ /* Clients should not be queue up commands at all, since
+ * they should not send a new command before receiving a
+ * reply to the previous command. Therefore, we
+ * mercilessly massacre clients which are stacking up too
+ * many commands. */
+ data->close = 1;
+ }
}
return(0);
}
}
return(0);
}