From dc3fb58a904f25f87fd2c6b4501af773f202d2a9 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Mon, 12 Oct 2009 10:07:03 +0200 Subject: [PATCH] gstpoll: Add some debugging statements --- gst/gstpoll.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/gst/gstpoll.c b/gst/gstpoll.c index 00cd296b10..17c0a550bf 100644 --- a/gst/gstpoll.c +++ b/gst/gstpoll.c @@ -486,6 +486,8 @@ gst_poll_new (gboolean controllable) { GstPoll *nset; + GST_DEBUG ("controllable : %d", controllable); + nset = g_slice_new0 (GstPoll); nset->lock = g_mutex_new (); #ifndef G_OS_WIN32 @@ -561,6 +563,8 @@ gst_poll_free (GstPoll * set) { g_return_if_fail (set != NULL); + GST_DEBUG_OBJECT (set, "Freeing"); + #ifndef G_OS_WIN32 if (set->control_write_fd.fd >= 0) close (set->control_write_fd.fd); @@ -610,6 +614,8 @@ gst_poll_add_fd_unlocked (GstPoll * set, GstPollFD * fd) { gint idx; + GST_DEBUG_OBJECT (set, "fd (fd:%d, idx:%d)", fd->fd, fd->idx); + idx = find_index (set->fds, fd); if (idx < 0) { #ifndef G_OS_WIN32 @@ -637,6 +643,8 @@ gst_poll_add_fd_unlocked (GstPoll * set, GstPollFD * fd) fd->idx = set->fds->len - 1; #endif + } else { + GST_WARNING_OBJECT (set, "Couldn't find fd !"); } return TRUE; @@ -691,6 +699,9 @@ gst_poll_remove_fd (GstPoll * set, GstPollFD * fd) g_return_val_if_fail (fd != NULL, FALSE); g_return_val_if_fail (fd->fd >= 0, FALSE); + + GST_DEBUG_OBJECT (set, "fd (fd:%d, idx:%d)", fd->fd, fd->idx); + g_mutex_lock (set->lock); /* get the index, -1 is an fd that is not added */ @@ -707,6 +718,8 @@ gst_poll_remove_fd (GstPoll * set, GstPollFD * fd) /* mark fd as removed by setting the index to -1 */ fd->idx = -1; + } else { + GST_WARNING_OBJECT (set, "Couldn't find fd !"); } g_mutex_unlock (set->lock); @@ -736,6 +749,9 @@ gst_poll_fd_ctl_write (GstPoll * set, GstPollFD * fd, gboolean active) g_return_val_if_fail (fd != NULL, FALSE); g_return_val_if_fail (fd->fd >= 0, FALSE); + GST_DEBUG_OBJECT (set, "fd (fd:%d, idx:%d), active : %d", + fd->fd, fd->idx, active); + g_mutex_lock (set->lock); idx = find_index (set->fds, fd); @@ -747,10 +763,14 @@ gst_poll_fd_ctl_write (GstPoll * set, GstPollFD * fd, gboolean active) pfd->events |= POLLOUT; else pfd->events &= ~POLLOUT; + + GST_LOG ("pfd->events now %d (POLLOUT:%d)", pfd->events, POLLOUT); #else gst_poll_update_winsock_event_mask (set, idx, FD_WRITE | FD_CONNECT, active); #endif + } else { + GST_WARNING_OBJECT (set, "Couldn't find fd !"); } g_mutex_unlock (set->lock); @@ -763,6 +783,9 @@ gst_poll_fd_ctl_read_unlocked (GstPoll * set, GstPollFD * fd, gboolean active) { gint idx; + GST_DEBUG_OBJECT (set, "fd (fd:%d, idx:%d), active : %d", + fd->fd, fd->idx, active); + idx = find_index (set->fds, fd); if (idx >= 0) { @@ -776,6 +799,8 @@ gst_poll_fd_ctl_read_unlocked (GstPoll * set, GstPollFD * fd, gboolean active) #else gst_poll_update_winsock_event_mask (set, idx, FD_READ | FD_ACCEPT, active); #endif + } else { + GST_WARNING_OBJECT (set, "Couldn't find fd !"); } return idx >= 0; @@ -872,6 +897,8 @@ gst_poll_fd_has_closed (const GstPoll * set, GstPollFD * fd) g_return_val_if_fail (fd != NULL, FALSE); g_return_val_if_fail (fd->fd >= 0, FALSE); + GST_DEBUG_OBJECT (set, "fd (fd:%d, idx:%d)", fd->fd, fd->idx); + g_mutex_lock (set->lock); idx = find_index (set->active_fds, fd); @@ -885,6 +912,8 @@ gst_poll_fd_has_closed (const GstPoll * set, GstPollFD * fd) res = (wfd->events.lNetworkEvents & FD_CLOSE) != 0; #endif + } else { + GST_WARNING_OBJECT (set, "Couldn't find fd !"); } g_mutex_unlock (set->lock); @@ -913,6 +942,8 @@ gst_poll_fd_has_error (const GstPoll * set, GstPollFD * fd) g_return_val_if_fail (fd != NULL, FALSE); g_return_val_if_fail (fd->fd >= 0, FALSE); + GST_DEBUG_OBJECT (set, "fd (fd:%d, idx:%d)", fd->fd, fd->idx); + g_mutex_lock (set->lock); idx = find_index (set->active_fds, fd); @@ -930,6 +961,8 @@ gst_poll_fd_has_error (const GstPoll * set, GstPollFD * fd) (wfd->events.iErrorCode[FD_ACCEPT_BIT] != 0) || (wfd->events.iErrorCode[FD_CONNECT_BIT] != 0); #endif + } else { + GST_WARNING_OBJECT (set, "Couldn't find fd !"); } g_mutex_unlock (set->lock); @@ -943,6 +976,8 @@ gst_poll_fd_can_read_unlocked (const GstPoll * set, GstPollFD * fd) gboolean res = FALSE; gint idx; + GST_DEBUG_OBJECT (set, "fd (fd:%d, idx:%d)", fd->fd, fd->idx); + idx = find_index (set->active_fds, fd); if (idx >= 0) { #ifndef G_OS_WIN32 @@ -954,6 +989,8 @@ gst_poll_fd_can_read_unlocked (const GstPoll * set, GstPollFD * fd) res = (wfd->events.lNetworkEvents & (FD_READ | FD_ACCEPT)) != 0; #endif + } else { + GST_WARNING_OBJECT (set, "Couldn't find fd !"); } return res; @@ -1009,6 +1046,8 @@ gst_poll_fd_can_write (const GstPoll * set, GstPollFD * fd) g_return_val_if_fail (fd != NULL, FALSE); g_return_val_if_fail (fd->fd >= 0, FALSE); + GST_DEBUG_OBJECT (set, "fd (fd:%d, idx:%d)", fd->fd, fd->idx); + g_mutex_lock (set->lock); idx = find_index (set->active_fds, fd); @@ -1022,6 +1061,8 @@ gst_poll_fd_can_write (const GstPoll * set, GstPollFD * fd) res = (wfd->events.lNetworkEvents & FD_WRITE) != 0; #endif + } else { + GST_WARNING_OBJECT (set, "Couldn't find fd !"); } g_mutex_unlock (set->lock); @@ -1097,6 +1138,8 @@ gst_poll_wait (GstPoll * set, GstClockTime timeout) g_mutex_lock (set->lock); + GST_DEBUG ("timeout :%" GST_TIME_FORMAT, GST_TIME_ARGS (timeout)); + /* we cannot wait from multiple threads unless we are a timer */ if (G_UNLIKELY (set->waiting > 0 && !set->timer)) goto already_waiting; @@ -1202,7 +1245,9 @@ gst_poll_wait (GstPoll * set, GstClockTime timeout) tvptr = NULL; } + GST_DEBUG ("Calling select"); res = select (max_fd + 1, &readfds, &writefds, &errorfds, tvptr); + GST_DEBUG ("After select, res:%d", res); } else { #ifdef HAVE_PSELECT struct timespec ts; @@ -1215,8 +1260,10 @@ gst_poll_wait (GstPoll * set, GstClockTime timeout) tsptr = NULL; } + GST_DEBUG ("Calling pselect"); res = pselect (max_fd + 1, &readfds, &writefds, &errorfds, tsptr, NULL); + GST_DEBUG ("After pselect, res:%d", res); #endif } @@ -1332,6 +1379,8 @@ gst_poll_set_controllable (GstPoll * set, gboolean controllable) { g_return_val_if_fail (set != NULL, FALSE); + GST_LOG_OBJECT (set, "controllable : %d", controllable); + g_mutex_lock (set->lock); #ifndef G_OS_WIN32 @@ -1367,6 +1416,7 @@ gst_poll_set_controllable (GstPoll * set, gboolean controllable) #ifndef G_OS_WIN32 no_socket_pair: { + GST_WARNING_OBJECT (set, "Can't create socket pair !"); g_mutex_unlock (set->lock); return FALSE; }