diff --git a/sys/kern/kern_dynlib.pas b/sys/kern/kern_dynlib.pas index 336bdf31..3df2eb72 100644 --- a/sys/kern/kern_dynlib.pas +++ b/sys/kern/kern_dynlib.pas @@ -269,6 +269,8 @@ begin Exit(EPERM); end; + //Writeln('sys_dynlib_unload_prx:',handle); + dynlibs_lock; obj:=find_obj_id(handle); diff --git a/sys/kern/kern_thr.pas b/sys/kern/kern_thr.pas index 329263d2..e86ebad6 100644 --- a/sys/kern/kern_thr.pas +++ b/sys/kern/kern_thr.pas @@ -232,6 +232,7 @@ type td_cpuset :Ptruint; td_sleepqueue :Pointer; td_slpq :TAILQ_ENTRY; + td_zombie :TAILQ_ENTRY; td_wchan :Pointer; td_wmesg :PChar; td_sqqueue :Integer; diff --git a/sys/kern/kern_thread.pas b/sys/kern/kern_thread.pas index e9c83157..40d3c5f4 100644 --- a/sys/kern/kern_thread.pas +++ b/sys/kern/kern_thread.pas @@ -142,7 +142,7 @@ end; procedure thread_zombie(td:p_kthread); begin rw_wlock(zombie_lock); - TAILQ_INSERT_HEAD(@zombie_threads,td,@td^.td_slpq); + TAILQ_INSERT_HEAD(@zombie_threads,td,@td^.td_zombie); rw_wunlock(zombie_lock); end; @@ -165,7 +165,7 @@ begin if cpu_thread_finished(td_first) then begin - TAILQ_REMOVE(@zombie_threads,@td_first,@td_first^.td_slpq); + TAILQ_REMOVE(@zombie_threads,@td_first,@td_first^.td_zombie); thread_free(td_first); end else begin diff --git a/sys/kern/subr_dynlib.pas b/sys/kern/subr_dynlib.pas index 45893687..7bb3058b 100644 --- a/sys/kern/subr_dynlib.pas +++ b/sys/kern/subr_dynlib.pas @@ -2417,7 +2417,7 @@ begin elm:=TAILQ_FIRST(@root^.dagmembers); while (elm<>nil) do begin - Inc(elm^.obj^.ref_count); + Dec(elm^.obj^.ref_count); // elm:=TAILQ_NEXT(elm,@elm^.link); end; @@ -3381,9 +3381,12 @@ end; function unload_prx(obj:p_lib_info):Integer; var + ref_count:Integer; modname:pchar; begin - if (obj^.ref_count=0) then + ref_count:=obj^.ref_count; + + if (ref_count=0) then begin Assert(False,'Invalid shared object handle'); Exit(EINVAL); @@ -3391,7 +3394,7 @@ begin unref_dag(obj); - if (obj^.ref_count<>1) then + if (ref_count<>1) then begin Exit(0); end; diff --git a/sys/vm/vm_map.pas b/sys/vm/vm_map.pas index 9a19712d..de3c2df1 100644 --- a/sys/vm/vm_map.pas +++ b/sys/vm/vm_map.pas @@ -2463,7 +2463,7 @@ begin continue; end; - next:=entry^.next; + next:=next^.next; end; {