summaryrefslogtreecommitdiffstats
path: root/src/cmd/acme/mail/win.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2006-02-15 23:06:27 +0000
committerrsc <devnull@localhost>2006-02-15 23:06:27 +0000
commit880ab2f10a2d4922d314ff8d016ea078f3c7f019 (patch)
tree9bb0a5bfd45d9a78ec768e1589257f50c635c522 /src/cmd/acme/mail/win.c
parent201e19d672a2dab81e213237569022607aced2e1 (diff)
downloadplan9port-880ab2f10a2d4922d314ff8d016ea078f3c7f019.tar.gz
plan9port-880ab2f10a2d4922d314ff8d016ea078f3c7f019.zip
fixed
Diffstat (limited to 'src/cmd/acme/mail/win.c')
-rw-r--r--src/cmd/acme/mail/win.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/cmd/acme/mail/win.c b/src/cmd/acme/mail/win.c
index e407b0c3..8a3e60a9 100644
--- a/src/cmd/acme/mail/win.c
+++ b/src/cmd/acme/mail/win.c
@@ -24,10 +24,32 @@ newwindow(void)
w->body = nil;
w->data = nil;
w->cevent = chancreate(sizeof(Event*), 0);
+ w->ref = 1;
return w;
}
void
+winincref(Window *w)
+{
+ qlock(&w->lk);
+ ++w->ref;
+ qunlock(&w->lk);
+}
+
+void
+windecref(Window *w)
+{
+ qlock(&w->lk);
+ if(--w->ref > 0){
+ qunlock(&w->lk);
+ return;
+ }
+ fsclose(w->event);
+ chanfree(w->cevent);
+ free(w);
+}
+
+void
winsetdump(Window *w, char *dir, char *cmd)
{
if(dir != nil)
@@ -125,6 +147,7 @@ wingetec(Window *w)
w->nbuf = fsread(w->event, w->buf, sizeof w->buf);
if(w->nbuf <= 0){
/* probably because window has exited, and only called by wineventproc, so just shut down */
+ windecref(w);
threadexits(nil);
}
w->bufp = w->buf;
@@ -255,8 +278,6 @@ windel(Window *w, int sure)
windormant(w);
fsclose(w->ctl);
w->ctl = nil;
- fsclose(w->event);
- w->event = nil;
return 1;
}