Serialize ZipOS handle IO across threads

This commit is contained in:
Justine Tunney 2023-02-23 06:24:49 -08:00
parent 0f1ead8943
commit a808b3e738
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
7 changed files with 18 additions and 6 deletions

View file

@ -18,6 +18,7 @@
*/
#include "libc/calls/calls.h"
#include "libc/sysv/errfuns.h"
#include "libc/thread/thread.h"
#include "libc/zip.h"
#include "libc/zipos/zipos.internal.h"
@ -31,6 +32,7 @@
*/
int64_t __zipos_lseek(struct ZiposHandle *h, int64_t offset, unsigned whence) {
int64_t rc;
pthread_mutex_lock(&h->lock);
switch (whence) {
case SEEK_SET:
rc = offset;
@ -50,5 +52,6 @@ int64_t __zipos_lseek(struct ZiposHandle *h, int64_t offset, unsigned whence) {
} else {
rc = einval();
}
pthread_mutex_unlock(&h->lock);
return rc;
}