Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] create_file_handler thinko?
@ 2002-05-13 15:01 Keith Seitz
  2002-05-13 20:00 ` Elena Zannoni
  0 siblings, 1 reply; 3+ messages in thread
From: Keith Seitz @ 2002-05-13 15:01 UTC (permalink / raw)
  To: gdb-patches

Hi,

According to comments in create_file_handler, calling create_file_handler
twice with the same fd should result in only a modification of the
parameters for the fd.

However, the source doesn't read this way. This patch changes
create_file_handler so that it behaves in a way consistent with its
comments.

Of course, if the comments are wrong, this patch is also completely
wrong...

Keith

ChangeLog
2002-05-13  Keith Seitz  <keiths@redhat.com>

        * event-loop.c (create_file_handler): Don't do anything but
        update data when we are given a fd which we are already
        monitoring.

Patch (mostly whitespace)
Index: event-loop.c
===================================================================
RCS file: /cvs/src/src/gdb/event-loop.c,v
retrieving revision 1.17
diff -p -r1.17 event-loop.c
*** event-loop.c	27 Nov 2001 04:15:09 -0000	1.17
--- event-loop.c	13 May 2002 21:59:26 -0000
*************** create_file_handler (int fd, int mask, h
*** 494,544 ****
        file_ptr->ready_mask = 0;
        file_ptr->next_file = gdb_notifier.first_file_handler;
        gdb_notifier.first_file_handler = file_ptr;
-     }
-   file_ptr->proc = proc;
-   file_ptr->client_data = client_data;
-   file_ptr->mask = mask;

!   if (use_poll)
!     {
  #ifdef HAVE_POLL
!       gdb_notifier.num_fds++;
!       if (gdb_notifier.poll_fds)
! 	gdb_notifier.poll_fds =
! 	  (struct pollfd *) xrealloc (gdb_notifier.poll_fds,
! 				      (gdb_notifier.num_fds
! 				       * sizeof (struct pollfd)));
!       else
! 	gdb_notifier.poll_fds =
! 	  (struct pollfd *) xmalloc (sizeof (struct pollfd));
!       (gdb_notifier.poll_fds + gdb_notifier.num_fds - 1)->fd = fd;
!       (gdb_notifier.poll_fds + gdb_notifier.num_fds - 1)->events = mask;
!       (gdb_notifier.poll_fds + gdb_notifier.num_fds - 1)->revents = 0;
  #else
!       internal_error (__FILE__, __LINE__,
! 		      "use_poll without HAVE_POLL");
  #endif /* HAVE_POLL */
!     }
!   else
!     {
!       if (mask & GDB_READABLE)
! 	FD_SET (fd, &gdb_notifier.check_masks[0]);
        else
! 	FD_CLR (fd, &gdb_notifier.check_masks[0]);

!       if (mask & GDB_WRITABLE)
! 	FD_SET (fd, &gdb_notifier.check_masks[1]);
!       else
! 	FD_CLR (fd, &gdb_notifier.check_masks[1]);

!       if (mask & GDB_EXCEPTION)
! 	FD_SET (fd, &gdb_notifier.check_masks[2]);
!       else
! 	FD_CLR (fd, &gdb_notifier.check_masks[2]);

!       if (gdb_notifier.num_fds <= fd)
! 	gdb_notifier.num_fds = fd + 1;
      }
  }

  /* Remove the file descriptor FD from the list of monitored fd's:
--- 494,545 ----
        file_ptr->ready_mask = 0;
        file_ptr->next_file = gdb_notifier.first_file_handler;
        gdb_notifier.first_file_handler = file_ptr;

!       if (use_poll)
! 	{
  #ifdef HAVE_POLL
! 	  gdb_notifier.num_fds++;
! 	  if (gdb_notifier.poll_fds)
! 	    gdb_notifier.poll_fds =
! 	      (struct pollfd *) xrealloc (gdb_notifier.poll_fds,
! 					  (gdb_notifier.num_fds
! 					   * sizeof (struct pollfd)));
! 	  else
! 	    gdb_notifier.poll_fds =
! 	      (struct pollfd *) xmalloc (sizeof (struct pollfd));
! 	  (gdb_notifier.poll_fds + gdb_notifier.num_fds - 1)->fd = fd;
! 	  (gdb_notifier.poll_fds + gdb_notifier.num_fds - 1)->events = mask;
! 	  (gdb_notifier.poll_fds + gdb_notifier.num_fds - 1)->revents = 0;
  #else
! 	  internal_error (__FILE__, __LINE__,
! 			  "use_poll without HAVE_POLL");
  #endif /* HAVE_POLL */
! 	}
        else
! 	{
! 	  if (mask & GDB_READABLE)
! 	    FD_SET (fd, &gdb_notifier.check_masks[0]);
! 	  else
! 	    FD_CLR (fd, &gdb_notifier.check_masks[0]);

! 	  if (mask & GDB_WRITABLE)
! 	    FD_SET (fd, &gdb_notifier.check_masks[1]);
! 	  else
! 	    FD_CLR (fd, &gdb_notifier.check_masks[1]);

! 	  if (mask & GDB_EXCEPTION)
! 	    FD_SET (fd, &gdb_notifier.check_masks[2]);
! 	  else
! 	    FD_CLR (fd, &gdb_notifier.check_masks[2]);

! 	  if (gdb_notifier.num_fds <= fd)
! 	    gdb_notifier.num_fds = fd + 1;
! 	}
      }
+
+   file_ptr->proc = proc;
+   file_ptr->client_data = client_data;
+   file_ptr->mask = mask;
  }

  /* Remove the file descriptor FD from the list of monitored fd's:


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFA] create_file_handler thinko?
  2002-05-13 15:01 [RFA] create_file_handler thinko? Keith Seitz
@ 2002-05-13 20:00 ` Elena Zannoni
  2002-05-14  8:22   ` Keith Seitz
  0 siblings, 1 reply; 3+ messages in thread
From: Elena Zannoni @ 2002-05-13 20:00 UTC (permalink / raw)
  To: Keith Seitz; +Cc: gdb-patches

Keith Seitz writes:
 > Hi,
 > 
 > According to comments in create_file_handler, calling create_file_handler
 > twice with the same fd should result in only a modification of the
 > parameters for the fd.
 > 
 > However, the source doesn't read this way. This patch changes
 > create_file_handler so that it behaves in a way consistent with its
 > comments.
 > 
 > Of course, if the comments are wrong, this patch is also completely
 > wrong...
 > 

The comment is fine. I think the code and the comment got out of
synch in one of the HAVE_POLL, use_poll etc cleanups.

Please check it in.

Thanks
Elena



 > Keith
 > 
 > ChangeLog
 > 2002-05-13  Keith Seitz  <keiths@redhat.com>
 > 
 >         * event-loop.c (create_file_handler): Don't do anything but
 >         update data when we are given a fd which we are already
 >         monitoring.
 > 
 > Patch (mostly whitespace)
 > Index: event-loop.c
 > ===================================================================
 > RCS file: /cvs/src/src/gdb/event-loop.c,v
 > retrieving revision 1.17
 > diff -p -r1.17 event-loop.c
 > *** event-loop.c	27 Nov 2001 04:15:09 -0000	1.17
 > --- event-loop.c	13 May 2002 21:59:26 -0000
 > *************** create_file_handler (int fd, int mask, h
 > *** 494,544 ****
 >         file_ptr->ready_mask = 0;
 >         file_ptr->next_file = gdb_notifier.first_file_handler;
 >         gdb_notifier.first_file_handler = file_ptr;
 > -     }
 > -   file_ptr->proc = proc;
 > -   file_ptr->client_data = client_data;
 > -   file_ptr->mask = mask;
 > 
 > !   if (use_poll)
 > !     {
 >   #ifdef HAVE_POLL
 > !       gdb_notifier.num_fds++;
 > !       if (gdb_notifier.poll_fds)
 > ! 	gdb_notifier.poll_fds =
 > ! 	  (struct pollfd *) xrealloc (gdb_notifier.poll_fds,
 > ! 				      (gdb_notifier.num_fds
 > ! 				       * sizeof (struct pollfd)));
 > !       else
 > ! 	gdb_notifier.poll_fds =
 > ! 	  (struct pollfd *) xmalloc (sizeof (struct pollfd));
 > !       (gdb_notifier.poll_fds + gdb_notifier.num_fds - 1)->fd = fd;
 > !       (gdb_notifier.poll_fds + gdb_notifier.num_fds - 1)->events = mask;
 > !       (gdb_notifier.poll_fds + gdb_notifier.num_fds - 1)->revents = 0;
 >   #else
 > !       internal_error (__FILE__, __LINE__,
 > ! 		      "use_poll without HAVE_POLL");
 >   #endif /* HAVE_POLL */
 > !     }
 > !   else
 > !     {
 > !       if (mask & GDB_READABLE)
 > ! 	FD_SET (fd, &gdb_notifier.check_masks[0]);
 >         else
 > ! 	FD_CLR (fd, &gdb_notifier.check_masks[0]);
 > 
 > !       if (mask & GDB_WRITABLE)
 > ! 	FD_SET (fd, &gdb_notifier.check_masks[1]);
 > !       else
 > ! 	FD_CLR (fd, &gdb_notifier.check_masks[1]);
 > 
 > !       if (mask & GDB_EXCEPTION)
 > ! 	FD_SET (fd, &gdb_notifier.check_masks[2]);
 > !       else
 > ! 	FD_CLR (fd, &gdb_notifier.check_masks[2]);
 > 
 > !       if (gdb_notifier.num_fds <= fd)
 > ! 	gdb_notifier.num_fds = fd + 1;
 >       }
 >   }
 > 
 >   /* Remove the file descriptor FD from the list of monitored fd's:
 > --- 494,545 ----
 >         file_ptr->ready_mask = 0;
 >         file_ptr->next_file = gdb_notifier.first_file_handler;
 >         gdb_notifier.first_file_handler = file_ptr;
 > 
 > !       if (use_poll)
 > ! 	{
 >   #ifdef HAVE_POLL
 > ! 	  gdb_notifier.num_fds++;
 > ! 	  if (gdb_notifier.poll_fds)
 > ! 	    gdb_notifier.poll_fds =
 > ! 	      (struct pollfd *) xrealloc (gdb_notifier.poll_fds,
 > ! 					  (gdb_notifier.num_fds
 > ! 					   * sizeof (struct pollfd)));
 > ! 	  else
 > ! 	    gdb_notifier.poll_fds =
 > ! 	      (struct pollfd *) xmalloc (sizeof (struct pollfd));
 > ! 	  (gdb_notifier.poll_fds + gdb_notifier.num_fds - 1)->fd = fd;
 > ! 	  (gdb_notifier.poll_fds + gdb_notifier.num_fds - 1)->events = mask;
 > ! 	  (gdb_notifier.poll_fds + gdb_notifier.num_fds - 1)->revents = 0;
 >   #else
 > ! 	  internal_error (__FILE__, __LINE__,
 > ! 			  "use_poll without HAVE_POLL");
 >   #endif /* HAVE_POLL */
 > ! 	}
 >         else
 > ! 	{
 > ! 	  if (mask & GDB_READABLE)
 > ! 	    FD_SET (fd, &gdb_notifier.check_masks[0]);
 > ! 	  else
 > ! 	    FD_CLR (fd, &gdb_notifier.check_masks[0]);
 > 
 > ! 	  if (mask & GDB_WRITABLE)
 > ! 	    FD_SET (fd, &gdb_notifier.check_masks[1]);
 > ! 	  else
 > ! 	    FD_CLR (fd, &gdb_notifier.check_masks[1]);
 > 
 > ! 	  if (mask & GDB_EXCEPTION)
 > ! 	    FD_SET (fd, &gdb_notifier.check_masks[2]);
 > ! 	  else
 > ! 	    FD_CLR (fd, &gdb_notifier.check_masks[2]);
 > 
 > ! 	  if (gdb_notifier.num_fds <= fd)
 > ! 	    gdb_notifier.num_fds = fd + 1;
 > ! 	}
 >       }
 > +
 > +   file_ptr->proc = proc;
 > +   file_ptr->client_data = client_data;
 > +   file_ptr->mask = mask;
 >   }
 > 
 >   /* Remove the file descriptor FD from the list of monitored fd's:


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFA] create_file_handler thinko?
  2002-05-13 20:00 ` Elena Zannoni
@ 2002-05-14  8:22   ` Keith Seitz
  0 siblings, 0 replies; 3+ messages in thread
From: Keith Seitz @ 2002-05-14  8:22 UTC (permalink / raw)
  To: gdb-patches

On Mon, 13 May 2002, Elena Zannoni wrote:

> The comment is fine. I think the code and the comment got out of
> synch in one of the HAVE_POLL, use_poll etc cleanups.
>
> Please check it in.

Ok, cool. It's in.

Thanks for the quick review!
Keith


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-05-14 15:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-13 15:01 [RFA] create_file_handler thinko? Keith Seitz
2002-05-13 20:00 ` Elena Zannoni
2002-05-14  8:22   ` Keith Seitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox