* cygheap.h (init_cygheap): Move bucket array here from cygheap.cc.

* cygheap.cc: Throughout use bucket array from cygheap.
* sigproc.cc (proc_subproc): Dynamically allocate zombie buffer to save DLL
space.
(sigproc_fixup_after_fork): Free zombie array after a fork.
* sigproc.h (sigproc_fixup_after_fork): Declare.
* dir.cc (mkdir): Expand buffer for security descriptor to 4K to avoid stack
corruption.
* fhandler.cc (fhandler_base::open): Ditto.
* path.cc (symlink): Ditto.
This commit is contained in:
Christopher Faylor 2001-09-06 03:39:18 +00:00
parent 0fb61528c9
commit 4ce15a4980
11 changed files with 49 additions and 18 deletions

View File

@ -1,3 +1,20 @@
Wed Sep 5 23:36:03 2001 Christopher Faylor <cgf@cygnus.com>
* cygheap.h (init_cygheap): Move bucket array here from cygheap.cc.
* cygheap.cc: Throughout use bucket array from cygheap.
* sigproc.cc (proc_subproc): Dynamically allocate zombie buffer to save
DLL space.
(sigproc_fixup_after_fork): Free zombie array after a fork.
* sigproc.h (sigproc_fixup_after_fork): Declare.
2001-09-06 Egor Duda <deo@logos-m.ru>
* dir.cc (mkdir): Expand buffer for security descriptor to 4K to avoid
stack corruption.
* fhandler.cc (fhandler_base::open): Ditto.
* path.cc (symlink): Ditto.
Wed Sep 5 21:35:00 2001 Corinna Vinschen <corinna@vinschen.de> Wed Sep 5 21:35:00 2001 Corinna Vinschen <corinna@vinschen.de>
* winver.rc: Change copyright to include 2001. * winver.rc: Change copyright to include 2001.

View File

@ -35,9 +35,7 @@ struct cygheap_entry
char data[0]; char data[0];
}; };
#define NBUCKETS 32 #define NBUCKETS (sizeof (cygheap->buckets) / sizeof (cygheap->buckets[0]))
static char *buckets[NBUCKETS] = {0};
#define N0 ((_cmalloc_entry *) NULL) #define N0 ((_cmalloc_entry *) NULL)
#define to_cmalloc(s) ((_cmalloc_entry *) (((char *) (s)) - (int) (N0->data))) #define to_cmalloc(s) ((_cmalloc_entry *) (((char *) (s)) - (int) (N0->data)))
@ -202,10 +200,10 @@ _cmalloc (int size)
continue; continue;
cygheap_protect->acquire (); cygheap_protect->acquire ();
if (buckets[b]) if (cygheap->buckets[b])
{ {
rvc = (_cmalloc_entry *) buckets[b]; rvc = (_cmalloc_entry *) cygheap->buckets[b];
buckets[b] = rvc->ptr; cygheap->buckets[b] = rvc->ptr;
rvc->b = b; rvc->b = b;
} }
else else
@ -227,8 +225,8 @@ _cfree (void *ptr)
cygheap_protect->acquire (); cygheap_protect->acquire ();
_cmalloc_entry *rvc = to_cmalloc (ptr); _cmalloc_entry *rvc = to_cmalloc (ptr);
DWORD b = rvc->b; DWORD b = rvc->b;
rvc->ptr = buckets[b]; rvc->ptr = cygheap->buckets[b];
buckets[b] = (char *) rvc; cygheap->buckets[b] = (char *) rvc;
cygheap_protect->release (); cygheap_protect->release ();
} }

View File

@ -152,6 +152,7 @@ struct cwdstuff
struct init_cygheap struct init_cygheap
{ {
_cmalloc_entry *chain; _cmalloc_entry *chain;
char *buckets[32];
cygheap_root root; cygheap_root root;
cygheap_user user; cygheap_user user;
mode_t umask; mode_t umask;

View File

@ -339,7 +339,7 @@ mkdir (const char *dir, mode_t mode)
if (allow_ntsec && real_dir.has_acls ()) if (allow_ntsec && real_dir.has_acls ())
set_security_attribute (S_IFDIR | ((mode & 07777) & ~cygheap->umask), set_security_attribute (S_IFDIR | ((mode & 07777) & ~cygheap->umask),
&sa, alloca (256), 256); &sa, alloca (4096), 4096);
if (CreateDirectoryA (real_dir.get_win32 (), &sa)) if (CreateDirectoryA (real_dir.get_win32 (), &sa))
{ {

View File

@ -387,7 +387,7 @@ fhandler_base::open (int flags, mode_t mode)
/* If the file should actually be created and ntsec is on, /* If the file should actually be created and ntsec is on,
set files attributes. */ set files attributes. */
if (flags & O_CREAT && get_device () == FH_DISK && allow_ntsec && has_acls ()) if (flags & O_CREAT && get_device () == FH_DISK && allow_ntsec && has_acls ())
set_security_attribute (mode, &sa, alloca (256), 256); set_security_attribute (mode, &sa, alloca (4096), 4096);
x = CreateFileA (get_win32_name (), access, shared, x = CreateFileA (get_win32_name (), access, shared,
&sa, creation_distribution, &sa, creation_distribution,

View File

@ -279,6 +279,7 @@ fork_child (HANDLE& hParent, dll *&first_dll, bool& load_dlls)
debug_fixup_after_fork (); debug_fixup_after_fork ();
pinfo_fixup_after_fork (); pinfo_fixup_after_fork ();
cygheap->fdtab.fixup_after_fork (hParent); cygheap->fdtab.fixup_after_fork (hParent);
sigproc_fixup_after_fork ();
signal_fixup_after_fork (); signal_fixup_after_fork ();
MALLOC_CHECK; MALLOC_CHECK;

View File

@ -27,9 +27,9 @@ details. */
/* Read /etc/passwd only once for better performance. This is done /* Read /etc/passwd only once for better performance. This is done
on the first call that needs information from it. */ on the first call that needs information from it. */
static struct passwd *passwd_buf = NULL; /* passwd contents in memory */ static struct passwd *passwd_buf; /* passwd contents in memory */
static int curr_lines = 0; static int curr_lines;
static int max_lines = 0; static int max_lines;
/* Set to loaded when /etc/passwd has been read in by read_etc_passwd (). /* Set to loaded when /etc/passwd has been read in by read_etc_passwd ().
Set to emulated if passwd is emulated. */ Set to emulated if passwd is emulated. */

View File

@ -2461,7 +2461,7 @@ symlink (const char *topath, const char *frompath)
if (allow_ntsec && win32_path.has_acls ()) if (allow_ntsec && win32_path.has_acls ())
set_security_attribute (S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO, set_security_attribute (S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO,
&sa, alloca (256), 256); &sa, alloca (4096), 4096);
h = CreateFileA(win32_path, GENERIC_WRITE, 0, &sa, h = CreateFileA(win32_path, GENERIC_WRITE, 0, &sa,
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0); CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);

View File

@ -44,7 +44,7 @@ details. */
extern BOOL allow_ntea; extern BOOL allow_ntea;
BOOL allow_ntsec = FALSE; BOOL allow_ntsec;
/* allow_smbntsec is handled exclusively in path.cc (path_conv::check). /* allow_smbntsec is handled exclusively in path.cc (path_conv::check).
It's defined here because of it's strong relationship to allow_ntsec. It's defined here because of it's strong relationship to allow_ntsec.
The default is TRUE to reflect the old behaviour. */ The default is TRUE to reflect the old behaviour. */

View File

@ -46,7 +46,7 @@ details. */
#define no_signals_available() (!hwait_sig || !sig_loop_wait) #define no_signals_available() (!hwait_sig || !sig_loop_wait)
#define ZOMBIEMAX ((int) (sizeof (zombies) / sizeof (zombies[0])) - 1) #define ZOMBIEMAX 4096
/* /*
* Global variables * Global variables
@ -102,9 +102,9 @@ Static HANDLE wait_sig_inited = NULL; // Control synchronization of
Static HANDLE events[PSIZE + 1] = {0}; // All my children's handles++ Static HANDLE events[PSIZE + 1] = {0}; // All my children's handles++
#define hchildren (events + 1) // Where the children handles begin #define hchildren (events + 1) // Where the children handles begin
Static pinfo pchildren[PSIZE]; // All my children info Static pinfo pchildren[PSIZE]; // All my children info
Static pinfo zombies[16384]; // All my deceased children info
Static int nchildren = 0; // Number of active children Static int nchildren = 0; // Number of active children
Static int nzombies = 0; // Number of deceased children static pinfo *zombies; // All my deceased children info
static int nzombies; // Number of deceased children
Static waitq waitq_head = {0, 0, 0, 0, 0, 0, 0};// Start of queue for wait'ing threads Static waitq waitq_head = {0, 0, 0, 0, 0, 0, 0};// Start of queue for wait'ing threads
Static waitq waitq_main; // Storage for main thread Static waitq waitq_main; // Storage for main thread
@ -303,6 +303,8 @@ proc_subproc (DWORD what, DWORD val)
int thiszombie; int thiszombie;
thiszombie = nzombies; thiszombie = nzombies;
if (!zombies)
zombies = (pinfo *) malloc (sizeof (pinfo) * ZOMBIEMAX);
zombies[nzombies] = pchildren[val]; // Add to zombie array zombies[nzombies] = pchildren[val]; // Add to zombie array
zombies[nzombies++]->process_state = PID_ZOMBIE;// Walking dead zombies[nzombies++]->process_state = PID_ZOMBIE;// Walking dead
@ -1302,6 +1304,17 @@ wait_subproc (VOID *)
return 0; return 0;
} }
void __stdcall
sigproc_fixup_after_fork ()
{
if (zombies)
{
free (zombies);
nzombies = 0;
zombies = NULL;
}
}
extern "C" { extern "C" {
/* Provide a stack frame when calling WaitFor* functions */ /* Provide a stack frame when calling WaitFor* functions */

View File

@ -115,6 +115,7 @@ int __stdcall sig_send (_pinfo *, int, DWORD ebp = (DWORD) __builtin_frame_addre
bool exception = 0) __attribute__ ((regparm(3))); bool exception = 0) __attribute__ ((regparm(3)));
void __stdcall signal_fixup_after_fork (); void __stdcall signal_fixup_after_fork ();
void __stdcall signal_fixup_after_exec (bool); void __stdcall signal_fixup_after_exec (bool);
void __stdcall sigproc_fixup_after_fork ();
extern char myself_nowait_dummy[]; extern char myself_nowait_dummy[];
extern char myself_nowait_nonmain_dummy[]; extern char myself_nowait_nonmain_dummy[];