diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-10-23 15:46:26 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-10-23 15:46:26 +0800 |
commit | 354b9f1112370fb68df58526dc7f72cc86208899 (patch) | |
tree | d331eef34321bf2674d688d47dc6ad156aa6da64 | |
parent | c08cd831bb8c6f099160ec67f62bbd6ab451a930 (diff) | |
download | pttbbs-354b9f1112370fb68df58526dc7f72cc86208899.tar pttbbs-354b9f1112370fb68df58526dc7f72cc86208899.tar.gz pttbbs-354b9f1112370fb68df58526dc7f72cc86208899.tar.bz2 pttbbs-354b9f1112370fb68df58526dc7f72cc86208899.tar.lz pttbbs-354b9f1112370fb68df58526dc7f72cc86208899.tar.xz pttbbs-354b9f1112370fb68df58526dc7f72cc86208899.tar.zst pttbbs-354b9f1112370fb68df58526dc7f72cc86208899.zip |
* fix: ccw/talk terminates process due to SIGPIPE.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@4968 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | pttbbs/mbbsd/ccw.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/pttbbs/mbbsd/ccw.c b/pttbbs/mbbsd/ccw.c index 89ebfefd..d759b19e 100644 --- a/pttbbs/mbbsd/ccw.c +++ b/pttbbs/mbbsd/ccw.c @@ -525,9 +525,11 @@ ccw_talk_send(CCW_CTX *ctx, const char *msg) assert(len >= 0 && (int)len == strlen(msg)); if (len < 1) return 0; - if (towrite(ctx->fd, &len, 1) != 1) + // XXX if remote is closed (without MSG_NOSIGNAL), + // this may raise a SIGPIPE and cause BBS to abort... + if (send(ctx->fd, &len, sizeof(len), MSG_NOSIGNAL) != sizeof(len)) return -1; - if (towrite(ctx->fd, msg, len)!= len) + if (send(ctx->fd, msg, len, MSG_NOSIGNAL) != len) return -1; return len; } @@ -537,8 +539,8 @@ ccw_talk_recv(CCW_CTX *ctx, char *buf, size_t szbuf) { char len = 0; buf[0] = 0; - // XXX blocking call here... - if (toread(ctx->fd, &len, 1) != 1) + // XXX blocking call here... (change to recv?) + if (toread(ctx->fd, &len, sizeof(len)) != sizeof(len)) return -1; if (toread(ctx->fd, buf, len)!= len) return -1; @@ -757,7 +759,9 @@ ccw_chat_send(CCW_CTX *ctx, const char *buf) char genbuf[200]; len = snprintf(genbuf, sizeof(genbuf), "%s\n", buf); - return (send(ctx->fd, genbuf, len, 0) == len); + // XXX if remote is closed (without MSG_NOSIGNAL), + // this may raise a SIGPIPE and cause BBS to abort... + return (send(ctx->fd, genbuf, len, MSG_NOSIGNAL) == len); } static void |