* 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>
* winver.rc: Change copyright to include 2001.

View File

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

View File

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

View File

@ -339,7 +339,7 @@ mkdir (const char *dir, mode_t mode)
if (allow_ntsec && real_dir.has_acls ())
set_security_attribute (S_IFDIR | ((mode & 07777) & ~cygheap->umask),
&sa, alloca (256), 256);
&sa, alloca (4096), 4096);
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,
set files attributes. */
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,
&sa, creation_distribution,

View File

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

View File

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

View File

@ -44,7 +44,7 @@ details. */
extern BOOL allow_ntea;
BOOL allow_ntsec = FALSE;
BOOL allow_ntsec;
/* allow_smbntsec is handled exclusively in path.cc (path_conv::check).
It's defined here because of it's strong relationship to allow_ntsec.
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 ZOMBIEMAX ((int) (sizeof (zombies) / sizeof (zombies[0])) - 1)
#define ZOMBIEMAX 4096
/*
* 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++
#define hchildren (events + 1) // Where the children handles begin
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 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_main; // Storage for main thread
@ -303,6 +303,8 @@ proc_subproc (DWORD what, DWORD val)
int thiszombie;
thiszombie = nzombies;
if (!zombies)
zombies = (pinfo *) malloc (sizeof (pinfo) * ZOMBIEMAX);
zombies[nzombies] = pchildren[val]; // Add to zombie array
zombies[nzombies++]->process_state = PID_ZOMBIE;// Walking dead
@ -1302,6 +1304,17 @@ wait_subproc (VOID *)
return 0;
}
void __stdcall
sigproc_fixup_after_fork ()
{
if (zombies)
{
free (zombies);
nzombies = 0;
zombies = NULL;
}
}
extern "C" {
/* 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)));
void __stdcall signal_fixup_after_fork ();
void __stdcall signal_fixup_after_exec (bool);
void __stdcall sigproc_fixup_after_fork ();
extern char myself_nowait_dummy[];
extern char myself_nowait_nonmain_dummy[];