summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-06-14 10:16:11 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-06-14 10:16:11 +0800
commit7f1fa71a2d329c9d7cfa6ff8c6b64d1cfdc16922 (patch)
treed2a184d18e8dfff68b1ec668959c129375f05afd
parent26457224ae293ff28627feab8a620f8c7df013e9 (diff)
downloadpttbbs-7f1fa71a2d329c9d7cfa6ff8c6b64d1cfdc16922.tar
pttbbs-7f1fa71a2d329c9d7cfa6ff8c6b64d1cfdc16922.tar.gz
pttbbs-7f1fa71a2d329c9d7cfa6ff8c6b64d1cfdc16922.tar.bz2
pttbbs-7f1fa71a2d329c9d7cfa6ff8c6b64d1cfdc16922.tar.lz
pttbbs-7f1fa71a2d329c9d7cfa6ff8c6b64d1cfdc16922.tar.xz
pttbbs-7f1fa71a2d329c9d7cfa6ff8c6b64d1cfdc16922.tar.zst
pttbbs-7f1fa71a2d329c9d7cfa6ff8c6b64d1cfdc16922.zip
* more checks on net system
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@4606 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--pttbbs/common/sys/net.c20
-rw-r--r--pttbbs/daemon/logind/logind.c4
2 files changed, 18 insertions, 6 deletions
diff --git a/pttbbs/common/sys/net.c b/pttbbs/common/sys/net.c
index 232d5bb1..efeda16a 100644
--- a/pttbbs/common/sys/net.c
+++ b/pttbbs/common/sys/net.c
@@ -188,9 +188,11 @@ int toread(int fd, void *buf, int len)
{
int l;
for( l = 0 ; len > 0 ; )
- if( (l = read(fd, buf, len)) <= 0 )
+ if( (l = read(fd, buf, len)) <= 0 ) {
+ if (errno == EINTR || errno == EAGAIN)
+ continue;
return -1;
- else{
+ }else{
buf += l;
len -= l;
}
@@ -204,9 +206,11 @@ int towrite(int fd, const void *buf, int len)
{
int l;
for( l = 0 ; len > 0 ; )
- if( (l = write(fd, buf, len)) <= 0 )
+ if( (l = write(fd, buf, len)) <= 0){
+ if (errno == EINTR || errno == EAGAIN)
+ continue;
return -1;
- else{
+ }else{
buf += l;
len -= l;
}
@@ -293,9 +297,17 @@ int recv_remote_fd(int tunnel, const char *tunnel_path)
}
cmsg = CMSG_FIRSTHDR(&msg);
+ if (!cmsg) {
+ // kernel indicates there's no ancillary data
+ return -1;
+ }
+
assert(cmsg->cmsg_type == SCM_RIGHTS);
if (cmsg->cmsg_type != SCM_RIGHTS)
+ {
+ // invalid message!?
return -1;
+ }
return *(int*)CMSG_DATA(cmsg);
}
diff --git a/pttbbs/daemon/logind/logind.c b/pttbbs/daemon/logind/logind.c
index 213d8a02..4346e32d 100644
--- a/pttbbs/daemon/logind/logind.c
+++ b/pttbbs/daemon/logind/logind.c
@@ -11,8 +11,8 @@
// TODO:
// 1. cache guest's usernum and check if too many guests online
// 2. [drop] change close connection to 'wait until user hit then close'
-// 3. regular check text screen files instead of HUP?
-// 4. start mbbsd for some parameter?
+// 3. [done] regular check text screen files instead of HUP?
+// 4. re-start mbbsd if pipe broken?
#include <stdio.h>
#include <ctype.h>