summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2012-04-11 19:07:37 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2012-04-11 19:07:37 +0800
commit61e4bb73c9ca74ac320f6206bcf6378239c48cbc (patch)
treefa3a39b34e7440c9c910423e2dd2e292b87f994b
parentb8059d964b2e009a0b8837614244d426a6a27a74 (diff)
downloadpttbbs-61e4bb73c9ca74ac320f6206bcf6378239c48cbc.tar
pttbbs-61e4bb73c9ca74ac320f6206bcf6378239c48cbc.tar.gz
pttbbs-61e4bb73c9ca74ac320f6206bcf6378239c48cbc.tar.bz2
pttbbs-61e4bb73c9ca74ac320f6206bcf6378239c48cbc.tar.lz
pttbbs-61e4bb73c9ca74ac320f6206bcf6378239c48cbc.tar.xz
pttbbs-61e4bb73c9ca74ac320f6206bcf6378239c48cbc.tar.zst
pttbbs-61e4bb73c9ca74ac320f6206bcf6378239c48cbc.zip
Redefine request buffer size
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5622 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--pttbbs/daemon/logind/logind.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/pttbbs/daemon/logind/logind.c b/pttbbs/daemon/logind/logind.c
index acaa6aec..0c56602a 100644
--- a/pttbbs/daemon/logind/logind.c
+++ b/pttbbs/daemon/logind/logind.c
@@ -64,6 +64,10 @@
#define LOGIND_ACKQUEUE_BOUND (255)
#endif
+#ifndef LOGIND_TUNNEL_BUFFER_BOUND
+#define LOGIND_TUNNEL_BUFFER_BOUND (65530)
+#endif
+
#define MY_EVENT_PRIORITY_NUMBERS (4)
#define EVTPRIORITY_NORM (MY_EVENT_PRIORITY_NUMBERS/2)
#define EVTPRIORITY_ACK (EVTPRIORITY_NORM-1)
@@ -1089,19 +1093,26 @@ is_tunnel_available() {
int nwrite = 0, sndbuf = 0;
socklen_t len = 0;
+ // for each client we need to send two kinds of data:
+ // send_remote_fd: struct msghdr + char[CMSG_SPACE(sizeof(int))];
+ // towrite: sizeof(login_data)
+ // However, it's hard to estimate how much sendmsg() needs.
+
if (ackq_size() > LOGIND_ACKQUEUE_BOUND)
return 0;
+#ifdef LOGIND_TUNNEL_BUFFER_BOUND
ioctl(g_tunnel, FIONWRITE, &nwrite);
len = sizeof(sndbuf);
getsockopt(g_tunnel, SOL_SOCKET, SO_SNDBUF, &sndbuf, &len);
- if (sndbuf >= nwrite && (sndbuf - nwrite) < (int)sizeof(login_data) * 5) {
+ if (sndbuf >= nwrite && (sndbuf - nwrite) < LOGIND_TUNNEL_BUFFER_BOUND) {
time4_t now = time(NULL);
fprintf(stderr, LOG_PREFIX "%s tunnel buffer is full (%d/%d)\n",
Cdate(&now), nwrite, sndbuf);
return 0;
}
+#endif
return 1;
}