* select.h (select_stuff): Remove variable names from parameter declarations.

(select_info): Ditto.
(select_record::dump_select_record): Declare new debugging-only function.
(select_info): Zero all fields.
(select_pipe_info): Ditto.
(select_socket_info): Ditto.
(select_serial_info): Ditto.
(select_mailslot_info): Ditto.
* select.cc (select_record::dump_select_record): Define new debugging-only
function.
(select_stuff::test_and_set): Call dump_select_record when debugging.
* thread.cc (pthread_mutex::unlock): Revert setting of tid to NULL since, in
this context, it is a number, not a pointer.
(pthread_spinlock::unlock): Ditto.
This commit is contained in:
Christopher Faylor 2012-12-22 19:35:41 +00:00
parent e97256cf70
commit 4a84997ae4
4 changed files with 55 additions and 11 deletions

View File

@ -1,3 +1,23 @@
2012-12-22 Christopher Faylor <me.cygwin2012@cgf.cx>
* select.h (select_stuff): Remove variable names from parameter
declarations.
(select_info): Ditto.
(select_record::dump_select_record): Declare new debugging-only
function.
(select_info): Zero all fields.
(select_pipe_info): Ditto.
(select_socket_info): Ditto.
(select_serial_info): Ditto.
(select_mailslot_info): Ditto.
* select.cc (select_record::dump_select_record): Define new
debugging-only function.
(select_stuff::test_and_set): Call dump_select_record when debugging.
* thread.cc (pthread_mutex::unlock): Revert setting of tid to NULL
since, in this context, it is a number, not a pointer.
(pthread_spinlock::unlock): Ditto.
2012-12-21 Christopher Faylor <me.cygwin2012@cgf.cx> 2012-12-21 Christopher Faylor <me.cygwin2012@cgf.cx>
* sigproc.cc (exit_thread): undef ExitThread or suffer recursion. * sigproc.cc (exit_thread): undef ExitThread or suffer recursion.

View File

@ -286,6 +286,22 @@ select_stuff::~select_stuff ()
destroy (); destroy ();
} }
#ifdef DEBUGGING
void
select_record::dump_select_record ()
{
select_printf ("fd %d, h %p, fh %p, thread_errno %d, windows_handle %p",
fd, h, fh, thread_errno, windows_handle);
select_printf ("read_ready %d, write_ready %d, except_ready %d",
read_ready, write_ready, except_ready);
select_printf ("read_selected %d, write_selected %d, except_selected %d, except_on_write %d",
read_selected, write_selected, except_selected, except_on_write);
select_printf ("startup %p, peek %p, verify %p cleanup %p, next %p",
startup, peek, verify, cleanup, next);
}
#endif /*DEBUGGING*/
/* Add a record to the select chain */ /* Add a record to the select chain */
bool bool
select_stuff::test_and_set (int i, fd_set *readfds, fd_set *writefds, select_stuff::test_and_set (int i, fd_set *readfds, fd_set *writefds,
@ -315,6 +331,9 @@ select_stuff::test_and_set (int i, fd_set *readfds, fd_set *writefds,
if (s->windows_handle) if (s->windows_handle)
windows_used = true; windows_used = true;
#ifdef DEBUGGING
s->dump_select_record ();
#endif
return true; return true;
err: err:

View File

@ -22,11 +22,10 @@ struct select_record
bool read_ready, write_ready, except_ready; bool read_ready, write_ready, except_ready;
bool read_selected, write_selected, except_selected; bool read_selected, write_selected, except_selected;
bool except_on_write; bool except_on_write;
int (*startup) (select_record *me, class select_stuff *stuff); int (*startup) (select_record *, class select_stuff *);
int (*peek) (select_record *, bool); int (*peek) (select_record *, bool);
int (*verify) (select_record *me, fd_set *readfds, fd_set *writefds, int (*verify) (select_record *, fd_set *, fd_set *, fd_set *);
fd_set *exceptfds); void (*cleanup) (select_record *, class select_stuff *);
void (*cleanup) (select_record *me, class select_stuff *stuff);
struct select_record *next; struct select_record *next;
void set_select_errno () {__seterrno (); thread_errno = errno;} void set_select_errno () {__seterrno (); thread_errno = errno;}
int saw_error () {return thread_errno;} int saw_error () {return thread_errno;}
@ -37,6 +36,9 @@ struct select_record
except_selected (false), except_on_write (false), except_selected (false), except_on_write (false),
startup (NULL), peek (NULL), verify (NULL), cleanup (NULL), startup (NULL), peek (NULL), verify (NULL), cleanup (NULL),
next (NULL) {} next (NULL) {}
#ifdef DEBUGGING
void dump_select_record ();
#endif
}; };
struct select_info struct select_info
@ -44,11 +46,12 @@ struct select_info
cygthread *thread; cygthread *thread;
bool stop_thread; bool stop_thread;
select_record *start; select_record *start;
select_info () {} select_info (): thread (NULL), stop_thread (0), start (NULL) {}
}; };
struct select_pipe_info: public select_info struct select_pipe_info: public select_info
{ {
select_pipe_info (): select_info () {}
}; };
struct select_socket_info: public select_info struct select_socket_info: public select_info
@ -56,14 +59,17 @@ struct select_socket_info: public select_info
int num_w4; int num_w4;
LONG *ser_num; LONG *ser_num;
HANDLE *w4; HANDLE *w4;
select_socket_info (): select_info (), num_w4 (0), ser_num (0), w4 (NULL) {}
}; };
struct select_serial_info: public select_info struct select_serial_info: public select_info
{ {
select_serial_info (): select_info () {}
}; };
struct select_mailslot_info: public select_info struct select_mailslot_info: public select_info
{ {
select_mailslot_info (): select_info () {}
}; };
class select_stuff class select_stuff
@ -88,10 +94,9 @@ public:
select_serial_info *device_specific_serial; select_serial_info *device_specific_serial;
select_mailslot_info *device_specific_mailslot; select_mailslot_info *device_specific_mailslot;
bool test_and_set (int i, fd_set *readfds, fd_set *writefds, bool test_and_set (int, fd_set *, fd_set *, fd_set *);
fd_set *exceptfds); int poll (fd_set *, fd_set *, fd_set *);
int poll (fd_set *readfds, fd_set *writefds, fd_set *exceptfds); wait_states wait (fd_set *, fd_set *, fd_set *, DWORD);
wait_states wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds, DWORD ms);
void cleanup (); void cleanup ();
void destroy (); void destroy ();

View File

@ -1778,7 +1778,7 @@ pthread_mutex::unlock ()
{ {
owner = (pthread_t) _unlocked_mutex; owner = (pthread_t) _unlocked_mutex;
#ifdef DEBUGGING #ifdef DEBUGGING
tid = NULL; tid = 0; // thread-id
#endif #endif
if (InterlockedDecrement ((long *) &lock_counter)) if (InterlockedDecrement ((long *) &lock_counter))
::SetEvent (win32_obj_id); // Another thread is waiting ::SetEvent (win32_obj_id); // Another thread is waiting
@ -1905,7 +1905,7 @@ pthread_spinlock::unlock ()
{ {
owner = (pthread_t) _unlocked_mutex; owner = (pthread_t) _unlocked_mutex;
#ifdef DEBUGGING #ifdef DEBUGGING
tid = NULL; tid = 0; // thread-id
#endif #endif
InterlockedExchange ((long *) &lock_counter, 0); InterlockedExchange ((long *) &lock_counter, 0);
::SetEvent (win32_obj_id); ::SetEvent (win32_obj_id);