commit cdf8e7d64f8817208d96403ffa712588b816da41
parent b9c308a434477777095b4b41b2dc2474abc96e05
Author: Pavel Renev <an2qzavok@gmail.com>
Date: Thu, 29 Jul 2021 12:18:22 +0000
more qlocking
Diffstat:
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/fs.c b/fs.c
@@ -31,7 +31,9 @@ fs_read(Req *r)
readstr(r, newobj->id);
respond(r, nil);
} else if (aux != nil) {
+ qlock(rich.l);
readbuf(r, aux->data->p, aux->data->n);
+ qunlock(rich.l);
respond(r, nil);
} else respond(r, "fs_read: f->aux is nil");
}
@@ -48,6 +50,7 @@ fs_write(Req *r)
if (f == new) {
respond(r, "not allowed");
} else if (aux != nil) {
+ qlock(rich.l);
/* TODO: this is not exactly finished */
n = r->ifcall.offset + r->ifcall.count;
m = (r->ifcall.offset > aux->data->n) ? aux->data->n : r->ifcall.offset;
@@ -59,6 +62,7 @@ fs_write(Req *r)
aux->data->n = n;
r->ofcall.count = r->ifcall.count;
respond(r, nil);
+ qunlock(rich.l);
generatepage(&rich);
/* there should be a call to redraw(), probably */
} else respond(r, "fs_write: f->aux is nil");
diff --git a/richterm.c b/richterm.c
@@ -124,6 +124,7 @@ threadmain(int argc, char **argv)
if (getwindow(display, Refnone) < 0)
sysfatal("resize failed: %r");
resize();
+ redraw(1);
break;
case KBD:
if (kv == 0x7f) shutdown();
@@ -174,9 +175,11 @@ void
drawpage(Image *dst, Page *p)
{
int i;
+ qlock(rich.l);
for (i = 0; i < p->count; i++) {
drawview(dst, p->view + i);
}
+ qunlock(rich.l);
}
void
@@ -295,6 +298,7 @@ generatepage(Rich *rich)
rich->page.max.y = ymax - r.min.y;
rich->page.max.x = 0;
+
qunlock(rich->l);
}
@@ -372,6 +376,8 @@ mkobjectftree(Object *obj, File *root, char *text)
{
Faux *auxtext, *auxfont, *auxlink, *auximage;
+ qlock(rich.l);
+
obj->dir = createfile(root, obj->id, "richterm", DMDIR|0555, nil);
auxtext = fauxalloc(text);
@@ -383,6 +389,7 @@ mkobjectftree(Object *obj, File *root, char *text)
obj->ffont = createfile(obj->dir, "font", "richterm", 0666, auxfont);
obj->flink = createfile(obj->dir, "link", "richterm", 0666, auxlink);
obj->fimage = createfile(obj->dir, "image", "richterm", 0666, auximage);
+ qunlock(rich.l);
return obj;
}
@@ -470,5 +477,4 @@ resize(void)
addpt(screen->r.min, Pt(17, 1)),
subpt(screen->r.max, Pt(1,1))
);
- redraw(1);
-}
-\ No newline at end of file
+}