ape/stdio: make fopen() quasi threadsafe for python
python uses processes sharing memory. it requires at least fopen() to be called by multiple threads at once so we introduce _IO_newfile() which allocates the FILE structure slot under a lock.
This commit is contained in:
parent
530a2bc5e9
commit
48b0c10681
14 changed files with 79 additions and 24 deletions
|
@ -8,7 +8,7 @@ int _IO_getc(FILE *f){
|
|||
default: /* CLOSED, WR, ERR, EOF */
|
||||
return EOF;
|
||||
case OPEN:
|
||||
_IO_setvbuf(f);
|
||||
if(_IO_setvbuf(f)!=0) return EOF;
|
||||
case RDWR:
|
||||
case RD:
|
||||
if(f->flags&STRING) return EOF;
|
||||
|
@ -17,6 +17,7 @@ int _IO_getc(FILE *f){
|
|||
else
|
||||
n = f->bufl;
|
||||
cnt=read(f->fd, f->buf, n);
|
||||
if(f->state==CLOSED) return EOF;
|
||||
switch(cnt){
|
||||
case -1: f->state=ERR; return EOF;
|
||||
case 0: f->state=END; return EOF;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue