summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mbbsd/io.c12
-rw-r--r--mbbsd/mbbsd.c1
-rw-r--r--mbbsd/talk.c2
-rw-r--r--util/shmctl.c67
4 files changed, 76 insertions, 6 deletions
diff --git a/mbbsd/io.c b/mbbsd/io.c
index a879f9e9..41ce6813 100644
--- a/mbbsd/io.c
+++ b/mbbsd/io.c
@@ -148,10 +148,6 @@ dogetch()
{
int len;
static time_t lastact;
-#ifdef NOKILLWATERBALL
- if( currutmp && currutmp->msgcount && !reentrant_write_request )
- write_request(1);
-#endif
if (ibufsize <= icurrchar) {
if (flushf)
@@ -175,7 +171,8 @@ dogetch()
/* jochang: modify first argument of select from FD_SETSIZE */
/* since we are only waiting input from fd 0 and i_newfd(>0) */
- while ((len = select(i_newfd + 1, &readfds, NULL, NULL, i_top ? &timeout : NULL)) < 0) {
+ while ((len = select(i_newfd + 1, &readfds, NULL, NULL,
+ i_top ? &timeout : NULL)) < 0) {
if (errno != EINTR)
abort_bbs(0);
/* raise(SIGHUP); */
@@ -187,6 +184,11 @@ dogetch()
if (i_newfd && FD_ISSET(i_newfd, &readfds))
return I_OTHERDATA;
}
+#ifdef NOKILLWATERBALL
+ if( currutmp && currutmp->msgcount && !reentrant_write_request )
+ write_request(1);
+#endif
+
#ifdef SKIP_TELNET_CONTROL_SIGNAL
do{
#endif
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index b64cab13..8371d7aa 100644
--- a/mbbsd/mbbsd.c
+++ b/mbbsd/mbbsd.c
@@ -431,6 +431,7 @@ write_request(int sig)
}
#ifdef NOKILLWATERBALL
reentrant_write_request = 0;
+ currutmp->wbtime = 0; /* race */
#endif
}
diff --git a/mbbsd/talk.c b/mbbsd/talk.c
index 827ef274..7aee54f2 100644
--- a/mbbsd/talk.c
+++ b/mbbsd/talk.c
@@ -669,7 +669,7 @@ my_write(pid_t pid, char *prompt, char *id, int flag, userinfo_t * puin)
if (uin->msgcount >= 1 &&
#ifdef NOKILLWATERBALL
- 0
+ !(uin->wbtime = now) /* race */
#else
(uin->pid <= 0 || kill(uin->pid, SIGUSR2) == -1)
#endif
diff --git a/util/shmctl.c b/util/shmctl.c
index 74cf3e12..772df087 100644
--- a/util/shmctl.c
+++ b/util/shmctl.c
@@ -532,6 +532,12 @@ int SHMinit(int argc, char **argv)
puts("timed...");
timed(1, NULL);
#endif
+
+#ifdef NOKILLWATERBALL
+ puts("nkwbd...");
+ nkwbd(1, NULL);
+#endif
+
return 0;
}
@@ -611,6 +617,64 @@ int usermode(int argc, char **argv)
return 0;
}
+#ifdef NOKILLWATERBALL
+int nkwbd(int argc, char **argv)
+{
+ int ch, sleeptime = 120, timeout = 120;
+ while( (ch = getopt(argc, argv, "s:t:h")) != -1 )
+ switch( ch ){
+ case 's':
+ if( (sleeptime = atoi(optarg)) < 10 ){
+ fprintf(stderr, "sleeptime < 10? set to 60");
+ sleeptime = 60;
+ }
+ break;
+
+ case 't':
+ if( (timeout = atoi(optarg)) < 10 ){
+ fprintf(stderr, "timeout < 10? set to 60");
+ timeout = 60;
+ }
+ break;
+
+ default:
+ fprintf(stderr, "usage: shmctl nkwbd [-s sleeptime] [-t timeout]\n");
+ return 0;
+ }
+
+ switch( fork() ){
+ case -1:
+ perror("fork()");
+ return 0;
+ break;
+
+ case 0: /* child */
+ while( 1 ){
+ int i;
+ time_t t = SHM->GV2.e.now - timeout;
+
+ printf("scanning\n");
+ for( i = 0 ; i < MAX_ACTIVE ; ++i )
+ if( SHM->uinfo[i].pid &&
+ SHM->uinfo[i].wbtime &&
+ SHM->uinfo[i].wbtime < t ){
+ printf("kill: %d\n", SHM->uinfo[i].pid);
+ kill(SHM->uinfo[i].pid, SIGUSR2);
+ SHM->uinfo[i].wbtime = 0; /* race */
+ }
+ printf("scanned\n");
+ sleep(sleeptime);
+ }
+ break;
+
+ default: /* parent */
+ fprintf(stderr, "nkwbd\n");
+ return 0;
+ }
+ return 0;
+}
+#endif
+
struct {
int (*func)(int, char **);
char *cmd, *descript;
@@ -628,6 +692,9 @@ struct {
#ifdef OUTTA_TIMER
{timed, "timed", "time daemon for OUTTA_TIMER"},
#endif
+#ifdef NOKILLWATERBALL
+ {nkwbd, "nkwbd", "NOKillWaterBall daemon"},
+#endif
{bBMC, "bBMC", "build BM cache"},
{SHMinit, "SHMinit", "initialize SHM (including uhash_loader)"},
{hotboard, "hotboard", "list boards of most bfriends"},