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
commitf316447abf988cb1df29b5a1cdcdfed9df8e253d (patch)
tree4247cb4a1e9b164bf4b15ae676a09d47a489da73
parent70b74ad55dc292a6898b18f4e57836e476a47ab2 (diff)
downloadpttbbs-f316447abf988cb1df29b5a1cdcdfed9df8e253d.tar
pttbbs-f316447abf988cb1df29b5a1cdcdfed9df8e253d.tar.gz
pttbbs-f316447abf988cb1df29b5a1cdcdfed9df8e253d.tar.bz2
pttbbs-f316447abf988cb1df29b5a1cdcdfed9df8e253d.tar.lz
pttbbs-f316447abf988cb1df29b5a1cdcdfed9df8e253d.tar.xz
pttbbs-f316447abf988cb1df29b5a1cdcdfed9df8e253d.tar.zst
pttbbs-f316447abf988cb1df29b5a1cdcdfed9df8e253d.zip
* more checks on net system
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4606 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--common/sys/net.c20
-rw-r--r--daemon/logind/logind.c4
2 files changed, 18 insertions, 6 deletions
diff --git a/common/sys/net.c b/common/sys/net.c
index 232d5bb1..efeda16a 100644
--- a/common/sys/net.c
+++ b/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/daemon/logind/logind.c b/daemon/logind/logind.c
index 213d8a02..4346e32d 100644
--- a/daemon/logind/logind.c
+++ b/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>