* dcrt0.cc (get_exit_lock): Use myself.lock rather than exit_lock.

* exceptions.cc (exit_lock): Delete.
(events_init): Don't init exit_lock.
* (_pinfo::commune_process): Add per-PICOM debugging.
* sigproc.cc (talktome): Add some temporary debugging statements.
* fhandler_proc.cc (format_proc_cpuinfo): Cosmetic change.
(format_proc_partitions): Ditto.
* syscalls.cc (locked_append): Ditto.
This commit is contained in:
Christopher Faylor 2005-10-02 00:13:41 +00:00
parent f5cfdc0fa4
commit 0cb6fc5d30
7 changed files with 56 additions and 30 deletions

View File

@ -1,3 +1,15 @@
2005-10-01 Christopher Faylor <cgf@timesys.com>
* dcrt0.cc (get_exit_lock): Use myself.lock rather than exit_lock.
* exceptions.cc (exit_lock): Delete.
(events_init): Don't init exit_lock.
* (_pinfo::commune_process): Add per-PICOM debugging.
* sigproc.cc (talktome): Add some temporary debugging statements.
* fhandler_proc.cc (format_proc_cpuinfo): Cosmetic change.
(format_proc_partitions): Ditto.
* syscalls.cc (locked_append): Ditto.
2005-09-30 Christopher Faylor <cgf@timesys.com> 2005-09-30 Christopher Faylor <cgf@timesys.com>
* dcrt0.cc (do_exit): Don't set ES_SET_MUTO here. Call get_exit_lock() * dcrt0.cc (do_exit): Don't set ES_SET_MUTO here. Call get_exit_lock()

View File

@ -1141,8 +1141,7 @@ _exit (int n)
void void
get_exit_lock () get_exit_lock ()
{ {
extern CRITICAL_SECTION exit_lock; myself.lock ();
EnterCriticalSection (&exit_lock);
if (exit_state < ES_SET_MUTO) if (exit_state < ES_SET_MUTO)
{ {
exit_state = ES_SET_MUTO; exit_state = ES_SET_MUTO;

View File

@ -1167,8 +1167,6 @@ exit_sig:
signal_exit (si.si_signo); /* never returns */ signal_exit (si.si_signo); /* never returns */
} }
CRITICAL_SECTION NO_COPY exit_lock;
/* Cover function to `do_exit' to handle exiting even in presence of more /* Cover function to `do_exit' to handle exiting even in presence of more
exceptions. We used to call exit, but a SIGSEGV shouldn't cause atexit exceptions. We used to call exit, but a SIGSEGV shouldn't cause atexit
routines to run. */ routines to run. */
@ -1229,7 +1227,6 @@ events_init ()
windows_system_directory_length = end - windows_system_directory; windows_system_directory_length = end - windows_system_directory;
debug_printf ("windows_system_directory '%s', windows_system_directory_length %d", debug_printf ("windows_system_directory '%s', windows_system_directory_length %d",
windows_system_directory, windows_system_directory_length); windows_system_directory, windows_system_directory_length);
InitializeCriticalSection (&exit_lock);
} }
void void

View File

@ -635,7 +635,7 @@ format_proc_cpuinfo (char *destbuf, size_t maxsize)
GetSystemInfo (&siSystemInfo); GetSystemInfo (&siSystemInfo);
for (cpu_number = 0;;cpu_number++) for (cpu_number = 0; ; cpu_number++)
{ {
__small_sprintf (szBuffer, "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%d", cpu_number); __small_sprintf (szBuffer, "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%d", cpu_number);
@ -945,7 +945,7 @@ format_proc_partitions (char *destbuf, size_t maxsize)
if (wincap.is_winnt ()) if (wincap.is_winnt ())
{ {
for (int drive_number=0;;drive_number++) for (int drive_number=0; ; drive_number++)
{ {
CHAR szDriveName[CYG_MAX_PATH]; CHAR szDriveName[CYG_MAX_PATH];
__small_sprintf (szDriveName, "\\\\.\\PHYSICALDRIVE%d", drive_number); __small_sprintf (szDriveName, "\\\\.\\PHYSICALDRIVE%d", drive_number);

View File

@ -394,6 +394,7 @@ _pinfo::commune_process (siginfo_t& si)
{ {
case PICOM_CMDLINE: case PICOM_CMDLINE:
{ {
sigproc_printf ("processing PICOM_CMDLINE");
unsigned n = 1; unsigned n = 1;
extern int __argc_safe; extern int __argc_safe;
const char *argv[__argc_safe + 1]; const char *argv[__argc_safe + 1];
@ -428,6 +429,7 @@ _pinfo::commune_process (siginfo_t& si)
} }
case PICOM_CWD: case PICOM_CWD:
{ {
sigproc_printf ("processing PICOM_CWD");
unsigned int n = strlen (cygheap->cwd.get (path, 1, 1, unsigned int n = strlen (cygheap->cwd.get (path, 1, 1,
CYG_MAX_PATH)) + 1; CYG_MAX_PATH)) + 1;
if (!WriteFile (tothem, &n, sizeof n, &nr, NULL)) if (!WriteFile (tothem, &n, sizeof n, &nr, NULL))
@ -438,6 +440,7 @@ _pinfo::commune_process (siginfo_t& si)
} }
case PICOM_ROOT: case PICOM_ROOT:
{ {
sigproc_printf ("processing PICOM_ROOT");
unsigned n; unsigned n;
if (cygheap->root.exists ()) if (cygheap->root.exists ())
n = strlen (strcpy (path, cygheap->root.posix_path ())) + 1; n = strlen (strcpy (path, cygheap->root.posix_path ())) + 1;
@ -451,6 +454,7 @@ _pinfo::commune_process (siginfo_t& si)
} }
case PICOM_FDS: case PICOM_FDS:
{ {
sigproc_printf ("processing PICOM_FDS");
unsigned int n = 0; unsigned int n = 0;
int fd; int fd;
cygheap_fdenum cfd; cygheap_fdenum cfd;
@ -469,27 +473,29 @@ _pinfo::commune_process (siginfo_t& si)
break; break;
} }
case PICOM_PIPE_FHANDLER: case PICOM_PIPE_FHANDLER:
{ {
HANDLE hdl = si._si_commune._si_pipe_fhandler; sigproc_printf ("processing PICOM_FDS");
unsigned int n = 0; HANDLE hdl = si._si_commune._si_pipe_fhandler;
cygheap_fdenum cfd; unsigned int n = 0;
while (cfd.next () >= 0) cygheap_fdenum cfd;
if (cfd->get_handle () == hdl) while (cfd.next () >= 0)
{ if (cfd->get_handle () == hdl)
fhandler_pipe *fh = cfd; {
n = sizeof *fh; fhandler_pipe *fh = cfd;
if (!WriteFile (tothem, &n, sizeof n, &nr, NULL)) n = sizeof *fh;
sigproc_printf ("WriteFile sizeof hdl failed, %E"); if (!WriteFile (tothem, &n, sizeof n, &nr, NULL))
else if (!WriteFile (tothem, fh, n, &nr, NULL)) sigproc_printf ("WriteFile sizeof hdl failed, %E");
sigproc_printf ("WriteFile hdl failed, %E"); else if (!WriteFile (tothem, fh, n, &nr, NULL))
break; sigproc_printf ("WriteFile hdl failed, %E");
} break;
if (!n && !WriteFile (tothem, &n, sizeof n, &nr, NULL)) }
sigproc_printf ("WriteFile sizeof hdl failed, %E"); if (!n && !WriteFile (tothem, &n, sizeof n, &nr, NULL))
break; sigproc_printf ("WriteFile sizeof hdl failed, %E");
} break;
}
case PICOM_FD: case PICOM_FD:
{ {
sigproc_printf ("processing PICOM_FD");
int fd = si._si_commune._si_fd; int fd = si._si_commune._si_fd;
unsigned int n = 0; unsigned int n = 0;
cygheap_fdget cfd (fd); cygheap_fdget cfd (fd);
@ -505,6 +511,7 @@ _pinfo::commune_process (siginfo_t& si)
} }
case PICOM_FIFO: case PICOM_FIFO:
{ {
sigproc_printf ("processing PICOM_FIFO");
fhandler_fifo *fh = cygheap->fdtab.find_fifo (si._si_commune._si_str); fhandler_fifo *fh = cygheap->fdtab.find_fifo (si._si_commune._si_str);
HANDLE it[2]; HANDLE it[2];
if (fh == NULL) if (fh == NULL)
@ -530,7 +537,11 @@ _pinfo::commune_process (siginfo_t& si)
} }
if (process_sync) if (process_sync)
{ {
WaitForSingleObject (process_sync, INFINITE); DWORD res = WaitForSingleObject (process_sync, 5000);
if (res != WAIT_OBJECT_0)
sigproc_printf ("WFSO failed - %d, %E", res);
else
sigproc_printf ("synchronized with pid %d", si.si_pid);
ForceCloseHandle (process_sync); ForceCloseHandle (process_sync);
} }
CloseHandle (tothem); CloseHandle (tothem);
@ -586,7 +597,11 @@ _pinfo::commune_request (__uint32_t code, ...)
si.si_signo = __SIGCOMMUNE; si.si_signo = __SIGCOMMUNE;
if (sig_send (this, si)) if (sig_send (this, si))
goto err; {
ForceCloseHandle (request_sync); /* don't signal semaphore since there was apparently no receiving process */
request_sync = NULL;
goto err;
}
size_t n; size_t n;
switch (code) switch (code)

View File

@ -970,7 +970,9 @@ stopped_or_terminated (waitq *parent_w, _pinfo *child)
static void static void
talktome (siginfo_t& si, HANDLE readsig) talktome (siginfo_t& si, HANDLE readsig)
{ {
sigproc_printf ("pid %d wants some information", si.si_pid);
pinfo pi (si.si_pid); pinfo pi (si.si_pid);
sigproc_printf ("pid %d pi %p", si.si_pid, (_pinfo *) pi); // DELETEME
if (si._si_commune._si_code & PICOM_EXTRASTR) if (si._si_commune._si_code & PICOM_EXTRASTR)
{ {
size_t n; size_t n;
@ -1173,6 +1175,7 @@ wait_sig (VOID *)
break; break;
} }
CloseHandle (readsig);
sigproc_printf ("signal thread exiting"); sigproc_printf ("signal thread exiting");
ExitThread (0); ExitThread (0);
} }

View File

@ -2610,10 +2610,10 @@ locked_append (int fd, const void * buf, size_t size)
int count = 0; int count = 0;
do do
if ((lock_buffer.l_start = lseek64 (fd, 0, SEEK_END)) != (_off64_t)-1 if ((lock_buffer.l_start = lseek64 (fd, 0, SEEK_END)) != (_off64_t) -1
&& fcntl_worker (fd, F_SETLKW, &lock_buffer) != -1) && fcntl_worker (fd, F_SETLKW, &lock_buffer) != -1)
{ {
if (lseek64 (fd, 0, SEEK_END) != (_off64_t)-1) if (lseek64 (fd, 0, SEEK_END) != (_off64_t) -1)
write (fd, buf, size); write (fd, buf, size);
lock_buffer.l_type = F_UNLCK; lock_buffer.l_type = F_UNLCK;
fcntl_worker (fd, F_SETLK, &lock_buffer); fcntl_worker (fd, F_SETLK, &lock_buffer);