diff --git a/src/ChangeLog b/src/ChangeLog index 44f795c9ac5075feb0bcad3b924a748b47549c13..036aa2459861b04a8c3bb44cbc62ead154a0ea1b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +Fri Dec 6 08:51:30 1996 Per Hedbor <cardeci@cluracan> + + * modules/files/efuns.c: Threaded file_stat and rm. More efuns + should be threaded, especially get_dir. + + * threads.c (th_init): Fixed types for thread_create (should + return object, not int.) + Thu Dec 5 13:34:40 1996 Fredrik Hubinette <hubbe@cytocin.hubbe.net> * callback.c, gc.c: fixed garbage collection calls diff --git a/src/interpret.c b/src/interpret.c index ca5fe2b401efe37ea733f8fad074c9b49e418571..63268aee30f4551d1ff1127b9b8ff83d3dbbe99a 100644 --- a/src/interpret.c +++ b/src/interpret.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: interpret.c,v 1.17 1996/12/06 04:26:56 hubbe Exp $"); +RCSID("$Id: interpret.c,v 1.18 1996/12/06 08:30:16 per Exp $"); #include "interpret.h" #include "object.h" #include "program.h" @@ -470,7 +470,6 @@ static void eval_instruction(unsigned char *pc) if(!mt_trylock(& interpreter_lock)) fatal("Interpreter running unlocked!\n"); #endif - sp[0].type=99; /* an invalid type */ sp[1].type=99; sp[2].type=99; diff --git a/src/modules/files/efuns.c b/src/modules/files/efuns.c index f0744966acdaf930a0e2a38cd6fe2ffd351e2fff..22c13938063c8e26e46ad02abbeaa3ca207f9393 100644 --- a/src/modules/files/efuns.c +++ b/src/modules/files/efuns.c @@ -65,18 +65,24 @@ struct array *encode_stat(struct stat *s) void f_file_stat(INT32 args) { struct stat st; - int i; - + int i, l; + char *s; + if(args<1) error("Too few arguments to file_stat()\n"); if(sp[-args].type != T_STRING) error("Bad argument 1 to file_stat()\n"); - if(args>1 && !IS_ZERO(sp-1-args)) + + s = sp[-args].u.string->str; + l = (args>1 && !IS_ZERO(sp-1-args))?1:0; + THREADS_ALLOW(); + if(l) { - i=lstat(sp[-args].u.string->str, &st); + i=lstat(s, &st); }else{ - i=stat(sp[-args].u.string->str, &st); + i=stat(s, &st); } + THREADS_DISALLOW(); pop_n_elems(args); if(i==-1) { @@ -101,6 +107,7 @@ void f_rm(INT32 args) { struct stat st; INT32 i; + char *s; if(!args) error("Too few arguments to rm()\n"); @@ -108,17 +115,20 @@ void f_rm(INT32 args) if(sp[-args].type != T_STRING) error("Bad argument 1 to rm().\n"); - i=lstat(sp[-args].u.string->str, &st) != -1; - + s = sp[-args].u.string->str; + + i=lstat(s, &st) != -1; + THREADS_ALLOW(); if(i) { if(S_IFDIR == (S_IFMT & st.st_mode)) { - i=rmdir(sp[-args].u.string->str) != -1; + i=rmdir(s) != -1; }else{ - i=unlink(sp[-args].u.string->str) != -1; + i=unlink(s) != -1; } } + THREADS_DISALLOW(); pop_n_elems(args); push_int(i); @@ -142,7 +152,9 @@ void f_mkdir(INT32 args) i=sp[1-args].u.integer; } - i=mkdir(sp[-args].u.string->str, i) != -1; + THREADS_ALLOW(); + i=mkdir(_tmp.sp[-args].u.string->str, i) != -1; + THREADS_DISALLOW(); pop_n_elems(args); push_int(i); } @@ -217,7 +229,9 @@ void f_getcwd(INT32 args) #ifndef MAXPATHLEN #define MAXPATHLEN 32768 #endif + THREADS_ALLOW(); e=(char *)getwd((char *)malloc(MAXPATHLEN+1)); + THREADS_DISALLOW(); #endif if(!e) error("Failed to fetch current path.\n"); diff --git a/src/modules/files/file.c b/src/modules/files/file.c index 54e6113bf8136190f6ac47293fc2c84d11f9d672..01628e7eb3e32a355fb9b7b9f89b64731c3e567b 100644 --- a/src/modules/files/file.c +++ b/src/modules/files/file.c @@ -6,7 +6,7 @@ #define READ_BUFFER 16384 #include "global.h" -RCSID("$Id: file.c,v 1.17 1996/12/06 04:27:44 hubbe Exp $"); +RCSID("$Id: file.c,v 1.18 1996/12/06 08:30:18 per Exp $"); #include "types.h" #include "interpret.h" #include "svalue.h" @@ -304,7 +304,7 @@ static struct pike_string *do_read(int fd, i=read(fd, low_make_buf_space(try_read, &b), try_read); THREADS_DISALLOW(); - check_signals(); +/* check_signals();*/ if(i==try_read) { diff --git a/src/threads.c b/src/threads.c index 9e6c59d973ae4b163493c5d13dcc3bb8daadac03..550489c848827fe19623c35cb4cf2402ff7cff09 100644 --- a/src/threads.c +++ b/src/threads.c @@ -1,5 +1,5 @@ #include "global.h" -RCSID("$Id: threads.c,v 1.12 1996/11/19 10:04:29 neotron Exp $"); +RCSID("$Id: threads.c,v 1.13 1996/12/06 08:30:17 per Exp $"); int num_threads = 1; int threads_disabled = 0; @@ -129,8 +129,10 @@ void th_init() #endif pthread_attr_setdetachstate(&pattr, PTHREAD_CREATE_DETACHED); - add_efun("thread_create",f_thread_create,"function(mixed ...:int)",OPT_SIDE_EFFECT); - add_efun("this_thread",f_this_thread,"function(:object)",OPT_EXTERNAL_DEPEND); + add_efun("thread_create",f_thread_create,"function(mixed ...:object)", + OPT_SIDE_EFFECT); + add_efun("this_thread",f_this_thread,"function(:object)", + OPT_EXTERNAL_DEPEND); }